/** * 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) { return new AggregateExplainOperation(getNamespace(), getPipeline()) .allowDiskUse(getAllowDiskUse()) .maxTime(getMaxAwaitTime(TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS) .hint(wrapped.getHint()); }
static void executeWrappedCommandProtocolAsync(final AsyncWriteBinding binding, final String database, final BsonDocument command, final AsyncConnection connection, final SingleResultCallback<BsonDocument> callback) { executeWrappedCommandProtocolAsync(binding, database, command, connection, new IdentityTransformer<BsonDocument>(), callback); }
@Override public void call(final AsyncConnection connection, final Throwable t) { if (t != null) { callable.call(connection, t); } else { validateCollation(connection, collation, callable); } } });
@Override public T execute(final WriteBinding binding) { return executeRetryableCommand(binding, getDatabaseName(), null, getFieldNameValidator(), CommandResultDocumentCodec.create(getDecoder(), "value"), getCommandCreator(binding.getSessionContext()), FindAndModifyHelper.<T>transformer()); }
private AggregateOperation<BsonDocument> getAggregateOperation() { return new AggregateOperation<BsonDocument>(namespace, getPipeline(), DECODER) .collation(collation) .hint(hint) .maxTime(maxTimeMS, TimeUnit.MILLISECONDS); }
static MapReduceStatistics createStatistics(final BsonDocument result) { return new MapReduceStatistics(getInputCount(result), getOutputCount(result), getEmitCount(result), getDuration(result)); }
private MixedBulkWriteOperation getMixedBulkOperation() { return new MixedBulkWriteOperation(namespace, getWriteRequests(), ordered, writeConcern, retryWrites) .bypassDocumentValidation(bypassDocumentValidation); }
@Override public BatchCursor<T> call(final ConnectionSource connectionSource, final Connection connection) { validateCollation(connection, collation); return executeWrappedCommandProtocol(binding, namespace.getDatabaseName(), getCommand(), CommandResultDocumentCodec.create(decoder, "retval"), connection, transformer(connectionSource, connection)); } });
static <T> T executeWrappedCommandProtocol(final ReadBinding binding, final String database, final BsonDocument command, final Decoder<T> decoder) { return executeWrappedCommandProtocol(binding, database, command, decoder, new IdentityTransformer<T>()); }
@Override public Void execute(final WriteBinding binding) { try { return super.execute(binding); } catch (MongoException e) { addErrorLabels(e); throw e; } }
@Override public BatchCursor<T> execute(final ReadBinding binding) { return new ChangeStreamBatchCursor<T>(ChangeStreamOperation.this, wrapped.execute(binding), binding); }
@Override public List<T> apply(final BatchCursor<RawBsonDocument> queryBatchCursor) { return convertResults(queryBatchCursor.next()); } });
@Override public boolean hasNext() { return resumeableOperation(new Function<BatchCursor<RawBsonDocument>, Boolean>() { @Override public Boolean apply(final BatchCursor<RawBsonDocument> queryBatchCursor) { return queryBatchCursor.hasNext(); } }); }
static <T> T rethrowIfNotNamespaceError(final MongoCommandException e, final T defaultValue) { if (!isNamespaceError(e)) { throw e; } return defaultValue; }
/** * Sets the number of documents to return per batch. * * @param batchSize the batch size * @return this * @mongodb.driver.manual reference/method/cursor.batchSize/#cursor.batchSize Batch Size */ public AggregateOperation<T> batchSize(final Integer batchSize) { wrapped.batchSize(batchSize); return this; }
/** * Sets the maximum execution time on the server for this operation. * * @param maxTime the max time * @param timeUnit the time unit, which may not be null * @return this * @mongodb.driver.manual reference/method/cursor.maxTimeMS/#cursor.maxTimeMS Max Time */ public AggregateOperation<T> maxTime(final long maxTime, final TimeUnit timeUnit) { wrapped.maxTime(maxTime, timeUnit); return this; }
/** * 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) { return new AggregateExplainOperation(getNamespace(), getPipeline()) .allowDiskUse(getAllowDiskUse()) .maxTime(getMaxAwaitTime(TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS) .hint(wrapped.getHint()); }
@Override public void executeAsync(final AsyncWriteBinding binding, final SingleResultCallback<T> callback) { executeRetryableCommand(binding, getDatabaseName(), null, getFieldNameValidator(), CommandResultDocumentCodec.create(getDecoder(), "value"), getCommandCreator(binding.getSessionContext()), FindAndModifyHelper.<T>transformer(), callback); }
static <T> T executeWrappedCommandProtocol(final WriteBinding binding, final String database, final BsonDocument command, final Decoder<T> decoder) { return executeWrappedCommandProtocol(binding, database, command, decoder, new IdentityTransformer<T>()); }
static BsonDocument executeWrappedCommandProtocol(final ReadBinding binding, final String database, final BsonDocument command, final Connection connection) { return executeWrappedCommandProtocol(binding, database, command, connection, new IdentityTransformer<BsonDocument>()); }