类com.mongodb.client.model.BsonField源码实例Demo

下面列出了怎么用com.mongodb.client.model.BsonField的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: immutables   文件: AggregationQuery.java
private BsonField accumulator(String field, Expression expression) {
  Preconditions.checkArgument(expression instanceof Call, "not a call %s", expression);
  final Call call = (Call) expression;
  final Operator op = call.operator();
  Preconditions.checkArgument(AggregationOperators.isAggregation(op), "not an aggregation operator: %s", op);
  final String name = "$" + naming.get(extractPath(expression));
  if (op == AggregationOperators.AVG) {
    return Accumulators.avg(field, name);
  } else if (op == AggregationOperators.COUNT) {
    return Accumulators.sum(field, 1);
  } else if (op == AggregationOperators.MAX) {
    return Accumulators.max(field, name);
  } else if (op == AggregationOperators.MIN) {
    return Accumulators.min(field, name);
  } else if (op == AggregationOperators.SUM) {
    return Accumulators.sum(field, name);
  } else {
    throw new IllegalArgumentException(String.format("Unknown aggregation operator %s from %s", op, expression));
  }
}
 
源代码2 项目: ditto   文件: MongoReadJournal.java
/**
 * For $group stage of an aggregation pipeline over a snapshot collection: take the newest values of fields
 * of serialized snapshots. Always include the first snapshot lifecycle.
 *
 * @param snapshotFields fields of a serialized snapshot to project.
 * @return list of group stage field accumulators.
 */
private List<BsonField> asFirstSnapshotBsonFields(final String... snapshotFields) {
    return Stream.concat(Stream.of(LIFECYCLE), Arrays.stream(snapshotFields))
            .map(fieldName -> {
                final String serializedFieldName = String.format("$%s.%s", SERIALIZED_SNAPSHOT, fieldName);
                return Accumulators.first(fieldName, serializedFieldName);
            })
            .collect(Collectors.toList());
}
 
源代码3 项目: rya   文件: AggregationPipelineQueryNode.java
/**
 * Add a $group step to filter out redundant solutions.
 * @return True if the distinct operation was successfully appended.
 */
public boolean distinct() {
    final List<String> key = new LinkedList<>();
    for (final String varName : bindingNames) {
        key.add(hashFieldExpr(varName));
    }
    final List<BsonField> reduceOps = new LinkedList<>();
    for (final String field : FIELDS) {
        reduceOps.add(new BsonField(field, new Document("$first", "$" + field)));
    }
    pipeline.add(Aggregates.group(new Document("$concat", key), reduceOps));
    return true;
}
 
源代码4 项目: MongoDB-Plugin   文件: MongoAccumulator.java
public List<BsonField> getAccumulators() {
    return accumulators;
}
 
源代码5 项目: MongoDB-Plugin   文件: MongoAccumulator.java
public MongoAccumulator setAccumulators(List<BsonField> accumulators) {
    this.accumulators = accumulators;
    return this;
}
 
 类所在包
 同包方法