/** * Gets an operation whose execution explains this operation. * * @param explainVerbosity the explain verbosity * @return a read operation that when executed will explain this operation */ public ReadOperation<BsonDocument> asExplainableOperation(final ExplainVerbosity explainVerbosity) { if (countStrategy.equals(CountStrategy.COMMAND)) { return createExplainableOperation(explainVerbosity); } else { return getAggregateOperation().asExplainableOperation(explainVerbosity); } }
/** * Gets an operation whose execution explains this operation. * * @param explainVerbosity the explain verbosity * @return a read operation that when executed will explain this operation */ public AsyncReadOperation<BsonDocument> asExplainableOperationAsync(final ExplainVerbosity explainVerbosity) { if (countStrategy.equals(CountStrategy.COMMAND)) { return createExplainableOperation(explainVerbosity); } else { return getAggregateOperation().asExplainableOperationAsync(explainVerbosity); } }
getAggregateOperation().executeAsync(binding, new SingleResultCallback<AsyncBatchCursor<BsonDocument>>(){ @Override public void onResult(final AsyncBatchCursor<BsonDocument> result, final Throwable t) {
@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; } }
/** * Gets an operation whose execution explains this operation. * * @param explainVerbosity the explain verbosity * @return a read operation that when executed will explain this operation */ public AsyncReadOperation<BsonDocument> asExplainableOperationAsync(final ExplainVerbosity explainVerbosity) { if (countStrategy.equals(CountStrategy.COMMAND)) { return createExplainableOperation(explainVerbosity); } else { return getAggregateOperation().asExplainableOperationAsync(explainVerbosity); } }
/** * Gets an operation whose execution explains this operation. * * @param explainVerbosity the explain verbosity * @return a read operation that when executed will explain this operation */ public ReadOperation<BsonDocument> asExplainableOperation(final ExplainVerbosity explainVerbosity) { if (countStrategy.equals(CountStrategy.COMMAND)) { return createExplainableOperation(explainVerbosity); } else { return getAggregateOperation().asExplainableOperation(explainVerbosity); } }
getAggregateOperation().executeAsync(binding, new SingleResultCallback<AsyncBatchCursor<BsonDocument>>(){ @Override public void onResult(final AsyncBatchCursor<BsonDocument> result, final Throwable t) {
@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; } }