Java Code Examples for org.eclipse.rdf4j.query.algebra.MultiProjection#getArg()

The following examples show how to use org.eclipse.rdf4j.query.algebra.MultiProjection#getArg() . 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: MultiProjectionEvaluator.java    From rya with Apache License 2.0 6 votes vote down vote up
/**
 * Make a {@link MultiProjectionEvaluator} that processes the logic of a {@link MultiProjection}.
 *
 * @param multiProjection - Defines the projections that will be processed. (not null)
 * @param bNodeIdFactory - Creates the IDs for Blank Nodes. (not null)
 * @return A {@link MultiProjectionEvaluator} for the provided {@link MultiProjection}.
 */
public static MultiProjectionEvaluator make(final MultiProjection multiProjection, final BNodeIdFactory bNodeIdFactory) {
    requireNonNull(multiProjection);

    // Figure out if there are extensions.
    final TupleExpr arg = multiProjection.getArg();
    final Optional<Extension> extension = (arg instanceof Extension) ? Optional.of((Extension)arg): Optional.empty();

    // If there are, iterate through them and find any blank node source names.
    final Set<String> blankNodeSourceNames = new HashSet<>();
    if(extension.isPresent()) {
        for(final ExtensionElem elem : extension.get().getElements()) {
            if(elem.getExpr() instanceof BNodeGenerator) {
                blankNodeSourceNames.add( elem.getName() );
            }
        }
    }

    // Create a ProjectionEvaluator for each projection that is part of the multi.
    final Set<ProjectionEvaluator> projections = new HashSet<>();
    for(final ProjectionElemList projectionElemList : multiProjection.getProjections()) {
        projections.add( new ProjectionEvaluator(projectionElemList, extension) );
    }

    return new MultiProjectionEvaluator(projections, blankNodeSourceNames, bNodeIdFactory);
}
 
Example 2
Source File: TopologyFactory.java    From rya with Apache License 2.0 6 votes vote down vote up
@Override
public void meet(final MultiProjection node) throws TopologyBuilderException {
    final String id = PROJECTION_PREFIX + UUID.randomUUID();
    final Optional<Side> side = getSide(node);

    final MultiProjectionProcessorSupplier supplier = new MultiProjectionProcessorSupplier(
            MultiProjectionEvaluator.make(node, bNodeIdFactory),
            result -> getResult(side, result));

    // If the arg is an Extension, then this node's grandchild is the next processing node.
    TupleExpr downstreamNode = node.getArg();
    if (downstreamNode instanceof Extension) {
        downstreamNode = ((Extension) downstreamNode).getArg();
    }

    entries.add(new ProcessorEntry(node, id, side, supplier, Lists.newArrayList(downstreamNode)));
    idMap.put(node, id);
    super.meet(node);
}
 
Example 3
Source File: SparqlToPipelineTransformVisitor.java    From rya with Apache License 2.0 5 votes vote down vote up
@Override
public void meet(MultiProjection projectionNode) throws Exception {
    projectionNode.visitChildren(this);
    if (projectionNode.getArg() instanceof AggregationPipelineQueryNode && projectionNode.getParentNode() != null) {
        AggregationPipelineQueryNode pipelineNode = (AggregationPipelineQueryNode) projectionNode.getArg();
        if (pipelineNode.project(projectionNode.getProjections())) {
            projectionNode.replaceWith(pipelineNode);
        }
    }
}
 
Example 4
Source File: ConstructConsequentVisitor.java    From rya with Apache License 2.0 5 votes vote down vote up
@Override
public void meet(MultiProjection projection) {
    List<ExtensionElem> bindings;
    if (projection.getArg() instanceof Extension) {
        bindings = ((Extension) projection.getArg()).getElements();
    }
    else {
        bindings = Arrays.asList();
    }
    for (ProjectionElemList template : projection.getProjections()) {
        recordConsequent(template, bindings);
    }
}