Java源码示例:org.eclipse.rdf4j.query.algebra.Count
示例1
private Aggregate create(AggregateOperator operator)
throws ValueExprEvaluationException, QueryEvaluationException {
if (operator instanceof Count) {
return new CountAggregate((Count) operator);
} else if (operator instanceof Min) {
return new MinAggregate((Min) operator);
} else if (operator instanceof Max) {
return new MaxAggregate((Max) operator);
} else if (operator instanceof Sum) {
return new SumAggregate((Sum) operator);
} else if (operator instanceof Avg) {
return new AvgAggregate((Avg) operator);
} else if (operator instanceof Sample) {
return new SampleAggregate((Sample) operator);
} else if (operator instanceof GroupConcat) {
return new ConcatAggregate((GroupConcat) operator);
}
return null;
}
示例2
@Override
public void meet(Count node) throws RDFHandlerException {
handler.handleStatement(valueFactory.createStatement(subject, RDF.TYPE, SP.COUNT_CLASS));
if (node.isDistinct()) {
handler.handleStatement(
valueFactory.createStatement(subject, SP.DISTINCT_PROPERTY, BooleanLiteral.TRUE));
}
Resource oldSubject = subject;
super.meet(node);
handler.handleStatement(valueFactory.createStatement(oldSubject, SP.EXPRESSION_PROPERTY, subject));
subject = oldSubject;
}
示例3
public CountAggregate(Count operator) {
super(operator);
// for a wildcarded count with a DISTINCT clause we need to filter on
// distinct bindingsets rather than individual values.
if (operator.isDistinct() && getArg() == null) {
distinctBindingSets = createSet("distinct-bs-" + this.hashCode());
} else {
distinctBindingSets = null;
}
}
示例4
@Test
public void testCountNotZero() throws QueryEvaluationException {
Group group = new Group(NONEMPTY_ASSIGNMENT);
group.addGroupElement(new GroupElem("count", new Count(new Var("a"))));
GroupIterator gi = new GroupIterator(evaluator, group, EmptyBindingSet.getInstance());
assertThat(gi.next().getBinding("count").getValue()).isEqualTo(vf.createLiteral("9", XMLSchema.INTEGER));
}
示例5
@Override
public Object visit(ASTCount node, Object data) throws VisitorException {
ValueExpr ve = null;
if (node.jjtGetNumChildren() > 0) {
ve = castToValueExpr(node.jjtGetChild(0).jjtAccept(this, data));
}
return new Count(ve, node.isDistinct());
}
示例6
/**
* @inheritDoc
*/
@Override
public void meet(Count theOp)
throws Exception
{
unaryMeet("count", theOp);
}
示例7
@Override
public void meet(Count node) throws X {
meetUnaryValueOperator(node);
}
示例8
/**
* @inheritDoc
*/
@Override
public void meet(Count theOp) throws Exception {
unaryMeet("count", theOp);
}
示例9
/**
* @inheritDoc
*/
@Override
public void meet(Count theOp) throws Exception {
unaryMeet("count", theOp);
}
示例10
@Override
public void meet(Count node) throws VisitorException {
super.meet(node);
meetAggregate(node);
}
示例11
@Override
public void meet(Count node) throws VisitorException {
super.meet(node);
meetAggregate(node);
}