private UnaryTupleOperator visitTemplates(Resource templates) throws RDF4JException { List<ProjectionElemList> projElemLists = new ArrayList<ProjectionElemList>(); Iteration<? extends Resource, QueryEvaluationException> iter = TripleSources.listResources(templates, store); while (iter.hasNext()) { Resource r = iter.next(); ProjectionElemList projElems = visitTemplate(r); projElemLists.add(projElems); } UnaryTupleOperator expr; if (projElemLists.size() > 1) { MultiProjection proj = new MultiProjection(); proj.setProjections(projElemLists); expr = proj; } else { Projection proj = new Projection(); proj.setProjectionElemList(projElemLists.get(0)); expr = proj; } Reduced reduced = new Reduced(); reduced.setArg(expr); tupleRoot = reduced; return expr; }
result = new MultiProjection(result, projList);
result = new MultiProjection(result, projList);
result = new MultiProjection(result, projList);
result = new MultiProjection(result, projections);
result = new MultiProjection(result, projections);
result = new MultiProjection(result, projections);
result = new MultiProjection(result, projections);
result = new MultiProjection(result, projections);
result = new MultiProjection(result, projections);
@Test public void testMultiProjection() throws Exception { StatementPattern isUndergrad = new StatementPattern(new Var("x"), constant(RDF.TYPE), constant(UNDERGRAD)); StatementPattern isCourse = new StatementPattern(new Var("course"), constant(RDF.TYPE), constant(COURSE)); StatementPattern hasEdge = new StatementPattern(new Var("x"), new Var("p"), new Var("course")); ProjectionElemList courseHasRelation = new ProjectionElemList( new ProjectionElem("p", "relation"), new ProjectionElem("course")); ProjectionElemList studentHasRelation = new ProjectionElemList( new ProjectionElem("p", "relation"), new ProjectionElem("x", "student")); QueryRoot queryTree = new QueryRoot(new MultiProjection( new Join(new Join(isCourse, hasEdge), isUndergrad), Arrays.asList(courseHasRelation, studentHasRelation))); SparqlToPipelineTransformVisitor visitor = new SparqlToPipelineTransformVisitor(collection); queryTree.visit(visitor); Assert.assertTrue(queryTree.getArg() instanceof AggregationPipelineQueryNode); AggregationPipelineQueryNode pipelineNode = (AggregationPipelineQueryNode) queryTree.getArg(); Assert.assertEquals(Sets.newHashSet("relation"), pipelineNode.getAssuredBindingNames()); Assert.assertEquals(Sets.newHashSet("relation", "course", "student"), pipelineNode.getBindingNames()); }
private UnaryTupleOperator multiProjection() { MultiProjection aProjection = new MultiProjection();
private UnaryTupleOperator multiProjection() { MultiProjection aProjection = new MultiProjection();
private UnaryTupleOperator multiProjection() { MultiProjection aProjection = new MultiProjection();