@Override public List<T> apply(final BatchCursor<RawBsonDocument> queryBatchCursor) { return convertResults(queryBatchCursor.next()); } });
@Override public T next() { if (!hasNext()) { throw new NoSuchElementException(); } if (curBatch == null) { curBatch = batchCursor.next(); } return getNextInBatch(); }
private static BasicDBList toDBList(final BatchCursor<DBObject> source) { BasicDBList dbList = new BasicDBList(); while (source.hasNext()) { dbList.addAll(source.next()); } return dbList; }
@Nullable @Override public TResult first() { BatchCursor<TResult> batchCursor = getExecutor().execute(operations.findFirst(filter, resultClass, findOptions), getReadPreference(), getReadConcern(), getClientSession()); try { return batchCursor.hasNext() ? batchCursor.next().iterator().next() : null; } finally { batchCursor.close(); } }
@Override public Long execute(final ReadBinding binding) { if (countStrategy.equals(CountStrategy.COMMAND)) { return withConnection(binding, new CallableWithConnection<Long>() { @Override public Long call(final Connection connection) { validateReadConcernAndCollation(connection, binding.getSessionContext().getReadConcern(), collation); return executeWrappedCommandProtocol(binding, namespace.getDatabaseName(), getCommand(binding.getSessionContext()), DECODER, connection, transformer()); } }); } else { BatchCursor<BsonDocument> cursor = getAggregateOperation().execute(binding); return cursor.hasNext() ? getCountFromAggregateResults(cursor.next()) : 0; } }
@Override public List<T> apply(final BatchCursor<RawBsonDocument> queryBatchCursor) { return convertResults(queryBatchCursor.next()); } });
@Override public T next() { if (!hasNext()) { throw new NoSuchElementException(); } if (curBatch == null) { curBatch = batchCursor.next(); } return getNextInBatch(); }
@Override public T next() { if (!hasNext()) { throw new NoSuchElementException(); } if (curBatch == null) { curBatch = batchCursor.next(); } return getNextInBatch(); }
private static BasicDBList toDBList(final BatchCursor<DBObject> source) { BasicDBList dbList = new BasicDBList(); while (source.hasNext()) { dbList.addAll(source.next()); } return dbList; }
@Nullable @Override public TResult first() { BatchCursor<TResult> batchCursor = getExecutor().execute(operations.findFirst(filter, resultClass, findOptions), getReadPreference(), getReadConcern(), getClientSession()); try { return batchCursor.hasNext() ? batchCursor.next().iterator().next() : null; } finally { batchCursor.close(); } }
@Nullable @Override public TResult first() { BatchCursor<TResult> batchCursor = getExecutor().execute(operations.findFirst(filter, resultClass, findOptions), getReadPreference(), getReadConcern(), getClientSession()); try { return batchCursor.hasNext() ? batchCursor.next().iterator().next() : null; } finally { batchCursor.close(); } }
@Override public Long execute(final ReadBinding binding) { if (countStrategy.equals(CountStrategy.COMMAND)) { return withConnection(binding, new CallableWithConnection<Long>() { @Override public Long call(final Connection connection) { validateReadConcernAndCollation(connection, binding.getSessionContext().getReadConcern(), collation); return executeWrappedCommandProtocol(binding, namespace.getDatabaseName(), getCommand(binding.getSessionContext()), DECODER, connection, transformer()); } }); } else { BatchCursor<BsonDocument> cursor = getAggregateOperation().execute(binding); return cursor.hasNext() ? getCountFromAggregateResults(cursor.next()) : 0; } }