本文整理汇总了Java中org.openrdf.query.algebra.LeftJoin类的典型用法代码示例。如果您正苦于以下问题:Java LeftJoin类的具体用法?Java LeftJoin怎么用?Java LeftJoin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LeftJoin类属于org.openrdf.query.algebra包,在下文中一共展示了LeftJoin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getQuerySegment
import org.openrdf.query.algebra.LeftJoin; //导入依赖的package包/类
public QuerySegment<T> getQuerySegment(final QueryModelNode node) {
Preconditions.checkNotNull(node);
if(node instanceof Filter) {
final Filter filter = (Filter)node;
if(MatcherUtilities.segmentContainsLeftJoins(filter)) {
return new OptionalJoinSegment<T>(filter);
} else {
return new JoinSegment<T>(filter);
}
} else if(node instanceof Join) {
final Join join = (Join) node;
if(MatcherUtilities.segmentContainsLeftJoins(join)) {
return new OptionalJoinSegment<T>(join);
} else {
return new JoinSegment<T>(join);
}
} else if (node instanceof LeftJoin) {
return new OptionalJoinSegment<T>((LeftJoin) node);
} else {
throw new IllegalArgumentException("Node must be a Join, Filter, or LeftJoin");
}
}
示例2: getJoinArgs
import org.openrdf.query.algebra.LeftJoin; //导入依赖的package包/类
/**
*
* @param tupleExpr
* - the query object that will be traversed by this method
* @param joinArgs
* - all nodes connected by Joins, LeftJoins, and Filters
* @return - List containing all nodes connected by Joins, LeftJoins, and
* Filters. This List contains the {@link ValueExpr} in place of the
* Filter and a {@link FlattenedOptional} in place of the LeftJoin
* for ease of comparison with PCJ nodes.
*/
private List<QueryModelNode> getJoinArgs(TupleExpr tupleExpr, List<QueryModelNode> joinArgs) {
if (tupleExpr instanceof Join) {
if (!(((Join) tupleExpr).getLeftArg() instanceof FixedStatementPattern)
&& !(((Join) tupleExpr).getRightArg() instanceof DoNotExpandSP)) {
Join join = (Join) tupleExpr;
getJoinArgs(join.getRightArg(), joinArgs);
getJoinArgs(join.getLeftArg(), joinArgs);
}
} else if (tupleExpr instanceof LeftJoin) {
LeftJoin lj = (LeftJoin) tupleExpr;
joinArgs.add(new FlattenedOptional(lj));
getJoinArgs(lj.getLeftArg(), joinArgs);
} else if (tupleExpr instanceof Filter) {
Filter filter = (Filter) tupleExpr;
joinArgs.add(filter.getCondition());
conditionMap.put(filter.getCondition(), filter);
getJoinArgs(filter.getArg(), joinArgs);
} else {
joinArgs.add(tupleExpr);
}
return joinArgs;
}
示例3: getJoinArgs
import org.openrdf.query.algebra.LeftJoin; //导入依赖的package包/类
/**
* This method is used to retrieve a set view of all descendants of the
* rightArg of the LeftJoin (the optional part)
*
* @param tupleExpr
* - tupleExpr whose args are being retrieved
* @param joinArgs
* - set view of all non-join args that are descendants of
* tupleExpr
* @return joinArgs
*/
private Set<TupleExpr> getJoinArgs(TupleExpr tupleExpr, Set<TupleExpr> joinArgs) {
if (tupleExpr instanceof Join) {
if (!(((Join) tupleExpr).getLeftArg() instanceof FixedStatementPattern)
&& !(((Join) tupleExpr).getRightArg() instanceof DoNotExpandSP)) {
Join join = (Join) tupleExpr;
getJoinArgs(join.getLeftArg(), joinArgs);
getJoinArgs(join.getRightArg(), joinArgs);
}
} else if (tupleExpr instanceof LeftJoin) { // TODO probably not
// necessary if not
// including leftarg
LeftJoin lj = (LeftJoin) tupleExpr;
joinArgs.add(new FlattenedOptional(lj));
getJoinArgs(lj.getLeftArg(), joinArgs);
} else if (tupleExpr instanceof Filter) {
getJoinArgs(((Filter) tupleExpr).getArg(), joinArgs);
} else {
joinArgs.add(tupleExpr);
}
return joinArgs;
}
示例4: buildQuery
import org.openrdf.query.algebra.LeftJoin; //导入依赖的package包/类
private void buildQuery(final TupleExpr tupleExpr, final StatementPattern matchStatement) {
//If our IndexerExpr (to be) is the rhs-child of LeftJoin, we can safely make that a Join:
// the IndexerExpr will (currently) not return results that can deliver unbound variables.
//This optimization should probably be generalized into a LeftJoin -> Join optimizer under certain conditions. Until that
// has been done, this code path at least takes care of queries generated by OpenSahara SparqTool that filter on OPTIONAL
// projections. E.g. summary~'full text search' (summary is optional). See #379
if (matchStatement.getParentNode() instanceof LeftJoin) {
final LeftJoin leftJoin = (LeftJoin)matchStatement.getParentNode();
if (leftJoin.getRightArg() == matchStatement && leftJoin.getCondition() == null) {
matchStatement.getParentNode().replaceWith(new Join(leftJoin.getLeftArg(), leftJoin.getRightArg()));
}
}
final FilterFunction fVisitor = new FilterFunction(matchStatement.getObjectVar().getName());
tupleExpr.visit(fVisitor);
final List<IndexingExpr> results = Lists.newArrayList();
for(int i = 0; i < fVisitor.func.size(); i++){
results.add(new IndexingExpr(fVisitor.func.get(i), matchStatement, fVisitor.args.get(i)));
}
removeMatchedPattern(tupleExpr, matchStatement, new IndexerExprReplacer(results));
}
示例5: getJoinArgs
import org.openrdf.query.algebra.LeftJoin; //导入依赖的package包/类
private List<TupleExpr> getJoinArgs(TupleExpr tupleExpr,
List<TupleExpr> joinArgs) {
if (tupleExpr instanceof Projection) {
Projection projection = (Projection) tupleExpr;
getJoinArgs(projection.getArg(), joinArgs);
} else if (tupleExpr instanceof Join) {
Join join = (Join) tupleExpr;
getJoinArgs(join.getLeftArg(), joinArgs);
getJoinArgs(join.getRightArg(), joinArgs);
} else if (tupleExpr instanceof LeftJoin) {
LeftJoin lj = (LeftJoin) tupleExpr;
joinArgs.add(new FlattenedOptional(lj));
getJoinArgs(lj.getLeftArg(), joinArgs);
} else if (tupleExpr instanceof Filter) {
getJoinArgs(((Filter) tupleExpr).getArg(), joinArgs);
} else {
joinArgs.add(tupleExpr);
}
return joinArgs;
}
示例6: meet
import org.openrdf.query.algebra.LeftJoin; //导入依赖的package包/类
@Override
public void meet(LeftJoin leftJoin) {
leftJoin.getLeftArg().visit(this);
Set<String> origBoundVars = boundVars;
try {
boundVars = new HashSet<String>(boundVars);
boundVars.addAll(leftJoin.getLeftArg().getBindingNames());
leftJoin.getRightArg().visit(this);
} finally {
boundVars = origBoundVars;
}
}
示例7: makeId
import org.openrdf.query.algebra.LeftJoin; //导入依赖的package包/类
private String makeId(final QueryModelNode node) {
checkNotNull(node);
// Create the prefix of the id. This makes it a little bit more human readable.
String prefix;
if (node instanceof StatementPattern) {
prefix = SP_PREFIX;
} else if (node instanceof Filter) {
prefix = FILTER_PREFIX;
} else if (node instanceof Join || node instanceof LeftJoin) {
prefix = JOIN_PREFIX;
} else if (node instanceof Projection) {
prefix = PROJECTION_PREFIX;
} else if(node instanceof Extension) {
prefix = AGGREGATION_PREFIX;
} else if (node instanceof Reduced) {
prefix = CONSTRUCT_PREFIX;
} else if(node instanceof PeriodicQueryNode) {
prefix = PERIODIC_QUERY_PREFIX;
} else {
throw new IllegalArgumentException("Node must be of type {StatementPattern, Join, Filter, Extension, Projection} but was " + node.getClass());
}
final String unique = UUID.randomUUID().toString().replaceAll("-", "");
// Put them together to create the Node ID.
return prefix + "_" + unique;
}
示例8: meet
import org.openrdf.query.algebra.LeftJoin; //导入依赖的package包/类
@Override
public void meet(final LeftJoin node) {
// Extract the metadata that will be stored for the node.
final String leftJoinNodeId = nodeIds.getOrMakeId(node);
final QueryModelNode left = node.getLeftArg();
final QueryModelNode right = node.getRightArg();
// Update the metadata for the JoinMetadata.Builder.
makeJoinMetadata(leftJoinNodeId, JoinType.LEFT_OUTER_JOIN, left, right);
// Walk to the next node.
super.meet(node);
}
示例9: meetNode
import org.openrdf.query.algebra.LeftJoin; //导入依赖的package包/类
@Override
public void meetNode(final QueryModelNode node) {
if (!(node instanceof Join || node instanceof LeftJoin
|| node instanceof StatementPattern || node instanceof Var
|| node instanceof Union || node instanceof Filter || node instanceof Projection)) {
isValid = false;
return;
}
super.meetNode(node);
}
示例10: meet
import org.openrdf.query.algebra.LeftJoin; //导入依赖的package包/类
@Override
public void meet(final LeftJoin leftJoin) {
if (leftJoin.getLeftArg().getBindingNames().containsAll(filterVars)) {
leftJoin.getLeftArg().visit(this);
} else {
relocate(filter, leftJoin.getLeftArg());
}
}
示例11: segmentContainsLeftJoins
import org.openrdf.query.algebra.LeftJoin; //导入依赖的package包/类
public static boolean segmentContainsLeftJoins(final TupleExpr tupleExpr) {
if (tupleExpr instanceof Projection) {
return segmentContainsLeftJoins(((Projection) tupleExpr).getArg());
} else if (tupleExpr instanceof Join) {
final Join join = (Join) tupleExpr;
return segmentContainsLeftJoins(join.getRightArg())
|| segmentContainsLeftJoins(join.getLeftArg());
} else if (tupleExpr instanceof LeftJoin) {
return true;
} else if (tupleExpr instanceof Filter) {
return segmentContainsLeftJoins(((Filter) tupleExpr).getArg());
} else {
return false;
}
}
示例12: FlattenedOptional
import org.openrdf.query.algebra.LeftJoin; //导入依赖的package包/类
public FlattenedOptional(LeftJoin node) {
rightArgs = getJoinArgs(node.getRightArg(), new HashSet<TupleExpr>());
boundVars = setWithOutConstants(
Sets.intersection(node.getLeftArg().getAssuredBindingNames(), node.getRightArg().getBindingNames()));
unboundVars = setWithOutConstants(Sets.difference(node.getRightArg().getBindingNames(), boundVars));
condition = node.getCondition();
rightArg = node.getRightArg();
getVarCounts(node);
assuredBindingNames = new HashSet<>(leftArgVarCounts.keySet());
bindingNames = new HashSet<>(Sets.union(assuredBindingNames, unboundVars));
}
示例13: getVarCounts
import org.openrdf.query.algebra.LeftJoin; //导入依赖的package包/类
/**
* This method counts the number of times each variable appears in the
* leftArg of the LeftJoin defining this FlattenedOptional. This information
* is used to whether nodes can be moved out of the leftarg above the
* LeftJoin in the query.
*
* @param tupleExpr
*/
private void getVarCounts(TupleExpr tupleExpr) {
if (tupleExpr instanceof Join) {
Join join = (Join) tupleExpr;
getVarCounts(join.getLeftArg());
getVarCounts(join.getRightArg());
} else if (tupleExpr instanceof LeftJoin) {
LeftJoin lj = (LeftJoin) tupleExpr;
getVarCounts(lj.getLeftArg());
} else if (tupleExpr instanceof Filter) {
getVarCounts(((Filter) tupleExpr).getArg());
} else {
incrementVarCounts(tupleExpr.getBindingNames());
}
}
示例14: getJoin
import org.openrdf.query.algebra.LeftJoin; //导入依赖的package包/类
private static TupleExpr getJoin(TupleExpr oldJoin, TupleExpr newArg) {
if (newArg instanceof FlattenedOptional) {
return new LeftJoin(oldJoin, ((FlattenedOptional) newArg).getRightArg());
} else {
return new Join(oldJoin, newArg);
}
}
示例15: meet
import org.openrdf.query.algebra.LeftJoin; //导入依赖的package包/类
@Override
public void meet(final FunctionCall call) {
final URI fnUri = valueFactory.createURI(call.getURI());
final Var resultVar = IndexingFunctionRegistry.getResultVarFromFunctionCall(fnUri, call.getArgs());
if (resultVar != null && resultVar.getName().equals(matchVar)) {
addFilter(valueFactory.createURI(call.getURI()), extractArguments(matchVar, call));
if (call.getParentNode() instanceof Filter || call.getParentNode() instanceof And || call.getParentNode() instanceof LeftJoin) {
call.replaceWith(new ValueConstant(valueFactory.createLiteral(true)));
} else {
throw new IllegalArgumentException("Query error: Found " + call + " as part of an expression that is too complex");
}
}
}