Search in sources :

Example 1 with IBindingProducerNode

use of com.bigdata.rdf.sparql.ast.IBindingProducerNode in project wikidata-query-rdf by wikimedia.

the class WikidataServicePlacementOptimizer method findLatestPossiblePositionForTheServiceNode.

private int findLatestPossiblePositionForTheServiceNode(StaticAnalysis sa, BOp serviceNode, final JoinGroupNode joinGroup) {
    int lastJoinIndex = -1;
    // Retrieve inVars from annotations. If no WIKIDATA_SERVICE_IN_VARS annotation provided
    // (which occurs on first run of LabelServicePlacementOptimizer), we still need to
    // traverse the tree, as there might be NamedSubqueryInclude, which might
    // be producing variables for ServiceNode.
    Object inVarsObject = serviceNode.annotations().get(WIKIDATA_SERVICE_IN_VARS);
    @SuppressWarnings("unchecked") Set<IVariable<?>> inVars = inVarsObject instanceof Set ? (Set<IVariable<?>>) inVarsObject : Collections.emptySet();
    for (int i = joinGroup.size() - 1; i >= 0; i--) {
        BOp child = joinGroup.get(i);
        if (child != serviceNode && child instanceof IBindingProducerNode) {
            // will touch any inbound var for the service
            if (checkIfNodeProducesVars(sa, child, inVars)) {
                lastJoinIndex = i;
                break;
            }
        }
    }
    return lastJoinIndex;
}
Also used : BOp(com.bigdata.bop.BOp) Set(java.util.Set) IBindingSet(com.bigdata.bop.IBindingSet) IVariable(com.bigdata.bop.IVariable) IBindingProducerNode(com.bigdata.rdf.sparql.ast.IBindingProducerNode)

Aggregations

BOp (com.bigdata.bop.BOp)1 IBindingSet (com.bigdata.bop.IBindingSet)1 IVariable (com.bigdata.bop.IVariable)1 IBindingProducerNode (com.bigdata.rdf.sparql.ast.IBindingProducerNode)1 Set (java.util.Set)1