Java Code Examples for org.eclipse.rdf4j.query.algebra.Extension#getElements()
The following examples show how to use
org.eclipse.rdf4j.query.algebra.Extension#getElements() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DistanceQuerySpec.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public QueryModelNode removeQueryPatterns() { final QueryModelNode placeholder = new SingletonSet(); filter.replaceWith(filter.getArg()); geoStatement.replaceWith(placeholder); QueryModelNode functionParent = distanceFunction.getParentNode(); if (functionParent instanceof ExtensionElem) { Extension extension = (Extension) functionParent.getParentNode(); List<ExtensionElem> elements = extension.getElements(); if (elements.size() > 1) { elements.remove(functionParent); } else { extension.replaceWith(extension.getArg()); } } return placeholder; }
Example 2
Source File: GeoRelationQuerySpec.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public QueryModelNode removeQueryPatterns() { final QueryModelNode placeholder = new SingletonSet(); filter.replaceWith(filter.getArg()); geoStatement.replaceWith(placeholder); if (functionParent instanceof ExtensionElem) { Extension extension = (Extension) functionParent.getParentNode(); List<ExtensionElem> elements = extension.getElements(); if (elements.size() > 1) { elements.remove(functionParent); } else { extension.replaceWith(extension.getArg()); } } return placeholder; }
Example 3
Source File: SpinRenderer.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void meet(Extension node) throws RDFHandlerException { if (inlineBindings != null && inlineBindings.extension == node) { // this is the first Extension node and has already been handled // by meetExtension() // to produce inline bindings in SELECT so we can skip it here node.getArg().visit(this); } else { // any further Extension nodes produce BIND() clauses node.getArg().visit(this); for (ExtensionElem elem : node.getElements()) { elem.visit(this); } } }
Example 4
Source File: SpinRenderer.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void meet(Extension node) { extension = node; List<ExtensionElem> elements = node.getElements(); // NB: preserve ExtensionElem order extensionExprs = new LinkedHashMap<>(elements.size()); for (ExtensionElem elem : elements) { extensionExprs.put(elem.getName(), elem.getExpr()); } }
Example 5
Source File: SparqlFluoQueryBuilder.java From rya with Apache License 2.0 | 4 votes |
@Override public void meet(final Reduced node) { //create id, initialize ConstructQueryMetadata builder, register ConstructQueryMetadata //builder with FluoQueryBuilder, and add metadata that we currently have final String constructId = nodeIds.getOrMakeId(node); ConstructQueryMetadata.Builder constructBuilder = fluoQueryBuilder.getConstructQueryBuilder().orNull(); if(constructBuilder == null) { constructBuilder = ConstructQueryMetadata.builder(); constructBuilder.setNodeId(constructId); fluoQueryBuilder.setConstructQueryMetadata(constructBuilder); } //get child node QueryModelNode child = node.getArg(); Preconditions.checkArgument(child instanceof Projection || child instanceof MultiProjection); final UnaryTupleOperator unary = (UnaryTupleOperator) child; //get ProjectionElemList to build ConstructGraph final List<ProjectionElemList> projections = new ArrayList<>(); if(unary instanceof Projection) { projections.add(((Projection) unary).getProjectionElemList()); } else { projections.addAll(((MultiProjection)unary).getProjections()); } //get ExtensionElems to build ConstructGraph final QueryModelNode grandChild = unary.getArg(); Preconditions.checkArgument(grandChild instanceof Extension); final Extension extension = (Extension) grandChild; final List<ExtensionElem> extensionElems = extension.getElements(); final ConstructGraph graph = getConstructGraph(projections, extensionElems); constructBuilder.setConstructGraph(graph); //set child to the next node we care about in Fluo //if Extension's arg is a Group node, then it is an Aggregation, so set child to Extension //otherwise set child to Extension's child (only care about Extensions if they are Aggregations) if(extension.getArg() instanceof Group) { child = extension; } else { child = extension.getArg(); } //Set the child node in the ConstructQueryMetadataBuilder final String childNodeId = nodeIds.getOrMakeId(child); constructBuilder.setChildNodeId(childNodeId); // Update the child node's metadata. final Set<String> childVars = getVars((TupleExpr)child); final VariableOrder childVarOrder = new VariableOrder(childVars); setChildMetadata(fluoQueryBuilder, childNodeId, childVarOrder, constructId); //fast forward visitor to next node we care about child.visit(this); }