/** * <p>Return a list of cursors over the collection that can be used to scan it in parallel.</p> * * <p>Note: As of MongoDB 2.6, this method will work against a mongod, but not a mongos. </p> * * @param options the parallel scan options * @return a list of cursors, whose size may be less than the number requested * @mongodb.driver.manual reference/command/parallelCollectionScan/ Parallel Collection Scan * @mongodb.server.release 2.6 * @since 2.12 * @deprecated the parallelCollectionScan command will be removed in MongoDB 4.2 */ @Deprecated public List<Cursor> parallelScan(final ParallelScanOptions options) { List<Cursor> cursors = new ArrayList<Cursor>(); ParallelCollectionScanOperation<DBObject> operation = new ParallelCollectionScanOperation<DBObject>(getNamespace(), options.getNumCursors(), objectCodec) .batchSize(options.getBatchSize()); ReadPreference readPreferenceFromOptions = options.getReadPreference(); List<BatchCursor<DBObject>> mongoCursors = executor.execute(operation, readPreferenceFromOptions != null ? readPreferenceFromOptions : getReadPreference(), getReadConcern()); for (BatchCursor<DBObject> mongoCursor : mongoCursors) { cursors.add(new MongoCursorAdapter(new MongoBatchCursorAdapter<DBObject>(mongoCursor))); } return cursors; }
@Override public List<AsyncBatchCursor<T>> apply(final BsonDocument result, final ServerAddress serverAddress) { List<AsyncBatchCursor<T>> cursors = new ArrayList<AsyncBatchCursor<T>>(); for (BsonValue cursorValue : getCursorDocuments(result)) { cursors.add(new AsyncQueryBatchCursor<T>(createQueryResult(getCursorDocument(cursorValue.asDocument()), source.getServerDescription().getAddress()), 0, getBatchSize(), 0, decoder, source, connection)); } return cursors; } };
private BsonDocument getCommand(final SessionContext sessionContext) { BsonDocument document = new BsonDocument("parallelCollectionScan", new BsonString(namespace.getCollectionName())) .append("numCursors", new BsonInt32(getNumCursors())); appendReadConcernToCommand(sessionContext, document); return document; } }
/** * <p>Return a list of cursors over the collection that can be used to scan it in parallel.</p> * * <p>Note: As of MongoDB 2.6, this method will work against a mongod, but not a mongos. </p> * * @param options the parallel scan options * @return a list of cursors, whose size may be less than the number requested * @mongodb.driver.manual reference/command/parallelCollectionScan/ Parallel Collection Scan * @mongodb.server.release 2.6 * @since 2.12 * @deprecated the parallelCollectionScan command will be removed in MongoDB 4.2 */ @Deprecated public List<Cursor> parallelScan(final ParallelScanOptions options) { List<Cursor> cursors = new ArrayList<Cursor>(); ParallelCollectionScanOperation<DBObject> operation = new ParallelCollectionScanOperation<DBObject>(getNamespace(), options.getNumCursors(), objectCodec) .batchSize(options.getBatchSize()); ReadPreference readPreferenceFromOptions = options.getReadPreference(); List<BatchCursor<DBObject>> mongoCursors = executor.execute(operation, readPreferenceFromOptions != null ? readPreferenceFromOptions : getReadPreference(), getReadConcern()); for (BatchCursor<DBObject> mongoCursor : mongoCursors) { cursors.add(new MongoCursorAdapter(new MongoBatchCursorAdapter<DBObject>(mongoCursor))); } return cursors; }
@Override public List<BatchCursor<T>> apply(final BsonDocument result, final ServerAddress serverAddress) { List<BatchCursor<T>> cursors = new ArrayList<BatchCursor<T>>(); for (BsonValue cursorValue : getCursorDocuments(result)) { cursors.add(new QueryBatchCursor<T>(createQueryResult(getCursorDocument(cursorValue.asDocument()), source.getServerDescription().getAddress()), 0, getBatchSize(), decoder, source)); } return cursors; } };
private BsonDocument getCommand(final SessionContext sessionContext) { BsonDocument document = new BsonDocument("parallelCollectionScan", new BsonString(namespace.getCollectionName())) .append("numCursors", new BsonInt32(getNumCursors())); appendReadConcernToCommand(sessionContext, document); return document; } }
@Override public List<AsyncBatchCursor<T>> apply(final BsonDocument result, final ServerAddress serverAddress) { List<AsyncBatchCursor<T>> cursors = new ArrayList<AsyncBatchCursor<T>>(); for (BsonValue cursorValue : getCursorDocuments(result)) { cursors.add(new AsyncQueryBatchCursor<T>(createQueryResult(getCursorDocument(cursorValue.asDocument()), source.getServerDescription().getAddress()), 0, getBatchSize(), 0, decoder, source, connection)); } return cursors; } };
@Override public List<BatchCursor<T>> apply(final BsonDocument result, final ServerAddress serverAddress) { List<BatchCursor<T>> cursors = new ArrayList<BatchCursor<T>>(); for (BsonValue cursorValue : getCursorDocuments(result)) { cursors.add(new QueryBatchCursor<T>(createQueryResult(getCursorDocument(cursorValue.asDocument()), source.getServerDescription().getAddress()), 0, getBatchSize(), decoder, source)); } return cursors; } };