@Override public void meet(ArbitraryLengthPath node) { final Var pathVar = new Var("_anon_" + UUID.randomUUID().toString().replaceAll("-", "_")); pathVar.setAnonymous(true); // cardinality of ALP is determined based on the cost of a // single ?s ?p ?o ?c pattern where ?p is unbound, compensating for the fact that // the length of the path is unknown but expected to be _at least_ twice that of a normal // statement pattern. cardinality = 2.0 * getCardinality(new StatementPattern(node.getSubjectVar(), pathVar, node.getObjectVar(), node.getContextVar())); }
public TypeRequirementVisitor(String varName, Resource requiredType) { final Var typeVar = VarNameUtils.createUniqueConstVar(requiredType); typeVar.setConstant(true); this.varName = varName; if (BASE_TYPES.contains(requiredType)) { this.typeRequirement = null; } else { this.typeRequirement = new StatementPattern(new Var(varName), RDF_TYPE_VAR, typeVar); } } @Override
@Override public void meet(ArbitraryLengthPath node) { final Var pathVar = new Var("_anon_" + UUID.randomUUID().toString().replaceAll("-", "_")); pathVar.setAnonymous(true); // cardinality of ALP is determined based on the cost of a // single ?s ?p ?o ?c pattern where ?p is unbound, compensating for the fact that // the length of the path is unknown but expected to be _at least_ twice that of a normal // statement pattern. cardinality = 2.0 * getCardinality(new StatementPattern(node.getSubjectVar(), pathVar, node.getObjectVar(), node.getContextVar())); }
/** * @inheritDoc */ public QueryBuilder<T> addProjectionStatement(final String theSubj, final Value thePred, final Value theObj) { if (isConstruct()) { mProjectionPatterns.add(new StatementPattern(new Var(theSubj), GroupBuilder.valueToVar(thePred), GroupBuilder.valueToVar(theObj))); } return this; }
/** * @inheritDoc */ public QueryBuilder<T> addProjectionStatement(IRI theSubj, IRI thePred, String theObj) { if (isConstruct()) { mProjectionPatterns.add(new StatementPattern(GroupBuilder.valueToVar(theSubj), GroupBuilder.valueToVar(thePred), new Var(theObj))); } return this; }
/** * @inheritDoc */ public QueryBuilder<T> addProjectionStatement(String theSubj, IRI thePred, Value theObj) { if (isConstruct()) { mProjectionPatterns.add(new StatementPattern(new Var(theSubj), GroupBuilder.valueToVar(thePred), GroupBuilder.valueToVar(theObj))); } return this; }
/** * @inheritDoc */ public QueryBuilder<T> addProjectionStatement(final String theSubj, final Value thePred, final Value theObj) { if (isConstruct()) { mProjectionPatterns.add(new StatementPattern(new Var(theSubj), GroupBuilder.valueToVar(thePred), GroupBuilder.valueToVar(theObj))); } return this; }
/** * @inheritDoc */ public QueryBuilder<T> addProjectionStatement(String theSubj, IRI thePred, Value theObj) { if (isConstruct()) { mProjectionPatterns.add(new StatementPattern(new Var(theSubj), GroupBuilder.valueToVar(thePred), GroupBuilder.valueToVar(theObj))); } return this; }
/** * @inheritDoc */ public QueryBuilder<T> addProjectionStatement(IRI theSubj, IRI thePred, String theObj) { if (isConstruct()) { mProjectionPatterns.add(new StatementPattern(GroupBuilder.valueToVar(theSubj), GroupBuilder.valueToVar(thePred), new Var(theObj))); } return this; }
/** * @inheritDoc */ public QueryBuilder<T> addProjectionStatement(final String theSubj, final Value thePred, final Value theObj) { if (isConstruct()) { mProjectionPatterns.add(new StatementPattern(new Var(theSubj), GroupBuilder.valueToVar(thePred), GroupBuilder.valueToVar(theObj))); } return this; }
/** * @inheritDoc */ public QueryBuilder<T> addProjectionStatement(IRI theSubj, String thePred, String theObj) { if (isConstruct()) { mProjectionPatterns.add(new StatementPattern(GroupBuilder.valueToVar(theSubj), new Var(thePred), new Var(theObj))); } return this; }
/** * @inheritDoc */ public QueryBuilder<T> addProjectionStatement(String theSubj, IRI thePred, String theObj) { if (isConstruct()) { mProjectionPatterns.add(new StatementPattern(new Var(theSubj), GroupBuilder.valueToVar(thePred), new Var(theObj))); } return this; }
/** * @inheritDoc */ public QueryBuilder<T> addProjectionStatement(final String theSubj, final String thePred, final Value theObj) { if (isConstruct()) { mProjectionPatterns.add(new StatementPattern(new Var(theSubj), new Var(thePred), GroupBuilder.valueToVar(theObj))); } return this; }
/** * @inheritDoc */ public QueryBuilder<T> addProjectionStatement(String theSubj, IRI thePred, String theObj) { if (isConstruct()) { mProjectionPatterns.add(new StatementPattern(new Var(theSubj), GroupBuilder.valueToVar(thePred), new Var(theObj))); } return this; }
/** * @inheritDoc */ @Override public QueryBuilder<T> addProjectionStatement(IRI theSubj, String thePred, String theObj) { if (isConstruct()) { mProjectionPatterns.add(new StatementPattern(GroupBuilder.valueToVar(theSubj), new Var(thePred), new Var(theObj))); } return this; }
/** * @inheritDoc */ @Override public QueryBuilder<T> addProjectionStatement(String theSubj, IRI thePred, String theObj) { if (isConstruct()) { mProjectionPatterns.add(new StatementPattern(new Var(theSubj), GroupBuilder.valueToVar(thePred), new Var(theObj))); } return this; }
/** * @inheritDoc */ public QueryBuilder<T> addProjectionStatement(final String theSubj, final String thePred, final Value theObj) { if (isConstruct()) { mProjectionPatterns.add(new StatementPattern(new Var(theSubj), new Var(thePred), GroupBuilder.valueToVar(theObj))); } return this; }
/** * @inheritDoc */ public QueryBuilder<T> addProjectionStatement(IRI theSubj, String thePred, String theObj) { if (isConstruct()) { mProjectionPatterns.add(new StatementPattern(GroupBuilder.valueToVar(theSubj), new Var(thePred), new Var(theObj))); } return this; }
/** * @inheritDoc */ public QueryBuilder<T> addProjectionStatement(final String theSubj, final String thePred, final String theObj) { if (isConstruct()) { mProjectionPatterns.add( new StatementPattern(new Var(theSubj), new Var(thePred), new Var(theObj))); } return this; }
@Test public void testStatementPattern() throws Exception { QueryRoot query = new QueryRoot(new StatementPattern( new Var("x"), constant(RDF.TYPE), constant(UNDERGRAD))); SparqlToPipelineTransformVisitor visitor = new SparqlToPipelineTransformVisitor(collection); query.visit(visitor); Assert.assertTrue(query.getArg() instanceof AggregationPipelineQueryNode); AggregationPipelineQueryNode pipelineNode = (AggregationPipelineQueryNode) query.getArg(); Assert.assertEquals(Sets.newHashSet("x"), pipelineNode.getAssuredBindingNames()); }