Java源码示例:org.eclipse.rdf4j.query.algebra.Difference

示例1
@Override
public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(final Difference difference,
		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(difference.getLeftArg(), bindings);
		}
	};

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

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

	return new LimitedSizeSPARQLMinusIteration(leftArg, rightArg, used, maxSize);
}
 
示例2
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());
	}
}
 
示例3
public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(final Difference difference,
		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(difference.getLeftArg(), bindings);
		}
	};

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

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

	return new SPARQLMinusIteration<>(leftArg, rightArg);
}
 
示例4
@Override
public Object visit(ASTMinusGraphPattern node, Object data) throws VisitorException {
	GraphPattern parentGP = graphPattern;

	TupleExpr leftArg = graphPattern.buildTupleExpr();

	graphPattern = new GraphPattern(parentGP);
	node.jjtGetChild(0).jjtAccept(this, null);
	TupleExpr rightArg = graphPattern.buildTupleExpr();

	parentGP = new GraphPattern();
	parentGP.addRequiredTE(new Difference(leftArg, rightArg));
	graphPattern = parentGP;

	return null;
}
 
示例5
/**
 * 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()));
    }
}
 
示例6
@Override
public void meet(Difference node) throws RDFHandlerException {
	node.getLeftArg().visit(this);
	listEntry();
	handler.handleStatement(valueFactory.createStatement(subject, RDF.TYPE, SP.MINUS_CLASS));
	Resource elementsList = valueFactory.createBNode();
	handler.handleStatement(valueFactory.createStatement(subject, SP.ELEMENTS_PROPERTY, elementsList));
	ListContext elementsCtx = newList(elementsList);
	node.getRightArg().visit(this);
	endList(elementsCtx);
}
 
示例7
@Override
public void meet(Difference difference) {
	super.meet(difference);
	TupleExpr leftArg = difference.getLeftArg();
	TupleExpr rightArg = difference.getRightArg();
	if (leftArg instanceof EmptySet) {
		difference.replaceWith(leftArg);
	} else if (rightArg instanceof EmptySet) {
		difference.replaceWith(leftArg);
	} else if (leftArg instanceof SingletonSet && rightArg instanceof SingletonSet) {
		difference.replaceWith(new EmptySet());
	}
}
 
示例8
@Override
public void meet(Difference difference) {
	super.meet(difference);

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

	if (leftArg instanceof EmptySet) {
		difference.replaceWith(leftArg);
	} else if (rightArg instanceof EmptySet) {
		difference.replaceWith(leftArg);
	} else if (leftArg instanceof SingletonSet && rightArg instanceof SingletonSet) {
		difference.replaceWith(new EmptySet());
	}
}
 
示例9
@Override
public void meet(Difference node) {
	Filter clone = new Filter();
	clone.setCondition(filter.getCondition().clone());

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

	FilterRelocator.relocate(filter);
	FilterRelocator.relocate(clone);
}
 
示例10
@Override
public void meet(Difference difference) {
	super.meet(difference);

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

	if (leftArg instanceof EmptySet) {
		difference.replaceWith(leftArg);
	} else if (rightArg instanceof EmptySet) {
		difference.replaceWith(leftArg);
	} else if (leftArg instanceof SingletonSet && rightArg instanceof SingletonSet) {
		difference.replaceWith(new EmptySet());
	}
}
 
示例11
/**
 * @inheritDoc
 */
@Override
public void meet(Difference theOp) throws Exception {
	String aLeft = renderTupleExpr(theOp.getLeftArg());
	String aRight = renderTupleExpr(theOp.getRightArg());

	mJoinBuffer.append("\n{")
			.append(aLeft)
			.append("}")
			.append("\nminus\n")
			.append("{")
			.append(aRight)
			.append("}.\n");
}
 
示例12
/**
 * @inheritDoc
 */
@Override
public void meet(Difference theOp) throws Exception {
	String aLeft = renderTupleExpr(theOp.getLeftArg());
	String aRight = renderTupleExpr(theOp.getRightArg());

	mBuffer.append(aLeft).append("\nminus\n").append(aRight);
}
 
示例13
@Override
public TupleExpr visit(ASTTupleMinus node, Object data) throws VisitorException {
	TupleExpr leftArg = (TupleExpr) node.getLeftArg().jjtAccept(this, null);
	TupleExpr rightArg = (TupleExpr) node.getRightArg().jjtAccept(this, null);

	return new Difference(leftArg, rightArg);
}
 
示例14
@Override
public TupleExpr visit(ASTGraphMinus node, Object data) throws VisitorException {
	TupleExpr leftArg = (TupleExpr) node.getLeftArg().jjtAccept(this, null);
	TupleExpr rightArg = (TupleExpr) node.getRightArg().jjtAccept(this, null);

	return new Difference(leftArg, rightArg);
}
 
示例15
@Override
public void meet(final Difference 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());
	}
}
 
示例16
/**
 * @inheritDoc
 */
@Override
public void meet(Difference theOp)
        throws Exception
{
    String aLeft = renderTupleExpr(theOp.getLeftArg());
    String aRight = renderTupleExpr(theOp.getRightArg());

    mJoinBuffer.append("\n{").append(aLeft).append("}").append("\nminus\n").append("{").append(aRight).append(
            "}.\n");
}
 
示例17
/**
 * @inheritDoc
 */
@Override
public void meet(Difference theOp)
        throws Exception
{
    binaryOpMeet(theOp, theOp.getLeftArg(), theOp.getRightArg());
}
 
示例18
public Collection<Plan> getMinusPlan(CompilerContext context, Collection<Plan> p1, Collection<Plan> p2) {
    //FIXME: Check the Site property
    return p1.stream().flatMap( pp1 ->
            p2.stream().flatMap(pp2 ->
                    Stream.of(context.asPlan(new Difference(pp1, pp2)))
            )
    ).collect(Collectors.toList());
}
 
示例19
@Override
public void meet(Difference node) throws X {
	meetBinaryTupleOperator(node);
}
 
示例20
/**
 * @inheritDoc
 */
@Override
public void meet(Difference theOp) throws Exception {
	binaryOpMeet(theOp, theOp.getLeftArg(), theOp.getRightArg());
}