org.eclipse.rdf4j.query.algebra.QueryModelNode Java Examples
The following examples show how to use
org.eclipse.rdf4j.query.algebra.QueryModelNode.
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: ValidIndexCombinationGenerator.java From rya with Apache License 2.0 | 6 votes |
private int indicesDisjoint(List<Integer> combo, List<ExternalTupleSet> indexList) { Set<QueryModelNode> indexNodes = Sets.newHashSet(); Set<QueryModelNode> tempNodes; TupleExpr temp; int j = 0; for (Integer i : combo) { temp = indexList.get(i).getTupleExpr(); SpFilterCollector spf = new SpFilterCollector(); temp.visit(spf); tempNodes = spf.getSpFilterSet(); if (Sets.intersection(indexNodes, tempNodes).size() == 0) { indexNodes = Sets.union(indexNodes, tempNodes); if (indexNodes.size() > spFilterSet.size()) { return j; } } else { return j; } j++; } return -1; }
Example #2
Source File: StatementMetadataExternalSetProviderTest.java From rya with Apache License 2.0 | 6 votes |
@Test public void createSingleAccumuloMetadataNode() throws MalformedQueryException { AccumuloRdfConfiguration conf = (AccumuloRdfConfiguration) getConf(false); Set<RyaIRI> propertySet = new HashSet<>(); propertySet.add(new RyaIRI("http://createdBy")); conf.setStatementMetadataProperties(propertySet); StatementMetadataExternalSetProvider metaProvider = new StatementMetadataExternalSetProvider( conf); SPARQLParser parser = new SPARQLParser(); ParsedQuery pq = parser.parseQuery(query, null); List<QueryModelNode> patterns = new ArrayList<>(); List<StatementMetadataNode<?>> expected = new ArrayList<>(); Set<StatementPattern> sp = StatementMetadataTestUtils.getMetadataStatementPatterns(pq.getTupleExpr(), propertySet); patterns.addAll(StatementPatternCollector.process(pq.getTupleExpr())); JoinSegment<StatementMetadataNode<?>> segment = new JoinSegment<>( new HashSet<>(patterns), patterns, new HashMap<ValueExpr, Filter>()); List<StatementMetadataNode<?>> extSets = metaProvider.getExternalSets(segment); expected.add(new StatementMetadataNode<>(sp, conf)); Assert.assertEquals(expected, extSets); }
Example #3
Source File: TupleExecutionPlanGenerator.java From rya with Apache License 2.0 | 6 votes |
private List<TupleExpr> getPlans(final TupleExpr te) { final NodeCollector nc = new NodeCollector(); te.visit(nc); final Set<QueryModelNode> nodeSet = nc.getNodeSet(); final List<Filter> filterList = nc.getFilterSet(); final Projection projection = nc.getProjection().clone(); final List<TupleExpr> queryPlans = Lists.newArrayList(); final Collection<List<QueryModelNode>> plans = Collections2.permutations(nodeSet); for (final List<QueryModelNode> p : plans) { if (p.size() == 0) { throw new IllegalArgumentException("Tuple must contain at least one node!"); } else if (p.size() == 1) { queryPlans.add(te); } else { queryPlans.add(buildTuple(p, filterList, projection)); } } return queryPlans; }
Example #4
Source File: GeneralizedExternalProcessor.java From rya with Apache License 2.0 | 6 votes |
@Override public void meet(Filter node) { Set<QueryModelNode> eSet = getQNodes(node); if (eSet.containsAll(sSet)) { if (eSet.equals(sSet)) { node.replaceWith(set); indexPlaced = true; return; } else { node.getArg().visit(this); } } }
Example #5
Source File: AbstractExternalSetOptimizer.java From rya with Apache License 2.0 | 6 votes |
@Override public void meetNode(QueryModelNode node) { if (checkNode(node)) { QuerySegment<T> segment = factory.getQuerySegment(node); ExternalSetProvider<T> provider = getProvider(); ExternalSetMatcher<T> matcher = getMatcher(segment); QuerySegment<T> tempSeg = null; if(useOptimal) { tempSeg = matcher.match(provider.getExternalSetCombos(segment), getNodeListRater(segment)); } else { tempSeg = matcher.match(provider.getExternalSets(segment)); } TupleExprAndNodes tups = tempSeg.getQuery(); node.replaceWith(tups.getTupleExpr()); Set<TupleExpr> unmatched = getUnMatchedArgNodes(tups.getNodes()); PCJOptimizerUtilities.relocateFilters(tups.getFilters()); for (final TupleExpr tupleExpr : unmatched) { tupleExpr.visit(this); } } else { super.meetNode(node); } }
Example #6
Source File: JoinSegment.java From rya with Apache License 2.0 | 6 votes |
/** * * @param tupleExpr * - the query object that will be traversed by this method * @param joinArgs * - all nodes connected by Joins and Filters * @return - List containing all nodes connected by Joins, LeftJoins, and * Filters. This List contains the * @param ValueExpr * in place of the Filter */ 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 Filter) { Filter filter = (Filter) tupleExpr; joinArgs.add(filter.getCondition()); conditionMap.put(filter.getCondition(), filter); getJoinArgs(filter.getArg(), joinArgs); } else { joinArgs.add(tupleExpr); } return joinArgs; }
Example #7
Source File: QuerySegmentFactory.java From rya with Apache License 2.0 | 6 votes |
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"); } }
Example #8
Source File: JoinSegment.java From rya with Apache License 2.0 | 6 votes |
/** * This method matches the ordered nodes returned by * {@link JoinSegment#getOrderedNodes()} for nodeToReplace with a subset of * the ordered nodes for this JoinSegment. The order of the nodes for * nodeToReplace must match the order of the nodes as a subset of * orderedNodes * * @param nodeToReplace * - nodes to be replaced by pcj * @param pcj * - pcj node that will replace specified query nodes */ @Override public boolean replaceWithExternalSet(QuerySegment<T> nodeToReplace, T set) { Preconditions.checkNotNull(nodeToReplace); Preconditions.checkNotNull(set); if (!containsQuerySegment(nodeToReplace)) { return false; } Set<QueryModelNode> nodeSet = nodeToReplace.getUnOrderedNodes(); orderedNodes.removeAll(nodeSet); orderedNodes.add(set); unorderedNodes.removeAll(nodeSet); unorderedNodes.add(set); for (QueryModelNode q : nodeSet) { if (q instanceof ValueExpr) { conditionMap.remove(q); } } return true; }
Example #9
Source File: PeriodicQueryUtil.java From rya with Apache License 2.0 | 6 votes |
@Override public void meetOther(QueryModelNode node) { if (node instanceof PeriodicQueryNode) { PeriodicQueryNode pNode = (PeriodicQueryNode) node; // do nothing if PeriodicQueryNode already positioned correctly if (pNode.equals(relocationParent.getArg())) { return; } // remove node from query pNode.replaceWith(pNode.getArg()); // set node' child to be relocationParent's child pNode.setArg(relocationParent.getArg()); // add node back into query below relocationParent relocationParent.replaceChildNode(relocationParent.getArg(), pNode); } }
Example #10
Source File: FilterOptimizer.java From CostFed with GNU Affero General Public License v3.0 | 6 votes |
@Override public void meetOther(QueryModelNode node) { if (node instanceof FilterTuple) { handleFilter((FilterTuple)node, filterExpr); } else if (node instanceof StatementTupleExpr) { // TODO check if we still can remove!!! } else { // TODO we maybe have to adjust canRemove here super.meetOther(node); } }
Example #11
Source File: OrderLimitOptimizer.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void meet(Order node) { for (OrderElem e : node.getElements()) { e.visit(this); } if (variablesProjected) { QueryModelNode parent = node.getParentNode(); if (projection == parent) { node.replaceWith(node.getArg().clone()); node.setArg(projection.clone()); Order replacement = node.clone(); projection.replaceWith(replacement); QueryModelNode distinct = replacement.getParentNode(); if (distinct instanceof Distinct) { distinct.replaceWith(new Reduced(replacement.clone())); } } } }
Example #12
Source File: GeneralizedExternalProcessor.java From rya with Apache License 2.0 | 6 votes |
private static boolean isTupleValid(QueryModelNode node) { ValidQueryVisitor vqv = new ValidQueryVisitor(); node.visit(vqv); Set<String> spVars = getVarNames(getQNodes("sp", node)); if (vqv.isValid() && spVars.size() > 0) { FilterCollector fvis = new FilterCollector(); node.visit(fvis); List<QueryModelNode> fList = fvis.getFilters(); return fList.size() == Sets.newHashSet(fList).size() && getVarNames(fList).size() <= spVars.size(); } else { return false; } }
Example #13
Source File: StatementMetadataExternalSetProviderTest.java From rya with Apache License 2.0 | 6 votes |
@Test public void createSingleMongoMetadataNode() throws MalformedQueryException { MongoDBRdfConfiguration conf = (MongoDBRdfConfiguration) getConf(true); Set<RyaIRI> propertySet = new HashSet<>(); propertySet.add(new RyaIRI("http://createdBy")); conf.setStatementMetadataProperties(propertySet); StatementMetadataExternalSetProvider metaProvider = new StatementMetadataExternalSetProvider(conf); SPARQLParser parser = new SPARQLParser(); ParsedQuery pq = parser.parseQuery(query, null); List<QueryModelNode> patterns = new ArrayList<>(); List<StatementMetadataNode<?>> expected = new ArrayList<>(); Set<StatementPattern> sp = StatementMetadataTestUtils.getMetadataStatementPatterns(pq.getTupleExpr(), propertySet); patterns.addAll(StatementPatternCollector.process(pq.getTupleExpr())); JoinSegment<StatementMetadataNode<?>> segment = new JoinSegment<>( new HashSet<>(patterns), patterns, new HashMap<ValueExpr, Filter>()); List<StatementMetadataNode<?>> extSets = metaProvider.getExternalSets(segment); expected.add(new StatementMetadataNode<>(sp,conf)); Assert.assertEquals(expected, extSets); }
Example #14
Source File: SparqlFluoQueryBuilder.java From rya with Apache License 2.0 | 5 votes |
@Override public void meetOther(final QueryModelNode node) throws Exception { if (node instanceof PeriodicQueryNode) { queryType = QueryType.PERIODIC; } else { super.meetOther(node); } }
Example #15
Source File: StatementMetadataExternalSetProviderTest.java From rya with Apache License 2.0 | 5 votes |
@Test public void createMultipleMetadataNode() throws MalformedQueryException { MongoDBRdfConfiguration conf = (MongoDBRdfConfiguration) getConf(true); Set<RyaIRI> propertySet = new HashSet<>(); propertySet.add(new RyaIRI("http://createdBy")); propertySet.add(new RyaIRI("http://createdOn")); conf.setStatementMetadataProperties(propertySet); StatementMetadataExternalSetProvider metaProvider = new StatementMetadataExternalSetProvider(conf); SPARQLParser parser = new SPARQLParser(); ParsedQuery pq2 = parser.parseQuery(query2, null); ParsedQuery pq3 = parser.parseQuery(query3, null); ParsedQuery pq1 = parser.parseQuery(query, null); List<QueryModelNode> patterns = new ArrayList<>(); List<StatementMetadataNode<?>> expected = new ArrayList<>(); Set<StatementPattern> sp1 = StatementMetadataTestUtils.getMetadataStatementPatterns(pq1.getTupleExpr(), propertySet); Set<StatementPattern> sp3 = StatementMetadataTestUtils.getMetadataStatementPatterns(pq3.getTupleExpr(), propertySet); //added extra blankNode into query3 to make blankNode names line up with query2. Need to remove it now so that //StatementMetadataNode doesn't blow up because all subjects aren't the same. removePatternWithGivenSubject(VarNameUtils.prependAnonymous("1"), sp3); patterns.addAll(StatementPatternCollector.process(pq2.getTupleExpr())); JoinSegment<StatementMetadataNode<?>> segment = new JoinSegment<>( new HashSet<>(patterns), patterns, new HashMap<ValueExpr, Filter>()); List<StatementMetadataNode<?>> extSets = metaProvider.getExternalSets(segment); expected.add(new StatementMetadataNode<>(sp1,conf)); expected.add(new StatementMetadataNode<>(sp3,conf)); Assert.assertEquals(expected, extSets); }
Example #16
Source File: OptionalJoinSegment.java From rya with Apache License 2.0 | 5 votes |
@Override public OptionalJoinSegment<T> clone() { List<QueryModelNode> order = new ArrayList<>(); for(QueryModelNode node: orderedNodes) { order.add(node.clone()); } Set<QueryModelNode> unorder = Sets.newHashSet(order); Map<ValueExpr, Filter> map = new HashMap<>(); for(ValueExpr expr: conditionMap.keySet()) { map.put(expr.clone(), conditionMap.get(expr).clone()); } return new OptionalJoinSegment<T>(unorder, order, map); }
Example #17
Source File: QueryModelTreeToGenericPlanNode.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void meetNode(QueryModelNode node) { GenericPlanNode genericPlanNode = new GenericPlanNode(node.getSignature()); genericPlanNode.setCostEstimate(node.getCostEstimate()); genericPlanNode.setResultSizeEstimate(node.getResultSizeEstimate()); genericPlanNode.setResultSizeActual(node.getResultSizeActual()); if (node instanceof VariableScopeChange) { boolean newScope = ((VariableScopeChange) node).isVariableScopeChange(); genericPlanNode.setNewScope(newScope); } if (node instanceof BinaryTupleOperator) { String algorithmName = ((BinaryTupleOperator) node).getAlgorithmName(); genericPlanNode.setAlgorithm(algorithmName); } // convert from nanoseconds to milliseconds genericPlanNode.setTotalTimeActual(node.getTotalTimeNanosActual() / 1_000_000.0); if (node == topTupleExpr) { top = genericPlanNode; } if (!deque.isEmpty()) { GenericPlanNode genericParentNode = deque.getLast(); genericParentNode.addPlans(genericPlanNode); } deque.addLast(genericPlanNode); super.meetNode(node); deque.removeLast(); }
Example #18
Source File: FilterIterator.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
private boolean isPartOfSubQuery(QueryModelNode node) { if (node instanceof SubQueryValueOperator) { return true; } QueryModelNode parent = node.getParentNode(); if (parent == null) { return false; } else { return isPartOfSubQuery(parent); } }
Example #19
Source File: QueryModelTreePrinter.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void meetNode(QueryModelNode node) { for (int i = 0; i < indentLevel; i++) { sb.append(indentString); } sb.append(node.getSignature()); if (node instanceof VariableScopeChange) { if (((VariableScopeChange) node).isVariableScopeChange()) { sb.append(" (new scope)"); } } if (node instanceof BinaryTupleOperator) { String algorithmName = ((BinaryTupleOperator) node).getAlgorithmName(); if (algorithmName != null) { sb.append(" (").append(algorithmName).append(")"); } } appendCostAnnotation(node, sb); sb.append(LINE_SEPARATOR); indentLevel++; super.meetNode(node); indentLevel--; }
Example #20
Source File: AbstractExternalSetOptimizer.java From rya with Apache License 2.0 | 5 votes |
private Set<TupleExpr> getUnMatchedArgNodes(List<QueryModelNode> nodes) { Set<TupleExpr> unmatched = new HashSet<>(); for (final QueryModelNode q : nodes) { if (q instanceof UnaryTupleOperator || q instanceof BinaryTupleOperator) { unmatched.add((TupleExpr) q); } else if (q instanceof FlattenedOptional) { FlattenedOptional opt = (FlattenedOptional) q; TupleExpr rightArg = opt.getRightArg(); if (rightArg instanceof UnaryTupleOperator || rightArg instanceof BinaryTupleOperator) { unmatched.add(rightArg); } } } return unmatched; }
Example #21
Source File: OptionalJoinSegmentPCJMatcherTest.java From rya with Apache License 2.0 | 5 votes |
@Override public void meetNode(QueryModelNode node) { if(node instanceof ExternalTupleSet) { nodes.add(node); } super.meetNode(node); }
Example #22
Source File: AbstractQuerySegment.java From rya with Apache License 2.0 | 5 votes |
/** * Allows nodes to be reordered using {@link ExternalSetMatcher} and set * * @param nodes * - reordering of orderedNodes */ @Override public void setNodes(List<QueryModelNode> nodes) { Set<QueryModelNode> nodeSet = Sets.newHashSet(nodes); Preconditions.checkArgument(nodeSet.equals(unorderedNodes)); orderedNodes = nodes; unorderedNodes = nodeSet; }
Example #23
Source File: HalyardTupleExprEvaluation.java From Halyard with Apache License 2.0 | 5 votes |
/** * Determines if a {@link QueryModelNode} is a {@link SubQueryValueOperator} or if it's parent node is * @param node * @return */ private boolean isPartOfSubQuery(QueryModelNode node) { if (node instanceof SubQueryValueOperator) { return true; } QueryModelNode parent = node.getParentNode(); if (parent == null) { return false; } else { return isPartOfSubQuery(parent); } }
Example #24
Source File: PCJNodeConsolidatorTest.java From rya with Apache License 2.0 | 5 votes |
@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); }
Example #25
Source File: SparqlFluoQueryBuilder.java From rya with Apache License 2.0 | 5 votes |
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; }
Example #26
Source File: ThetaJoinPredicate.java From semagrow with Apache License 2.0 | 5 votes |
public void replaceWith(Quantifier.Var v1, ValueExpr e) { theta.visit(new AbstractQueryModelVisitor<RuntimeException>() { @Override public void meetNode(QueryModelNode node) throws RuntimeException { if (node instanceof Quantifier.Var) { Quantifier.Var v = (Quantifier.Var)node; if (v.equals(v1)) node.replaceWith(e); } super.meetNode(node); } }); }
Example #27
Source File: SparqlFluoQueryBuilder.java From rya with Apache License 2.0 | 5 votes |
private void makeJoinMetadata(final String joinNodeId, final JoinType joinType, final QueryModelNode left, final QueryModelNode right) { final String leftChildNodeId = nodeIds.getOrMakeId(left); final String rightChildNodeId = nodeIds.getOrMakeId(right); // Get or create a builder for this node populated with the known metadata. JoinMetadata.Builder joinBuilder = fluoQueryBuilder.getJoinBuilder(joinNodeId).orNull(); if(joinBuilder == null) { joinBuilder = JoinMetadata.builder(joinNodeId); fluoQueryBuilder.addJoinMetadata(joinBuilder); } joinBuilder.setJoinType(joinType); joinBuilder.setLeftChildNodeId( leftChildNodeId ); joinBuilder.setRightChildNodeId( rightChildNodeId ); if(fluoQueryBuilder.getQueryBuilder().getJoinBatchSize().isPresent()) { joinBuilder.setJoinBatchSize(fluoQueryBuilder.getQueryBuilder().getJoinBatchSize().get()); } // Figure out the variable order for each child node's binding set and // store it. Also store that each child node's parent is this join. final Set<String> leftVars = getVars((TupleExpr)left); final Set<String> rightVars = getVars((TupleExpr) right); final JoinVarOrders varOrders = getJoinArgVarOrders(leftVars, rightVars); // Create or update the left child's variable order and parent node id. final VariableOrder leftVarOrder = varOrders.getLeftVarOrder(); setChildMetadata(fluoQueryBuilder, leftChildNodeId, leftVarOrder, joinNodeId); // Create or update the right child's variable order and parent node id. final VariableOrder rightVarOrder = varOrders.getRightVarOrder(); setChildMetadata(fluoQueryBuilder, rightChildNodeId, rightVarOrder, joinNodeId); }
Example #28
Source File: GeoTemporalIndexSetProvider.java From rya with Apache License 2.0 | 5 votes |
private void discoverFilter(final FunctionCall filter, final List<QueryModelNode> unmatched) { try { filter.visit(new FilterVisitor()); } catch (final Exception e) { LOG.error("Failed to match the filter object.", e); } }
Example #29
Source File: JoinSegment.java From rya with Apache License 2.0 | 5 votes |
@Override public JoinSegment<T> clone() { List<QueryModelNode> order = new ArrayList<>(); for(QueryModelNode node: orderedNodes) { order.add(node.clone()); } Set<QueryModelNode> unorder = Sets.newHashSet(order); Map<ValueExpr, Filter> map = new HashMap<>(); for(ValueExpr expr: conditionMap.keySet()) { map.put(expr.clone(), conditionMap.get(expr).clone()); } return new JoinSegment<T>(unorder, order, map); }
Example #30
Source File: QueryVariableNormalizer.java From rya with Apache License 2.0 | 5 votes |
private static List<List<String>> filterCommonVars(List<QueryModelNode> vars1, List<QueryModelNode> vars2) { List<List<String>> varList = Lists.newArrayList(); List<String> varList1 = Lists.newArrayList(); List<String> varList2 = Lists.newArrayList(); for (int i = 0; i < vars1.size(); i++) { if ((vars1.get(i) instanceof ValueConstant) && (vars2.get(i) instanceof Var)) { ValueConstant vc = (ValueConstant) vars1.get(i); final String s = VarNameUtils.createUniqueConstVarName(vc.getValue()); varList1.add(s); varList2.add(((Var)vars2.get(i)).getName()); } else if(!(vars1.get(i) instanceof ValueConstant)){ if (!((Var) vars1.get(i)).isConstant() && (vars2.get(i) instanceof Var) && !((Var) vars2.get(i)).isConstant()) { varList1.add(((Var) vars1.get(i)).getName()); varList2.add(((Var) vars2.get(i)).getName()); } else if (((Var) vars1.get(i)).isConstant() && (vars2.get(i) instanceof Var) && !((Var) vars2.get(i)).isConstant()) { varList1.add(((Var) vars1.get(i)).getName()); varList2.add(((Var) vars2.get(i)).getName()); } } } varList.add(varList1); varList.add(varList2); return varList; }