MongoCollection::parallelCollectionScan

(PECL mongo >=1.5.0)

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

说明

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

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.

参数

num_cursors

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

返回值

Returns an array of MongoCommandCursor objects.

范例

Example #1 MongoCollection::parallelCollectionScan() example

Returning all documents in a collection by using multiple cursors.

<?php
$m 
= 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 )
        {
            echo 
$item['name'], "\n";
        }
    }
}
?>

参见

相关文章
php vector returns the number of values in the collectionphp ibm db2 函数 returns an array indexed by column position representing a row in a result setphp ibm db2 函数 returns an array indexed by column name representing a row in a result setphp gnupg 函数 returns an array with information about all keys that matches the given patternphp postgresql 函数 returns an array with client protocol and server version when available php sqlite 函数 execute a query against a given database and returns an arrayphp imagickdraw returns an array representing the pattern of dashes and gaps used to stroke pathsphp mongocollection returns information about indexes on this collectionphp mongocollection returns an array of cursors to iterator over a full collection in parallelphp mongocollection set the read preference for this collectionphp mongodb driver server returns an array of information about this serverphp mongodb driver server returns an array of tags describing this server in a replica setphp mongodb gets an array of mongocollection objects for all collections in this databasephp recursivearrayiterator returns an iterator for the current entry if it is an array or an objectphp solrdocument returns an array of fields names in the documentphp solrdocument returns an array representation of the documentphp solrparams returns an array of non url encoded parametersphp solrparams returns an array of url encoded parametersphp splenum returns all consts possible values as an arrayphp splfixedarray returns the size of the array
关注编程学问公众号