Java源码示例:org.eclipse.rdf4j.query.algebra.evaluation.impl.ExternalSet

示例1
/**
 * Switch logic appropriate for each type of {@link TupleExpr} query model node, sending each type to it's appropriate evaluation method. For example,
 * {@code UnaryTupleOperator} is sent to {@link evaluateUnaryTupleOperator()}.
 * @param parent
 * @param expr
 * @param bindings
 */
private void evaluateTupleExpr(BindingSetPipe parent, TupleExpr expr, BindingSet bindings) {
    if (expr instanceof StatementPattern) {
        statementEvaluation.evaluateStatementPattern(parent, (StatementPattern) expr, bindings);
    } else if (expr instanceof UnaryTupleOperator) {
        evaluateUnaryTupleOperator(parent, (UnaryTupleOperator) expr, bindings);
    } else if (expr instanceof BinaryTupleOperator) {
        evaluateBinaryTupleOperator(parent, (BinaryTupleOperator) expr, bindings);
    } else if (expr instanceof SingletonSet) {
        evaluateSingletonSet(parent, (SingletonSet) expr, bindings);
    } else if (expr instanceof EmptySet) {
        evaluateEmptySet(parent, (EmptySet) expr, bindings);
    } else if (expr instanceof ExternalSet) {
        evaluateExternalSet(parent, (ExternalSet) expr, bindings);
    } else if (expr instanceof ZeroLengthPath) {
        evaluateZeroLengthPath(parent, (ZeroLengthPath) expr, bindings);
    } else if (expr instanceof ArbitraryLengthPath) {
        evaluateArbitraryLengthPath(parent, (ArbitraryLengthPath) expr, bindings);
    } else if (expr instanceof BindingSetAssignment) {
        evaluateBindingSetAssignment(parent, (BindingSetAssignment) expr, bindings);
    } else if (expr == null) {
        parent.handleException(new IllegalArgumentException("expr must not be null"));
    } else {
        parent.handleException(new QueryEvaluationException("Unsupported tuple expr type: " + expr.getClass()));
    }
}
 
示例2
@Override
protected void meetNode(QueryModelNode node) {
    if (node instanceof ExternalSet) {
        meetExternalSet((ExternalSet) node);
    } else {
        node.visitChildren(this);
    }
}
 
示例3
/**
 * Evaluate {@link ExternalSet} query model nodes
 * @param parent
 * @param externalSet
 * @param bindings
 */
private void evaluateExternalSet(BindingSetPipe parent, ExternalSet externalSet, BindingSet bindings) {
    try {
        HalyardStatementPatternEvaluation.enqueue(parent, externalSet.evaluate(bindings), externalSet);
    } catch (QueryEvaluationException e) {
        parent.handleException(e);
    }
}
 
示例4
@Override
public List<QueryModelNode> getAllUnmatchedNodes() {
    final List<QueryModelNode> unmatched = new ArrayList<>();
    for (final QueryModelNode node : segmentNodeList) {
        if (!(node instanceof ExternalSet)) {
            unmatched.add(node);
        }
    }
    return unmatched;
}
 
示例5
@Override
public void meetNode(final QueryModelNode node) {
    if (node instanceof ExternalSet) {
        qNodes.add(node);
    }
    super.meetNode(node);
}
 
示例6
@Override
public void meetNode(QueryModelNode node) throws RuntimeException {
    if (node instanceof ExternalSet || node instanceof StatementPattern) {
        eSet.add(node);
    }
    super.meetNode(node);
}
 
示例7
public Flux<BindingSet> evaluateReactorInternal(TupleExpr expr, BindingSet bindings)
        throws QueryEvaluationException
{
    if (expr instanceof StatementPattern) {
        return evaluateReactorInternal((StatementPattern) expr, bindings);
    }
    else if (expr instanceof UnaryTupleOperator) {
        return evaluateReactorInternal((UnaryTupleOperator) expr, bindings);
    }
    else if (expr instanceof BinaryTupleOperator) {
        return evaluateReactorInternal((BinaryTupleOperator) expr, bindings);
    }
    else if (expr instanceof SingletonSet) {
        return evaluateReactorInternal((SingletonSet) expr, bindings);
    }
    else if (expr instanceof EmptySet) {
        return evaluateReactorInternal((EmptySet) expr, bindings);
    }
    else if (expr instanceof ExternalSet) {
        return evaluateReactorInternal((ExternalSet) expr, bindings);
    }
    else if (expr instanceof ZeroLengthPath) {
        return evaluateReactorInternal((ZeroLengthPath) expr, bindings);
    }
    else if (expr instanceof ArbitraryLengthPath) {
        return evaluateReactorInternal((ArbitraryLengthPath) expr, bindings);
    }
    else if (expr instanceof BindingSetAssignment) {
        return evaluateReactorInternal((BindingSetAssignment) expr, bindings);
    }
    else if (expr == null) {
        throw new IllegalArgumentException("expr must not be null");
    }
    else {
        throw new QueryEvaluationException("Unsupported tuple expr type: " + expr.getClass());
    }
}
 
示例8
public Observable<BindingSet> evaluateReactiveInternal(TupleExpr expr, BindingSet bindings)
        throws QueryEvaluationException
{
    if (expr instanceof StatementPattern) {
        return evaluateReactiveInternal((StatementPattern) expr, bindings);
    }
    else if (expr instanceof UnaryTupleOperator) {
        return evaluateReactiveInternal((UnaryTupleOperator) expr, bindings);
    }
    else if (expr instanceof BinaryTupleOperator) {
        return evaluateReactiveInternal((BinaryTupleOperator) expr, bindings);
    }
    else if (expr instanceof SingletonSet) {
        return evaluateReactiveInternal((SingletonSet) expr, bindings);
    }
    else if (expr instanceof EmptySet) {
        return evaluateReactiveInternal((EmptySet) expr, bindings);
    }
    else if (expr instanceof ExternalSet) {
        return evaluateReactiveInternal((ExternalSet) expr, bindings);
    }
    else if (expr instanceof ZeroLengthPath) {
        return evaluateReactiveInternal((ZeroLengthPath) expr, bindings);
    }
    else if (expr instanceof ArbitraryLengthPath) {
        return evaluateReactiveInternal((ArbitraryLengthPath) expr, bindings);
    }
    else if (expr instanceof BindingSetAssignment) {
        return evaluateReactiveInternal((BindingSetAssignment) expr, bindings);
    }
    else if (expr == null) {
        throw new IllegalArgumentException("expr must not be null");
    }
    else {
        throw new QueryEvaluationException("Unsupported tuple expr type: " + expr.getClass());
    }
}
 
示例9
private double getSpJoinSelect(RdfCloudTripleStoreConfiguration conf, TupleExpr te, StatementPattern sp1)
        throws TableNotFoundException {

    // System.out.println("Tuple is " + te + " and sp is " + sp1);

    if (te instanceof StatementPattern) {
        return getJoinSelect(conf, (StatementPattern) te, sp1);
    } else {

        SpExternalCollector spe = new SpExternalCollector();
        te.visit(spe);
        List<QueryModelNode> espList = spe.getSpExtTup();

        if (espList.size() == 0) {

            Set<String> tupBn = te.getAssuredBindingNames();
            Set<String> eBn = sp1.getAssuredBindingNames();
            Set<String> intersect = Sets.intersection(tupBn, eBn);

            return Math.pow(1.0 / 10000.0, intersect.size());

        }
        
        double min = Double.MAX_VALUE;
        double select = Double.MAX_VALUE;

        for (QueryModelNode node : espList) {

            if (node instanceof StatementPattern)
                select = getJoinSelect(conf, sp1, (StatementPattern) node);
            else if (node instanceof ExternalSet) {
                select = getExtJoinSelect(sp1, (ExternalSet) node);
            }

            if (min > select) {
                min = select;
            }
        }
        // System.out.println("Max is " + max);
        return min;
    }
}
 
示例10
public Flux<BindingSet> evaluateReactorInternal(ExternalSet expr, BindingSet bindings)
        throws QueryEvaluationException
{
    return fromIteration(evalStrategy.evaluate(expr, bindings));
}
 
示例11
public Observable<BindingSet> evaluateReactiveInternal(ExternalSet expr, BindingSet bindings)
        throws QueryEvaluationException
{
    return fromIteration(expr.evaluate(bindings));
}
 
示例12
private double getSelectivity(RdfCloudTripleStoreConfiguration conf, TupleExpr te, QueryModelNode node) throws TableNotFoundException {
    
      if ((node instanceof StatementPattern)) {
          return getSpJoinSelect(conf, te, (StatementPattern) node);

      } else if (node instanceof ExternalSet) {

          return getExtJoinSelect(te, (ExternalSet) node);

      } else {
          return 0;
      }
    
}
 
示例13
private double getExtJoinSelect(TupleExpr te, ExternalSet eSet) {
    
      Set<String> tupBn = te.getAssuredBindingNames();
      Set<String> eBn = eSet.getAssuredBindingNames();
      Set<String> intersect = Sets.intersection(tupBn, eBn);
     
      return Math.pow(1.0 / 10000.0, intersect.size());
    
}