org.eclipse.rdf4j.query.algebra.Intersection Java Examples

The following examples show how to use org.eclipse.rdf4j.query.algebra.Intersection. 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: LimitedSizeEvaluationStrategy.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(final Intersection intersection,
		final BindingSet bindings) throws QueryEvaluationException {
	Iteration<BindingSet, QueryEvaluationException> leftArg, rightArg;

	leftArg = new DelayedIteration<BindingSet, QueryEvaluationException>() {

		@Override
		protected Iteration<BindingSet, QueryEvaluationException> createIteration()
				throws QueryEvaluationException {
			return evaluate(intersection.getLeftArg(), bindings);
		}
	};

	rightArg = new DelayedIteration<BindingSet, QueryEvaluationException>() {

		@Override
		protected Iteration<BindingSet, QueryEvaluationException> createIteration()
				throws QueryEvaluationException {
			return evaluate(intersection.getRightArg(), bindings);
		}
	};

	return new LimitedSizeIntersectIteration(leftArg, rightArg, used, maxSize);
}
 
Example #2
Source File: StrictEvaluationStrategy.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(BinaryTupleOperator expr,
		BindingSet bindings) throws QueryEvaluationException {
	if (expr instanceof Join) {
		return evaluate((Join) expr, bindings);
	} else if (expr instanceof LeftJoin) {
		return evaluate((LeftJoin) expr, bindings);
	} else if (expr instanceof Union) {
		return evaluate((Union) expr, bindings);
	} else if (expr instanceof Intersection) {
		return evaluate((Intersection) expr, bindings);
	} else if (expr instanceof Difference) {
		return evaluate((Difference) expr, bindings);
	} else if (expr == null) {
		throw new IllegalArgumentException("expr must not be null");
	} else {
		throw new QueryEvaluationException("Unsupported binary tuple operator type: " + expr.getClass());
	}
}
 
Example #3
Source File: StrictEvaluationStrategy.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(final Intersection intersection,
		final BindingSet bindings) throws QueryEvaluationException {
	Iteration<BindingSet, QueryEvaluationException> leftArg, rightArg;

	leftArg = new DelayedIteration<BindingSet, QueryEvaluationException>() {

		@Override
		protected Iteration<BindingSet, QueryEvaluationException> createIteration()
				throws QueryEvaluationException {
			return evaluate(intersection.getLeftArg(), bindings);
		}
	};

	rightArg = new DelayedIteration<BindingSet, QueryEvaluationException>() {

		@Override
		protected Iteration<BindingSet, QueryEvaluationException> createIteration()
				throws QueryEvaluationException {
			return evaluate(intersection.getRightArg(), bindings);
		}
	};

	return new IntersectIteration<>(leftArg, rightArg);
}
 
Example #4
Source File: HalyardTupleExprEvaluation.java    From Halyard with Apache License 2.0 6 votes vote down vote up
/**
 * Evaluate {@link BinaryTupleOperator} query model nodes
 * @param parent
 * @param expr
 * @param bindings
 */
private void evaluateBinaryTupleOperator(BindingSetPipe parent, BinaryTupleOperator expr, BindingSet bindings) {
    if (expr instanceof Join) {
        evaluateJoin(parent, (Join) expr, bindings);
    } else if (expr instanceof LeftJoin) {
        evaluateLeftJoin(parent, (LeftJoin) expr, bindings);
    } else if (expr instanceof Union) {
        evaluateUnion(parent, (Union) expr, bindings);
    } else if (expr instanceof Intersection) {
        evaluateIntersection(parent, (Intersection) expr, bindings);
    } else if (expr instanceof Difference) {
        evaluateDifference(parent, (Difference) expr, bindings);
    } else if (expr == null) {
        parent.handleException(new IllegalArgumentException("expr must not be null"));
    } else {
        parent.handleException(new QueryEvaluationException("Unsupported binary tuple operator type: " + expr.getClass()));
    }
}
 
Example #5
Source File: IntersectionBlock.java    From semagrow with Apache License 2.0 5 votes vote down vote up
public Collection<Plan> getIntersectionPlan(CompilerContext context, Collection<Plan> p1, Collection<Plan> p2) {
    return p1.stream().flatMap( pp1 ->
            p2.stream().flatMap(pp2 ->
                    Stream.of(context.asPlan(new Intersection(pp1, pp2)))
            )
    ).collect(Collectors.toList());
}
 
Example #6
Source File: QueryModelPruner.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void meet(Intersection intersection) {
	super.meet(intersection);
	TupleExpr leftArg = intersection.getLeftArg();
	TupleExpr rightArg = intersection.getRightArg();
	if (leftArg instanceof EmptySet || rightArg instanceof EmptySet) {
		intersection.replaceWith(leftArg);
	}
}
 
Example #7
Source File: ContextCollector.java    From semagrow with Apache License 2.0 5 votes vote down vote up
/**
 * @inheritDoc
 */
@Override
public void meet(Intersection theOp)
        throws Exception
{
    binaryOpMeet(theOp, theOp.getLeftArg(), theOp.getRightArg());
}
 
Example #8
Source File: SPARQLTupleExprRenderer.java    From semagrow with Apache License 2.0 5 votes vote down vote up
/**
 * @inheritDoc
 */
@Override
public void meet(Intersection theOp)
        throws Exception
{
    String aLeft = renderTupleExpr(theOp.getLeftArg());
    String aRight = renderTupleExpr(theOp.getRightArg());

    mJoinBuffer.append("\n").append(aLeft).append("}").append("\nintersection\n").append("{").append(aRight).append(
            "}.\n");
}
 
Example #9
Source File: PCJOptimizerUtilities.java    From rya with Apache License 2.0 5 votes vote down vote up
@Override
public void meet(final Intersection node) {
	if (Sets.intersection(node.getRightArg().getBindingNames(), filterVars).size() > 0) {
		relocate(filter, node.getRightArg());
	} else if (Sets.intersection(node.getLeftArg().getBindingNames(), filterVars).size() > 0) {
		final Filter clone = new Filter(filter.getArg(), filter
				.getCondition().clone());
		relocate(clone, node.getLeftArg());
	}
}
 
Example #10
Source File: QueryModelBuilder.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public TupleExpr visit(ASTGraphIntersect node, Object data) throws VisitorException {
	TupleExpr leftArg = (TupleExpr) node.getLeftArg().jjtAccept(this, null);
	TupleExpr rightArg = (TupleExpr) node.getRightArg().jjtAccept(this, null);

	return new Intersection(leftArg, rightArg);
}
 
Example #11
Source File: QueryModelBuilder.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public TupleExpr visit(ASTTupleIntersect node, Object data) throws VisitorException {
	TupleExpr leftArg = (TupleExpr) node.getLeftArg().jjtAccept(this, null);
	TupleExpr rightArg = (TupleExpr) node.getRightArg().jjtAccept(this, null);

	return new Intersection(leftArg, rightArg);
}
 
Example #12
Source File: SerqlTupleExprRenderer.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * @inheritDoc
 */
@Override
public void meet(Intersection theOp) throws Exception {
	String aLeft = renderTupleExpr(theOp.getLeftArg());
	String aRight = renderTupleExpr(theOp.getRightArg());

	mBuffer.append(aLeft).append("\nintersection\n").append(aRight);
}
 
Example #13
Source File: SparqlTupleExprRenderer.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * @inheritDoc
 */
@Override
public void meet(Intersection theOp) throws Exception {
	String aLeft = renderTupleExpr(theOp.getLeftArg());
	String aRight = renderTupleExpr(theOp.getRightArg());

	mJoinBuffer.append("\n")
			.append(aLeft)
			.append("}")
			.append("\nintersection\n")
			.append("{")
			.append(aRight)
			.append("}.\n");
}
 
Example #14
Source File: QueryModelNormalizer.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void meet(Intersection intersection) {
	super.meet(intersection);

	TupleExpr leftArg = intersection.getLeftArg();
	TupleExpr rightArg = intersection.getRightArg();

	if (leftArg instanceof EmptySet || rightArg instanceof EmptySet) {
		intersection.replaceWith(new EmptySet());
	}
}
 
Example #15
Source File: FilterOptimizer.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void meet(Intersection node) {
	Filter clone = new Filter();
	clone.setCondition(filter.getCondition().clone());

	relocate(filter, node.getLeftArg());
	relocate(clone, node.getRightArg());

	FilterRelocator.relocate(filter);
	FilterRelocator.relocate(clone);
}
 
Example #16
Source File: QueryModelPruner.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void meet(Intersection intersection) {
	super.meet(intersection);

	TupleExpr leftArg = intersection.getLeftArg();
	TupleExpr rightArg = intersection.getRightArg();

	if (leftArg instanceof EmptySet || rightArg instanceof EmptySet) {
		intersection.replaceWith(new EmptySet());
	}
}
 
Example #17
Source File: ContextCollector.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * @inheritDoc
 */
@Override
public void meet(Intersection theOp) throws Exception {
	binaryOpMeet(theOp, theOp.getLeftArg(), theOp.getRightArg());
}
 
Example #18
Source File: AbstractQueryModelVisitor.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void meet(Intersection node) throws X {
	meetBinaryTupleOperator(node);
}