GoLang MongoCollection::parallelCollectionScan

request it (238)
GoLang replacement for PHP's MongoCollection::parallelCollectionScan [edit | history]

Do you know a GoLang replacement for PHP's MongoCollection::parallelCollectionScan? Write it!

PHP MongoCollection::parallelCollectionScan

PHP original manual for MongoCollection::parallelCollectionScan [ show | php.net ]


(PECL mongo >=1.5.0)

MongoCollection::parallelCollectionScanReturns an array of cursors to iterator over a full collection in parallel


public array[MongoCommandCursor] MongoCollection::parallelCollectionScan ( int $num_cursors )

This method returns an array of a maximum of num_cursors cursors. An iteration over one of the returned cursors results in a partial set of documents for a collection. Iteration over all the returned cursors results in getting every document back from the collection.

This method is a wrapper for the parallelCollectionScan MongoDB command.



The number of cursors to request from the server. Please note, that the server can return less cursors than you requested.

Return Values

Returns an array of MongoCommandCursor objects.


Example #1 MongoCollection::parallelCollectionScan() example

Returning all documents in a collection by using multiple cursors.

= new MongoClient;
$c $m->demo->cities;

/* Request three cursors */
$cursors $c->parallelCollectionScan);

/* Add all the cursors to the MultipleIterator */
$mi = new MultipleIteratorMultipleIterator::MIT_NEED_ANY );
foreach ( 
$cursors as $cursor )
$mi->attachIterator$cursor );

/* Iterate over all the associated cursors */
foreach ( $mi as $items )
    foreach ( 
$items as $item )
        if ( 
$item !== NULL )
$item['name'], "\n";

See Also