@Override public BatchCursor<T> call(final ConnectionSource source, final Connection connection) { validateReadConcernAndCollation(connection, binding.getSessionContext().getReadConcern(), collation); return executeWrappedCommandProtocol(binding, namespace.getDatabaseName(), getCommand(binding.getSessionContext()), createCommandDecoder(), connection, transformer(source, connection)); } });
static <T> T executeWrappedCommandProtocol(final ReadBinding binding, final String database, final BsonDocument command, final Decoder<BsonDocument> decoder, final Connection connection, final CommandTransformer<BsonDocument, T> transformer) { return executeWrappedCommandProtocol(database, command, decoder, connection, binding.getReadPreference(), transformer, binding.getSessionContext()); }
@Override public Long call(final Connection connection) { validateReadConcernAndCollation(connection, binding.getSessionContext().getReadConcern(), collation); return executeWrappedCommandProtocol(binding, namespace.getDatabaseName(), getCommand(binding.getSessionContext()), DECODER, connection, transformer()); } });
@Override public MapReduceBatchCursor<T> call(final ConnectionSource source, final Connection connection) { validateReadConcernAndCollation(connection, binding.getSessionContext().getReadConcern(), collation); return executeWrappedCommandProtocol(binding, namespace.getDatabaseName(), getCommand(binding.getSessionContext()), CommandResultDocumentCodec.create(decoder, "results"), connection, transformer(source, connection)); } });
@Override public List<BatchCursor<T>> call(final ConnectionSource source, final Connection connection) { validateReadConcern(connection, binding.getSessionContext().getReadConcern()); return executeWrappedCommandProtocol(binding, namespace.getDatabaseName(), getCommand(binding.getSessionContext()), CommandResultDocumentCodec.create(decoder, "firstBatch"), connection, transformer(source)); } });
@Override public BatchCursor<T> call(final ConnectionSource source, final Connection connection) { validateReadConcernAndCollation(connection, binding.getSessionContext().getReadConcern(), collation); return executeWrappedCommandProtocol(binding, namespace.getDatabaseName(), getCommand(connection.getDescription(), binding.getSessionContext()), CommandResultDocumentCodec.create(decoder, FIELD_NAMES_WITH_RESULT), connection, transformer(source, connection)); } });
ChangeStreamBatchCursor(final ChangeStreamOperation<T> changeStreamOperation, final BatchCursor<RawBsonDocument> wrapped, final ReadBinding binding) { changeStreamOperation.startOperationTimeForResume(binding.getSessionContext().getOperationTime()); this.changeStreamOperation = changeStreamOperation; this.resumeToken = changeStreamOperation.getResumeToken(); this.wrapped = wrapped; this.binding = binding.retain(); }
if (serverIsAtLeastVersionThreeDotTwo(connection.getDescription())) { try { validateReadConcernAndCollation(connection, binding.getSessionContext().getReadConcern(), collation); return executeWrappedCommandProtocol(binding, namespace.getDatabaseName(), wrapInExplainIfNecessary(getCommand(binding.getSessionContext())), CommandResultDocumentCodec.create(decoder, FIRST_BATCH), connection, transformer(source, connection)); validateReadConcernAndCollation(connection, binding.getSessionContext().getReadConcern(), collation); QueryResult<T> queryResult = connection.query(namespace, asDocument(connection.getDescription(), binding.getReadPreference()),
static <T> T executeWrappedCommandProtocol(final ReadBinding binding, final String database, final BsonDocument command, final Decoder<BsonDocument> decoder, final Connection connection, final CommandTransformer<BsonDocument, T> transformer) { return executeWrappedCommandProtocol(database, command, decoder, connection, binding.getReadPreference(), transformer, binding.getSessionContext()); }
@Override public Long call(final Connection connection) { validateReadConcernAndCollation(connection, binding.getSessionContext().getReadConcern(), collation); return executeWrappedCommandProtocol(binding, namespace.getDatabaseName(), getCommand(binding.getSessionContext()), DECODER, connection, transformer()); } });
@Override public BatchCursor<T> call(final ConnectionSource source, final Connection connection) { validateReadConcernAndCollation(connection, binding.getSessionContext().getReadConcern(), collation); return executeWrappedCommandProtocol(binding, namespace.getDatabaseName(), getCommand(binding.getSessionContext()), createCommandDecoder(), connection, transformer(source, connection)); } });
@Override public MapReduceBatchCursor<T> call(final ConnectionSource source, final Connection connection) { validateReadConcernAndCollation(connection, binding.getSessionContext().getReadConcern(), collation); return executeWrappedCommandProtocol(binding, namespace.getDatabaseName(), getCommand(binding.getSessionContext()), CommandResultDocumentCodec.create(decoder, "results"), connection, transformer(source, connection)); } });
@Override public List<BatchCursor<T>> call(final ConnectionSource source, final Connection connection) { validateReadConcern(connection, binding.getSessionContext().getReadConcern()); return executeWrappedCommandProtocol(binding, namespace.getDatabaseName(), getCommand(binding.getSessionContext()), CommandResultDocumentCodec.create(decoder, "firstBatch"), connection, transformer(source)); } });
@Override public BatchCursor<T> call(final ConnectionSource source, final Connection connection) { validateReadConcernAndCollation(connection, binding.getSessionContext().getReadConcern(), collation); return executeWrappedCommandProtocol(binding, namespace.getDatabaseName(), getCommand(connection.getDescription(), binding.getSessionContext()), CommandResultDocumentCodec.create(decoder, FIELD_NAMES_WITH_RESULT), connection, transformer(source, connection)); } });
ChangeStreamBatchCursor(final ChangeStreamOperation<T> changeStreamOperation, final BatchCursor<RawBsonDocument> wrapped, final ReadBinding binding) { changeStreamOperation.startOperationTimeForResume(binding.getSessionContext().getOperationTime()); this.changeStreamOperation = changeStreamOperation; this.resumeToken = changeStreamOperation.getResumeToken(); this.wrapped = wrapped; this.binding = binding.retain(); }
if (serverIsAtLeastVersionThreeDotTwo(connection.getDescription())) { try { validateReadConcernAndCollation(connection, binding.getSessionContext().getReadConcern(), collation); return executeWrappedCommandProtocol(binding, namespace.getDatabaseName(), wrapInExplainIfNecessary(getCommand(binding.getSessionContext())), CommandResultDocumentCodec.create(decoder, FIRST_BATCH), connection, transformer(source, connection)); validateReadConcernAndCollation(connection, binding.getSessionContext().getReadConcern(), collation); QueryResult<T> queryResult = connection.query(namespace, asDocument(connection.getDescription(), binding.getReadPreference()),