DCausse has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/399376 )

Change subject: Remove iterateOverScroll
......................................................................

Remove iterateOverScroll

it's misleading and does not work as expected.
Better to use Elastica Scroll API.

Change-Id: I1abafa745e35fcc84d2802d563756f0c6ba58f3c
Depends-On: Icb5af4c9957bc17476cd779b091a610fa2682a5a
---
M ElasticaConnection.php
1 file changed, 0 insertions(+), 55 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Elastica 
refs/changes/76/399376/1

diff --git a/ElasticaConnection.php b/ElasticaConnection.php
index 3b37d5b..781aa98 100644
--- a/ElasticaConnection.php
+++ b/ElasticaConnection.php
@@ -214,61 +214,6 @@
  * Utility class
  */
 class MWElasticUtils {
-       /**
-        * Iterate over a scroll.
-        *
-        * @param \Elastica\Index $index
-        * @param string $scrollId the initial $scrollId
-        * @param string $scrollTime the scroll timeout
-        * @param callable $consumer function that receives the results
-        * @param int $limit the max number of results to fetch (0: no limit)
-        * @param int $retryAttempts the number of times we retry
-        * @param callable $retryErrorCallback function called before each 
retries
-        */
-       public static function iterateOverScroll( \Elastica\Index $index, 
$scrollId, $scrollTime,
-               $consumer, $limit = 0, $retryAttempts = 0, $retryErrorCallback 
= null
-       ) {
-               $clearScroll = true;
-               $fetched = 0;
-
-               while ( true ) {
-                       $result = static::withRetry( $retryAttempts,
-                               function () use ( $index, $scrollId, 
$scrollTime ) {
-                                       return $index->search( [], [
-                                               'scroll_id' => $scrollId,
-                                               'scroll' => $scrollTime
-                                       ] );
-                               }, $retryErrorCallback );
-
-                       $scrollId = $result->getResponse()->getScrollId();
-
-                       if ( !$result->count() ) {
-                               // No need to clear scroll on the last call
-                               $clearScroll = false;
-                               break;
-                       }
-
-                       $fetched += $result->count();
-                       $results = $result->getResults();
-
-                       if ( $limit > 0 && $fetched > $limit ) {
-                               $results = array_slice( $results, 0, count( 
$results ) - ( $fetched - $limit ) );
-                       }
-                       $consumer( $results );
-
-                       if ( $limit > 0 && $fetched >= $limit ) {
-                               break;
-                       }
-               }
-               // @todo: catch errors and clear the scroll, it'd be easy with 
a finally block ...
-
-               if ( $clearScroll ) {
-                       try {
-                               $index->getClient()->request( 
"_search/scroll/".$scrollId, \Elastica\Request::DELETE );
-                       } catch ( Exception $e ) {
-                       }
-               }
-       }
 
        /**
         * A function that retries callback $func if it throws an exception.

-- 
To view, visit https://gerrit.wikimedia.org/r/399376
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1abafa745e35fcc84d2802d563756f0c6ba58f3c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Elastica
Gerrit-Branch: master
Gerrit-Owner: DCausse <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to