/** * 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()); }
/** * 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()); }
@Override public String toString() { return "AggregateOperation{" + "namespace=" + getNamespace() + ", pipeline=" + getPipeline() + ", decoder=" + getDecoder() + ", allowDiskUse=" + getAllowDiskUse() + ", batchSize=" + getBatchSize() + ", collation=" + getCollation() + ", comment=" + getComment() + ", hint=" + getHint() + ", maxAwaitTimeMS=" + getMaxAwaitTime(TimeUnit.MILLISECONDS) + ", maxTimeMS=" + getMaxTime(TimeUnit.MILLISECONDS) + ", useCursor=" + wrapped.getUseCursor() + "}"; } }
/** {@inheritDoc} */ @Override public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { Object operation = args[0]; final String operationName; if (operation instanceof AggregateOperation<?>) { operationName = Joiner.on(",").join(((AggregateOperation<?>) operation).getPipeline()); } else if (operation instanceof ListIndexesOperation<?>) { operationName = "indexes"; } else if (operation instanceof FindOperation<?>) { FindOperation<?> findOperation = (FindOperation<?>) operation; operationName = "find(" + findOperation.getFilter().toJson() + ")"; } else if (operation instanceof CountOperation) { operationName = "count(" + ((CountOperation) operation).getFilter().toJson() + ")"; } else if (operation instanceof UpdateOperation) { UpdateOperation updateOperation = (UpdateOperation) operation; List<UpdateRequest> updateRequests = updateOperation.getUpdateRequests(); operationName = updateRequests.stream().map(ur -> "{" + ur.getType() + ur.getFilter() + "}").collect(Collectors.joining(",")); } else { operationName = operation.toString(); } return doInvoke(operationExecutor, method, args, operationName); } }
/** * 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()); }
/** * 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()); }
@Override public String toString() { return "AggregateOperation{" + "namespace=" + getNamespace() + ", pipeline=" + getPipeline() + ", decoder=" + getDecoder() + ", allowDiskUse=" + getAllowDiskUse() + ", batchSize=" + getBatchSize() + ", collation=" + getCollation() + ", comment=" + getComment() + ", hint=" + getHint() + ", maxAwaitTimeMS=" + getMaxAwaitTime(TimeUnit.MILLISECONDS) + ", maxTimeMS=" + getMaxTime(TimeUnit.MILLISECONDS) + ", useCursor=" + wrapped.getUseCursor() + "}"; } }