本文整理汇总了Java中org.openrdf.query.algebra.Compare类的典型用法代码示例。如果您正苦于以下问题:Java Compare类的具体用法?Java Compare怎么用?Java Compare使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Compare类属于org.openrdf.query.algebra包,在下文中一共展示了Compare类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testFilter
import org.openrdf.query.algebra.Compare; //导入依赖的package包/类
@Test
public void testFilter() {
final AggregationPipelineQueryNode base = new AggregationPipelineQueryNode(
collection,
new LinkedList<>(),
Sets.newHashSet("x", "y"),
Sets.newHashSet("x", "y", "opt"),
HashBiMap.create());
// Extend with a supported filter
AggregationPipelineQueryNode node = base.clone();
boolean success = node.filter(new Compare(new Var("x"), new Var("y"), Compare.CompareOp.EQ));
Assert.assertTrue(success);
Assert.assertEquals(Sets.newHashSet("x", "y", "opt"), node.getBindingNames());
Assert.assertEquals(Sets.newHashSet("x", "y"), node.getAssuredBindingNames());
Assert.assertEquals(3, node.getPipeline().size());
// Extend with an unsupported filter
node = base.clone();
success = node.filter(new IsLiteral(new Var("opt")));
Assert.assertFalse(success);
Assert.assertEquals(Sets.newHashSet("x", "y", "opt"), node.getBindingNames());
Assert.assertEquals(Sets.newHashSet("x", "y"), node.getAssuredBindingNames());
Assert.assertEquals(0, node.getPipeline().size());
}
开发者ID:apache,项目名称:incubator-rya,代码行数:24,代码来源:AggregationPipelineQueryNodeTest.java
示例2: extractNegatedProperties
import org.openrdf.query.algebra.Compare; //导入依赖的package包/类
private void extractNegatedProperties(final ValueExpr condition,
final Set<URI> negatedProperties) {
if (condition instanceof And) {
final And and = (And) condition;
extractNegatedProperties(and.getLeftArg(), negatedProperties);
extractNegatedProperties(and.getRightArg(), negatedProperties);
} else if (condition instanceof Compare) {
final Compare compare = (Compare) condition;
Preconditions.checkArgument(compare.getOperator() == CompareOp.NE);
if (compare.getLeftArg() instanceof ValueConstant) {
Preconditions.checkArgument(compare.getRightArg() instanceof Var);
negatedProperties.add((URI) ((ValueConstant) compare.getLeftArg()).getValue());
} else if (compare.getRightArg() instanceof ValueConstant) {
Preconditions.checkArgument(compare.getLeftArg() instanceof Var);
negatedProperties
.add((URI) ((ValueConstant) compare.getRightArg()).getValue());
} else {
fail("Unsupported path expression. Check condition node: ", condition);
}
}
}
开发者ID:dkmfbk,项目名称:knowledgestore,代码行数:23,代码来源:SPARQLRenderer.java
示例3: meet
import org.openrdf.query.algebra.Compare; //导入依赖的package包/类
@Override
public void meet(Compare arg0) throws SparqlParserException
{
arg0.getLeftArg().visit(this);
ITerm termLeft = getTerm();
arg0.getRightArg().visit(this);
ITerm termRight = getTerm();
CompareOp op = arg0.getOperator();
switch (op) {
case EQ: mTerm = sExpressionFactory.formEq(termLeft, termRight); break;
case NE: mTerm = sExpressionFactory.formNeq(termLeft, termRight); break;
case GT: mTerm = sExpressionFactory.formGt(termLeft, termRight); break;
case GE: mTerm = sExpressionFactory.formGte(termLeft, termRight); break;
case LT: mTerm = sExpressionFactory.formLt(termLeft, termRight); break;
case LE: mTerm = sExpressionFactory.formLte(termLeft, termRight); break;
}
}
开发者ID:obidea,项目名称:semantika,代码行数:19,代码来源:SparqlQueryHandler.java
示例4: meet
import org.openrdf.query.algebra.Compare; //导入依赖的package包/类
@Override
public void meet(final Compare n) {
final QueryModelNode p = n.getParentNode();
final boolean par = p instanceof Not || p instanceof MathExpr;
emitIf(par, "(").emit(n.getLeftArg()).emit(" ").emit(n.getOperator().getSymbol())
.emit(" ").emit(n.getRightArg()).emitIf(par, ")");
}
开发者ID:dkmfbk,项目名称:knowledgestore,代码行数:8,代码来源:SPARQLRenderer.java
示例5: meet
import org.openrdf.query.algebra.Compare; //导入依赖的package包/类
@Override
public void meet(Compare node) throws RuntimeException {
setSeen(node);
super.meet(node);
}
开发者ID:lszeremeta,项目名称:neo4j-sparql-extension-yars,代码行数:6,代码来源:SeenVisitor.java
示例6: meet
import org.openrdf.query.algebra.Compare; //导入依赖的package包/类
@Override
public void meet(Compare node) throws RuntimeException {
check(node);
super.meet(node);
}
开发者ID:lszeremeta,项目名称:neo4j-sparql-extension-yars,代码行数:6,代码来源:ConsistencyVisitor.java
示例7: filter
import org.openrdf.query.algebra.Compare; //导入依赖的package包/类
/**
* Add a SPARQL filter to the pipeline, if possible. A filter eliminates
* results that don't satisfy a given condition. Not all conditional
* expressions are supported. If unsupported expressions are used in the
* filter, the pipeline will remain unchanged and this method will return
* false. Currently only supports binary {@link Compare} conditions among
* variables and/or literals.
* @param condition The filter condition
* @return True if the filter was successfully converted into a pipeline
* step, false otherwise.
*/
public boolean filter(ValueExpr condition) {
if (condition instanceof Compare) {
Compare compare = (Compare) condition;
Compare.CompareOp operator = compare.getOperator();
Object leftArg = valueFieldExpr(compare.getLeftArg());
Object rightArg = valueFieldExpr(compare.getRightArg());
if (leftArg == null || rightArg == null) {
// unsupported value expression, can't convert filter
return false;
}
final String opFunc;
switch (operator) {
case EQ:
opFunc = "$eq";
break;
case NE:
opFunc = "$ne";
break;
case LT:
opFunc = "$lt";
break;
case LE:
opFunc = "$le";
break;
case GT:
opFunc = "$gt";
break;
case GE:
opFunc = "$ge";
break;
default:
// unrecognized comparison operator, can't convert filter
return false;
}
Document compareDoc = new Document(opFunc, Arrays.asList(leftArg, rightArg));
pipeline.add(Aggregates.project(Projections.fields(
Projections.computed("FILTER", compareDoc),
Projections.include(VALUES, HASHES, TYPES, LEVEL, TIMESTAMP))));
pipeline.add(Aggregates.match(new Document("FILTER", true)));
pipeline.add(Aggregates.project(Projections.fields(
Projections.include(VALUES, HASHES, TYPES, LEVEL, TIMESTAMP))));
return true;
}
return false;
}
开发者ID:apache,项目名称:incubator-rya,代码行数:57,代码来源:AggregationPipelineQueryNode.java
示例8: meet
import org.openrdf.query.algebra.Compare; //导入依赖的package包/类
@Override
public void meet(Compare arg0) throws Exception {
ValueExpr left = arg0.getLeftArg();
if (!(left instanceof Var))
return;
Var var = (Var) left;
if (!var.equals(inXSDDateTimeVar))
return;
CompareOp op = arg0.getOperator();
ValueExpr right = arg0.getRightArg();
if (!(right instanceof ValueConstant)) {
if (log.isLoggable(Level.SEVERE))
log.severe("Expected value constant for time filter [right = "
+ right + "]");
return;
}
ValueConstant constant = (ValueConstant) right;
Value value = constant.getValue();
if (!(value instanceof Literal)) {
if (log.isLoggable(Level.SEVERE))
log.severe("Expected literal value [value = " + value + "]");
return;
}
Literal literal = (Literal)value;
if (!literal.getDatatype().equals(XMLSchema.DATETIME)) {
if (log.isLoggable(Level.SEVERE))
log.severe("Expected XSD date time literal datatype [literal = " + literal + "]");
return;
}
if (op.equals(CompareOp.GE)) {
timeFrom = dtf.parseDateTime(literal.getLabel());
} else if (op.equals(CompareOp.LT)) {
timeTo = dtf.parseDateTime(literal.getLabel());
} else {
if (log.isLoggable(Level.SEVERE))
log.severe("Expected either >= or < operator in time filter");
}
}
开发者ID:markusstocker,项目名称:emrooz,代码行数:52,代码来源:SparqlQueryModelVisitor.java
示例9: meet
import org.openrdf.query.algebra.Compare; //导入依赖的package包/类
@Override
public void meet(Compare node) throws RuntimeException {
node.getLeftArg().visit(this);
buffer.append(" ").append(node.getOperator().getSymbol()).append(" ");
node.getRightArg().visit(this);
}
开发者ID:goerlitz,项目名称:rdffederator,代码行数:7,代码来源:AnnotatingTreePrinter.java
注:本文中的org.openrdf.query.algebra.Compare类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论