@Test public void testDistinct() { final AggregationPipelineQueryNode base = new AggregationPipelineQueryNode( collection, new LinkedList<>(), Sets.newHashSet("x", "y"), Sets.newHashSet("x", "y", "opt"), HashBiMap.create()); AggregationPipelineQueryNode node = base.clone(); boolean success = node.distinct(); Assert.assertTrue(success); Assert.assertEquals(Sets.newHashSet("x", "y", "opt"), node.getBindingNames()); Assert.assertEquals(Sets.newHashSet("x", "y"), node.getAssuredBindingNames()); Assert.assertEquals(1, node.getPipeline().size()); }
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; }
AggregationPipelineQueryNode extends ExternalSet { 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; } }
AggregationPipelineQueryNode extends ExternalSet { 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; } AggregationPipelineQueryNode(final MongoCollection<Document> collection, final StatementPattern baseSP);   AggregationPipelineQueryNode(final MongoCollection<Document> collection,
            final List<Bson> pipeline, final Set<String> assuredBindingNames,
            final Set<String> bindingNames, final BiMap<String, String> varToOriginalName); }
AggregationPipelineQueryNode extends ExternalSet { 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; } AggregationPipelineQueryNode(final MongoCollection<Document> collection, final StatementPattern baseSP);   AggregationPipelineQueryNode(final MongoCollection<Document> collection,
            final List<Bson> pipeline, final Set<String> assuredBindingNames,
            final Set<String> bindingNames, final BiMap<String, String> varToOriginalName); @Override boolean equals(final Object o); @Override int hashCode(); @Override CloseableIteration<BindingSet, QueryEvaluationException> evaluate(final BindingSet bindings); @Override Set<String> getAssuredBindingNames(); @Override Set<String> getBindingNames(); @Override AggregationPipelineQueryNode clone(); @Override String getSignature(); boolean joinWith(final StatementPattern sp); boolean project(final Iterable<ProjectionElemList> projections); boolean extend(final Iterable<ExtensionElem> extensionElements); boolean filter(final ValueExpr condition); boolean distinct(); void requireSourceDerivationDepth(final int requiredLevel); void requireSourceTimestamp(final long t); List<Bson> getTriplePipeline(final long timestamp, final boolean requireNew); }
AggregationPipelineQueryNode extends ExternalSet { 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; } AggregationPipelineQueryNode(final MongoCollection<Document> collection, final StatementPattern baseSP);   AggregationPipelineQueryNode(final MongoCollection<Document> collection,
            final List<Bson> pipeline, final Set<String> assuredBindingNames,
            final Set<String> bindingNames, final BiMap<String, String> varToOriginalName); @Override boolean equals(final Object o); @Override int hashCode(); @Override CloseableIteration<BindingSet, QueryEvaluationException> evaluate(final BindingSet bindings); @Override Set<String> getAssuredBindingNames(); @Override Set<String> getBindingNames(); @Override AggregationPipelineQueryNode clone(); @Override String getSignature(); boolean joinWith(final StatementPattern sp); boolean project(final Iterable<ProjectionElemList> projections); boolean extend(final Iterable<ExtensionElem> extensionElements); boolean filter(final ValueExpr condition); boolean distinct(); void requireSourceDerivationDepth(final int requiredLevel); void requireSourceTimestamp(final long t); List<Bson> getTriplePipeline(final long timestamp, final boolean requireNew);  }