本文整理汇总了Java中org.openrdf.query.algebra.LeftJoin类的典型用法代码示例。如果您正苦于以下问题:Java LeftJoin类的具体用法?Java LeftJoin怎么用?Java LeftJoin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LeftJoin类属于org.openrdf.query.algebra包,在下文中一共展示了LeftJoin类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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");
}
}
开发者ID:apache,项目名称:incubator-rya,代码行数:24,代码来源:QuerySegmentFactory.java
示例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;
}
开发者ID:apache,项目名称:incubator-rya,代码行数:35,代码来源:OptionalJoinSegment.java
示例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;
}
开发者ID:apache,项目名称:incubator-rya,代码行数:34,代码来源:FlattenedOptional.java
示例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));
}
开发者ID:apache,项目名称:incubator-rya,代码行数:21,代码来源:FilterFunctionOptimizer.java
示例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;
}
开发者ID:apache,项目名称:incubator-rya,代码行数:21,代码来源:FlattenedOptionalTest.java
示例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;
}
}
开发者ID:apache,项目名称:incubator-rya,代码行数:15,代码来源:QueryJoinOptimizer.java
示例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;
}
开发者ID:apache,项目名称:incubator-rya,代码行数:28,代码来源:SparqlFluoQueryBuilder.java
示例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);
}
开发者ID:apache,项目名称:incubator-rya,代码行数:14,代码来源:SparqlFluoQueryBuilder.java
示例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);
}
开发者ID:apache,项目名称:incubator-rya,代码行数:11,代码来源:PCJOptimizerUtilities.java
示例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());
}
}
开发者ID:apache,项目名称:incubator-rya,代码行数:9,代码来源:PCJOptimizerUtilities.java
示例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;
}
}
开发者ID:apache,项目名称:incubator-rya,代码行数:16,代码来源:MatcherUtilities.java
示例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));
}
开发者ID:apache,项目名称:incubator-rya,代码行数:12,代码来源:FlattenedOptional.java
示例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());
}
}
开发者ID:apache,项目名称:incubator-rya,代码行数:23,代码来源:FlattenedOptional.java
示例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);
}
}
开发者ID:apache,项目名称:incubator-rya,代码行数:8,代码来源:QueryNodesToTupleExpr.java
示例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");
}
}
}
开发者ID:apache,项目名称:incubator-rya,代码行数:14,代码来源:FilterFunctionOptimizer.java
示例16: testAlreadyInOrder
import org.openrdf.query.algebra.LeftJoin; //导入依赖的package包/类
@Test
public void testAlreadyInOrder() throws Exception {
String query1 = ""//
+ "SELECT ?a ?b ?c ?d" //
+ "{" //
+ " ?a <uri:p5> <uri:const3>" //
+ " OPTIONAL{?a <uri:p3> ?c} . " //
+ " ?a <uri:p4> ?b . "//
+ " OPTIONAL{<uri:const2> <uri:p4> ?d } . "//
+ " ?c <uri:p1> ?d "
+ " OPTIONAL{<uri:const1> <uri:p2> ?b} . "//
+ "}";//
String query2 = ""//
+ "SELECT ?a ?b ?c ?d" //
+ "{" //
+ " ?a <uri:p4> ?b . "//
+ " OPTIONAL{<uri:const2> <uri:p4> ?d } . "//
+ " ?c <uri:p1> ?d "
+ "}";//
SPARQLParser parser = new SPARQLParser();
ParsedQuery pq1 = parser.parseQuery(query1, null);
ParsedQuery pq2 = parser.parseQuery(query2, null);
TupleExpr te1 = pq1.getTupleExpr();
TupleExpr te2 = pq2.getTupleExpr();
LeftJoin join1 = (LeftJoin) ((Projection) te1).getArg();
Join join2 = (Join) ((Projection) te2).getArg();
QuerySegment<ExternalTupleSet> seg1 = qFactory.getQuerySegment(join1);
QuerySegment<ExternalTupleSet> seg2 = qFactory.getQuerySegment(join2);
QueryNodeConsolidator consolidator = new QueryNodeConsolidator(seg1.getOrderedNodes(), seg2.getOrderedNodes());
List<QueryModelNode> queryNodes = new ArrayList<>(seg1.getOrderedNodes());
Assert.assertTrue(consolidator.consolidateNodes());
Assert.assertEquals(consolidator.getQueryNodes(), queryNodes);
}
开发者ID:apache,项目名称:incubator-rya,代码行数:41,代码来源:PCJNodeConsolidatorTest.java
示例17: testInvalidOrder
import org.openrdf.query.algebra.LeftJoin; //导入依赖的package包/类
@Test
public void testInvalidOrder() throws Exception {
String query1 = ""//
+ "SELECT ?a ?b ?c ?d" //
+ "{" //
+ " ?a <uri:p5> <uri:const3>" //
+ " OPTIONAL{<uri:const2> <uri:p4> ?d } . "//
+ " ?a <uri:p4> ?b . "//
+ " OPTIONAL{?a <uri:p3> ?c} . " //
+ " OPTIONAL{<uri:const1> <uri:p2> ?b} . "//
+ " ?c <uri:p1> ?d "
+ "}";//
String query2 = ""//
+ "SELECT ?a ?b ?c ?d" //
+ "{" //
+ " ?a <uri:p4> ?b . "//
+ " ?c <uri:p1> ?d "
+ " OPTIONAL{<uri:const2> <uri:p4> ?d } . "//
+ "}";//
SPARQLParser parser = new SPARQLParser();
ParsedQuery pq1 = parser.parseQuery(query1, null);
ParsedQuery pq2 = parser.parseQuery(query2, null);
TupleExpr te1 = pq1.getTupleExpr();
TupleExpr te2 = pq2.getTupleExpr();
Join join1 = (Join) ((Projection) te1).getArg();
LeftJoin join2 = (LeftJoin) ((Projection) te2).getArg();
QuerySegment<ExternalTupleSet> seg1 = qFactory.getQuerySegment(join1);
QuerySegment<ExternalTupleSet> seg2 = qFactory.getQuerySegment(join2);
QueryNodeConsolidator consolidator = new QueryNodeConsolidator(seg1.getOrderedNodes(), seg2.getOrderedNodes());
Assert.assertTrue(!consolidator.consolidateNodes());
}
开发者ID:apache,项目名称:incubator-rya,代码行数:38,代码来源:PCJNodeConsolidatorTest.java
示例18: testExactMatchReOrdered
import org.openrdf.query.algebra.LeftJoin; //导入依赖的package包/类
@Test
public void testExactMatchReOrdered() throws Exception {
String query1 = ""//
+ "SELECT ?a ?b ?c ?d ?e ?f ?g ?h" //
+ "{" //
+ " ?a <uri:p0> ?b ." //
+ " OPTIONAL{?b <uri:p2> ?c. ?c <uri:p1> ?d} . " //
+ " OPTIONAL{?b <uri:p3> ?e. ?e <uri:p1> ?f} . "//
+ " OPTIONAL{?b <uri:p4> ?g. ?g <uri:p1> ?h} . "//
+ "}";//
String query2 = ""//
+ "SELECT ?a ?b ?c ?d ?e ?f ?g ?h" //
+ "{" //
+ " ?a <uri:p0> ?b ." //
+ " OPTIONAL{?b <uri:p2> ?c. ?c <uri:p1> ?d} . " //
+ " OPTIONAL{?b <uri:p4> ?g. ?g <uri:p1> ?h} . "//
+ " OPTIONAL{?b <uri:p3> ?e. ?e <uri:p1> ?f} . "//
+ "}";//
SPARQLParser parser = new SPARQLParser();
ParsedQuery pq1 = parser.parseQuery(query1, null);
ParsedQuery pq2 = parser.parseQuery(query2, null);
TupleExpr te1 = pq1.getTupleExpr();
TupleExpr te2 = pq2.getTupleExpr();
LeftJoin join1 = (LeftJoin) ((Projection) te1).getArg();
LeftJoin join2 = (LeftJoin) ((Projection) te2).getArg();
QuerySegment<ExternalTupleSet> seg1 = qFactory.getQuerySegment(join1);
QuerySegment<ExternalTupleSet> seg2 = qFactory.getQuerySegment(join2);
QueryNodeConsolidator consolidator = new QueryNodeConsolidator(seg1.getOrderedNodes(), seg2.getOrderedNodes());
List<QueryModelNode> queryNodes = new ArrayList<>(seg2.getOrderedNodes());
Assert.assertTrue(consolidator.consolidateNodes());
Assert.assertEquals(consolidator.getQueryNodes(), queryNodes);
}
开发者ID:apache,项目名称:incubator-rya,代码行数:39,代码来源:PCJNodeConsolidatorTest.java
示例19: 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()), GeoParseUtils.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");
}
}
}
开发者ID:apache,项目名称:incubator-rya,代码行数:14,代码来源:GeoEnabledFilterFunctionOptimizer.java
示例20: meet
import org.openrdf.query.algebra.LeftJoin; //导入依赖的package包/类
@Override
public void meet(final LeftJoin n) {
final TupleExpr l = n.getLeftArg();
final TupleExpr r = n.getCondition() == null ? n.getRightArg() : //
new Filter(n.getRightArg(), n.getCondition());
emit(l);
if (!(l instanceof SingletonSet)) {
newline();
}
emit("OPTIONAL ").emit(r, true);
}
开发者ID:dkmfbk,项目名称:knowledgestore,代码行数:12,代码来源:SPARQLRenderer.java
注:本文中的org.openrdf.query.algebra.LeftJoin类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论