public void visitDescribe(Resource describe) throws RDF4JException { Value resultNodes = TripleSources.singleValue(describe, SP.RESULT_NODES_PROPERTY, store); if (!(resultNodes instanceof Resource)) { throw new MalformedSpinException( String.format("Value of %s is not a resource", SP.RESULT_NODES_PROPERTY)); } projElems = new LinkedHashMap<String, ProjectionElem>(); Projection projection = visitResultNodes((Resource)resultNodes); TupleExpr whereExpr = visitWhere(describe); projection.setArg(whereExpr); addSourceExpressions(projection, projElems.values()); }
private TupleExpr buildTuple(final List<QueryModelNode> nodes, final List<Filter> filters, final Projection projection) { final Projection proj = projection.clone(); Join join = null; join = new Join((TupleExpr) nodes.get(0).clone(), (TupleExpr) nodes.get(1).clone()); for (int i = 2; i < nodes.size(); i++) { join = new Join(join, (TupleExpr) nodes.get(i).clone()); } if (filters.size() == 0) { proj.setArg(join); return proj; } else { TupleExpr queryPlan = join; for (final Filter f : filters) { final Filter filt = f.clone(); filt.setArg(queryPlan); queryPlan = filt; } proj.setArg(queryPlan); return proj; } }
private UnaryTupleOperator projection() { if (!mProjectionPatterns.isEmpty()) { return multiProjection(); } else { Extension aExt = null; ProjectionElemList aList = new ProjectionElemList(); for (String aVar : mProjectionVars) { aList.addElement(new ProjectionElem(aVar)); } Projection aProjection = new Projection(); aProjection.setProjectionElemList(aList); if (aExt != null) { aProjection.setArg(aExt); } return aProjection; } }
private UnaryTupleOperator projection() { if (!mProjectionPatterns.isEmpty()) { return multiProjection(); } else { Extension aExt = null; ProjectionElemList aList = new ProjectionElemList(); for (String aVar : mProjectionVars) { aList.addElement(new ProjectionElem(aVar)); } Projection aProjection = new Projection(); aProjection.setProjectionElemList(aList); if (aExt != null) { aProjection.setArg(aExt); } return aProjection; } }
private UnaryTupleOperator projection() { if (!mProjectionPatterns.isEmpty()) { return multiProjection(); } else { Extension aExt = null; ProjectionElemList aList = new ProjectionElemList(); for (String aVar : mProjectionVars) { aList.addElement(new ProjectionElem(aVar)); } Projection aProjection = new Projection(); aProjection.setProjectionElemList(aList); if (aExt != null) { aProjection.setArg(aExt); } return aProjection; } }
/** * * This method moves the Filters of a specified {@link TupleExpr} to the top * of the TupleExpr. * * @param query * - query whose filters will be relocated * @return - TupleExpr with filters relocated to top */ public static TupleExpr moveFiltersToTop(TupleExpr query) { ProjectionAndFilterGatherer fg = new ProjectionAndFilterGatherer(); query.visit(fg); List<ValueExpr> filterCond = new ArrayList<>(fg.filterCond); Projection projection = fg.projection; if (filterCond.size() == 0) { return query; } Filter first = new Filter(); first.setCondition(filterCond.remove(0)); Filter current = first; for (ValueExpr cond : filterCond) { Filter filter = new Filter(null, cond); current.setArg(filter); current = filter; } TupleExpr te = projection.getArg(); projection.setArg(first); current.setArg(te); return query; }
Projection projection = visitResultVariables((Resource)resultVars, oldProjElems); TupleExpr whereExpr = visitWhere(select); projection.setArg(whereExpr); projection.setArg(group); if (having instanceof Resource) { TupleExpr havingExpr = visitHaving((Resource)having); projection.setArg(havingExpr); Order order = visitOrderBy((Resource)orderby); order.setArg(projection.getArg()); projection.setArg(order);