private BsonDocument getCommand(final ConnectionDescription description) { BsonDocument commandDocument = new BsonDocument("create", new BsonString(viewName)) .append("viewOn", new BsonString(viewOn)) .append("pipeline", new BsonArray(pipeline)); if (collation != null) { commandDocument.put("collation", collation.asDocument()); } appendWriteConcernToCommand(writeConcern, commandDocument, description); return commandDocument; }
private BsonDocument getCommand(final SessionContext sessionContext) { BsonDocument commandDocument = new BsonDocument("distinct", new BsonString(namespace.getCollectionName())); appendReadConcernToCommand(sessionContext, commandDocument); commandDocument.put("key", new BsonString(fieldName)); putIfNotNullOrEmpty(commandDocument, "query", filter); putIfNotZero(commandDocument, "maxTimeMS", maxTimeMS); if (collation != null) { commandDocument.put("collation", collation.asDocument()); } return commandDocument; } }
private BsonDocument getCommand(final SessionContext sessionContext) { BsonDocument document = new BsonDocument("count", new BsonString(namespace.getCollectionName())); appendReadConcernToCommand(sessionContext, document); putIfNotNull(document, "query", filter); putIfNotZero(document, "limit", limit); putIfNotZero(document, "skip", skip); putIfNotNull(document, "hint", hint); putIfNotZero(document, "maxTimeMS", maxTimeMS); if (collation != null) { document.put("collation", collation.asDocument()); } return document; }
private BsonDocument getCommand() { BsonDocument commandDocument = new BsonDocument("aggregate", new BsonString(namespace.getCollectionName())); commandDocument.put("pipeline", new BsonArray(pipeline)); commandDocument.put("explain", BsonBoolean.TRUE); if (maxTimeMS > 0) { commandDocument.put("maxTimeMS", new BsonInt64(maxTimeMS)); } if (allowDiskUse != null) { commandDocument.put("allowDiskUse", BsonBoolean.valueOf(allowDiskUse)); } if (collation != null) { commandDocument.put("collation", collation.asDocument()); } if (hint != null) { commandDocument.put("hint", hint); } return commandDocument; }
commandDocument.put("collation", collation.asDocument());
@Override public BsonDocument create(final ServerDescription serverDescription, final ConnectionDescription connectionDescription) { validateCollation(connectionDescription, collation); BsonDocument commandDocument = new BsonDocument("findAndModify", new BsonString(getNamespace().getCollectionName())); putIfNotNull(commandDocument, "query", getFilter()); putIfNotNull(commandDocument, "fields", getProjection()); putIfNotNull(commandDocument, "sort", getSort()); putIfNotZero(commandDocument, "maxTimeMS", getMaxTime(MILLISECONDS)); commandDocument.put("remove", BsonBoolean.TRUE); addWriteConcernToCommand(connectionDescription, commandDocument, sessionContext); if (collation != null) { commandDocument.put("collation", collation.asDocument()); } addTxnNumberToCommand(serverDescription, connectionDescription, commandDocument, sessionContext); return commandDocument; } };
private BsonDocument getCommand(final ConnectionDescription description, final SessionContext sessionContext) { BsonDocument commandDocument = new BsonDocument("aggregate", aggregateTarget.create()); appendReadConcernToCommand(sessionContext, commandDocument); commandDocument.put("pipeline", pipelineCreator.create(description, sessionContext)); if (maxTimeMS > 0) { commandDocument.put("maxTimeMS", new BsonInt64(maxTimeMS)); } if (!isInline(description)) { BsonDocument cursor = new BsonDocument(); if (batchSize != null) { cursor.put("batchSize", new BsonInt32(batchSize)); } commandDocument.put(CURSOR, cursor); } if (allowDiskUse != null) { commandDocument.put("allowDiskUse", BsonBoolean.valueOf(allowDiskUse)); } if (collation != null) { commandDocument.put("collation", collation.asDocument()); } if (comment != null) { commandDocument.put("comment", new BsonString(comment)); } if (hint != null) { commandDocument.put("hint", hint); } return commandDocument; }
private BsonDocument getCommand() { BsonDocument commandDocument = new BsonDocument("ns", new BsonString(namespace.getCollectionName())); if (getKey() != null) { commandDocument.put("key", getKey()); } else if (getKeyFunction() != null) { commandDocument.put("$keyf", getKeyFunction()); } commandDocument.put("initial", getInitial()); commandDocument.put("$reduce", getReduceFunction()); if (getFinalizeFunction() != null) { commandDocument.put("finalize", getFinalizeFunction()); } if (getFilter() != null) { commandDocument.put("cond", getFilter()); } if (getCollation() != null) { commandDocument.put("collation", collation.asDocument()); } return new BsonDocument("group", commandDocument); }
private BsonDocument getCommand(final ConnectionDescription description) { BsonValue aggregationTarget = (aggregationLevel == AggregationLevel.DATABASE) ? new BsonInt32(1) : new BsonString(namespace.getCollectionName()); BsonDocument commandDocument = new BsonDocument("aggregate", aggregationTarget); commandDocument.put("pipeline", new BsonArray(pipeline)); if (maxTimeMS > 0) { commandDocument.put("maxTimeMS", new BsonInt64(maxTimeMS)); } if (allowDiskUse != null) { commandDocument.put("allowDiskUse", BsonBoolean.valueOf(allowDiskUse)); } if (bypassDocumentValidation != null && serverIsAtLeastVersionThreeDotTwo(description)) { commandDocument.put("bypassDocumentValidation", BsonBoolean.valueOf(bypassDocumentValidation)); } if (serverIsAtLeastVersionThreeDotSix(description)) { commandDocument.put("cursor", new BsonDocument()); } appendWriteConcernToCommand(writeConcern, commandDocument, description); if (collation != null) { commandDocument.put("collation", collation.asDocument()); } if (comment != null) { commandDocument.put("comment", new BsonString(comment)); } if (hint != null) { commandDocument.put("hint", hint); } return commandDocument; }
document.put("collation", collation.asDocument());
@Override public BsonDocument create(final ServerDescription serverDescription, final ConnectionDescription connectionDescription) { validateCollation(connectionDescription, collation); BsonDocument commandDocument = new BsonDocument("findAndModify", new BsonString(getNamespace().getCollectionName())); putIfNotNull(commandDocument, "query", getFilter()); putIfNotNull(commandDocument, "fields", getProjection()); putIfNotNull(commandDocument, "sort", getSort()); commandDocument.put("new", new BsonBoolean(!isReturnOriginal())); putIfTrue(commandDocument, "upsert", isUpsert()); putIfNotZero(commandDocument, "maxTimeMS", getMaxTime(MILLISECONDS)); commandDocument.put("update", getReplacement()); if (bypassDocumentValidation != null && serverIsAtLeastVersionThreeDotTwo(connectionDescription)) { commandDocument.put("bypassDocumentValidation", BsonBoolean.valueOf(bypassDocumentValidation)); } addWriteConcernToCommand(connectionDescription, commandDocument, sessionContext); if (collation != null) { commandDocument.put("collation", collation.asDocument()); } addTxnNumberToCommand(serverDescription, connectionDescription, commandDocument, sessionContext); return commandDocument; } };
@Override public BsonDocument create(final ServerDescription serverDescription, final ConnectionDescription connectionDescription) { validateCollation(connectionDescription, collation); BsonDocument commandDocument = new BsonDocument("findAndModify", new BsonString(getNamespace().getCollectionName())); putIfNotNull(commandDocument, "query", getFilter()); putIfNotNull(commandDocument, "fields", getProjection()); putIfNotNull(commandDocument, "sort", getSort()); commandDocument.put("new", new BsonBoolean(!isReturnOriginal())); putIfTrue(commandDocument, "upsert", isUpsert()); putIfNotZero(commandDocument, "maxTimeMS", getMaxTime(MILLISECONDS)); commandDocument.put("update", getUpdate()); if (bypassDocumentValidation != null && serverIsAtLeastVersionThreeDotTwo(connectionDescription)) { commandDocument.put("bypassDocumentValidation", BsonBoolean.valueOf(bypassDocumentValidation)); } addWriteConcernToCommand(connectionDescription, commandDocument, sessionContext); if (collation != null) { commandDocument.put("collation", collation.asDocument()); } if (arrayFilters != null) { commandDocument.put("arrayFilters", new BsonArray(arrayFilters)); } addTxnNumberToCommand(serverDescription, connectionDescription, commandDocument, sessionContext); return commandDocument; } };
BsonDocument collation = update.getCollation().asDocument(); getCodec(collation).encode(writer, collation, EncoderContext.builder().build()); if (deleteRequest.getCollation() != null) { writer.writeName("collation"); BsonDocument collation = deleteRequest.getCollation().asDocument(); getCodec(collation).encode(writer, collation, EncoderContext.builder().build());
private BsonDocument getCommand(final SessionContext sessionContext) { BsonDocument commandDocument = new BsonDocument("mapreduce", new BsonString(namespace.getCollectionName())) .append("map", getMapFunction()) .append("reduce", getReduceFunction()) .append("out", new BsonDocument("inline", new BsonInt32(1))) .append("query", asValueOrNull(getFilter())) .append("sort", asValueOrNull(getSort())) .append("finalize", asValueOrNull(getFinalizeFunction())) .append("scope", asValueOrNull(getScope())) .append("verbose", BsonBoolean.valueOf(isVerbose())); appendReadConcernToCommand(sessionContext, commandDocument); putIfNotZero(commandDocument, "limit", getLimit()); putIfNotZero(commandDocument, "maxTimeMS", getMaxTime(MILLISECONDS)); putIfTrue(commandDocument, "jsMode", isJsMode()); if (collation != null) { commandDocument.put("collation", collation.asDocument()); } return commandDocument; }
private BsonDocument getCommand(final ConnectionDescription description) { BsonDocument outputDocument = new BsonDocument(getAction(), new BsonString(getCollectionName())); outputDocument.append("sharded", BsonBoolean.valueOf(isSharded())); outputDocument.append("nonAtomic", BsonBoolean.valueOf(isNonAtomic())); if (getDatabaseName() != null) { outputDocument.put("db", new BsonString(getDatabaseName())); } BsonDocument commandDocument = new BsonDocument("mapreduce", new BsonString(namespace.getCollectionName())) .append("map", getMapFunction()) .append("reduce", getReduceFunction()) .append("out", outputDocument) .append("query", asValueOrNull(getFilter())) .append("sort", asValueOrNull(getSort())) .append("finalize", asValueOrNull(getFinalizeFunction())) .append("scope", asValueOrNull(getScope())) .append("verbose", BsonBoolean.valueOf(isVerbose())); putIfNotZero(commandDocument, "limit", getLimit()); putIfNotZero(commandDocument, "maxTimeMS", getMaxTime(MILLISECONDS)); putIfTrue(commandDocument, "jsMode", isJsMode()); if (bypassDocumentValidation != null && description != null && serverIsAtLeastVersionThreeDotTwo(description)) { commandDocument.put("bypassDocumentValidation", BsonBoolean.valueOf(bypassDocumentValidation)); } if (description != null) { appendWriteConcernToCommand(writeConcern, commandDocument, description); } if (collation != null) { commandDocument.put("collation", collation.asDocument()); } return commandDocument; }
index.append("collation", request.getCollation().asDocument());
private BsonDocument getCommand(final ConnectionDescription description) { BsonDocument commandDocument = new BsonDocument("create", new BsonString(viewName)) .append("viewOn", new BsonString(viewOn)) .append("pipeline", new BsonArray(pipeline)); if (collation != null) { commandDocument.put("collation", collation.asDocument()); } appendWriteConcernToCommand(writeConcern, commandDocument, description); return commandDocument; }
private BsonDocument getCommand(final SessionContext sessionContext) { BsonDocument commandDocument = new BsonDocument("distinct", new BsonString(namespace.getCollectionName())); appendReadConcernToCommand(sessionContext, commandDocument); commandDocument.put("key", new BsonString(fieldName)); putIfNotNullOrEmpty(commandDocument, "query", filter); putIfNotZero(commandDocument, "maxTimeMS", maxTimeMS); if (collation != null) { commandDocument.put("collation", collation.asDocument()); } return commandDocument; } }
private BsonDocument getCommand(final SessionContext sessionContext) { BsonDocument document = new BsonDocument("count", new BsonString(namespace.getCollectionName())); appendReadConcernToCommand(sessionContext, document); putIfNotNull(document, "query", filter); putIfNotZero(document, "limit", limit); putIfNotZero(document, "skip", skip); putIfNotNull(document, "hint", hint); putIfNotZero(document, "maxTimeMS", maxTimeMS); if (collation != null) { document.put("collation", collation.asDocument()); } return document; }
@Override public BsonDocument create(final ServerDescription serverDescription, final ConnectionDescription connectionDescription) { validateCollation(connectionDescription, collation); BsonDocument commandDocument = new BsonDocument("findAndModify", new BsonString(getNamespace().getCollectionName())); putIfNotNull(commandDocument, "query", getFilter()); putIfNotNull(commandDocument, "fields", getProjection()); putIfNotNull(commandDocument, "sort", getSort()); putIfNotZero(commandDocument, "maxTimeMS", getMaxTime(MILLISECONDS)); commandDocument.put("remove", BsonBoolean.TRUE); addWriteConcernToCommand(connectionDescription, commandDocument, sessionContext); if (collation != null) { commandDocument.put("collation", collation.asDocument()); } addTxnNumberToCommand(serverDescription, connectionDescription, commandDocument, sessionContext); return commandDocument; } };