/** * Bind the variables in a goal pattern using the binding environment, to * generate a more specialized goal * @param goal the TriplePattern to be instantiated * @return a TriplePattern obtained from the goal by substituting current bindings */ public TriplePattern partInstantiate(TriplePattern goal) { return new TriplePattern( getGroundVersion(goal.getSubject()), getGroundVersion(goal.getPredicate()), getGroundVersion(goal.getObject()) ); }
/** * Printable string */ @Override public String toString() { return simplePrintString(subject) + " @" + simplePrintString(predicate) + " " + simplePrintString(object); }
/** * Return true if the given pattern occurs somewhere in the find sequence. */ @Override public boolean contains(TriplePattern pattern) { return graph.contains(pattern.getSubject(), pattern.getPredicate(), pattern.getObject()); }
/** * Return an ordered list of RuleClauseCode objects to implement the given * query pattern. This may use indexing to narrow the rule set more that the predicate-only case. * @param goal the triple pattern that makes up the query */ public List<RuleClauseCode> codeFor(TriplePattern goal) { List<RuleClauseCode> allRules = codeFor(goal.getPredicate()); if (allRules == null) { return allRules; } Map<Node, List<RuleClauseCode>> indexedCodeTable = indexPredicateToCodeMap.get(goal.getPredicate()); if (indexedCodeTable != null) { List<RuleClauseCode> indexedCode = indexedCodeTable.get(goal.getObject()); if (indexedCode != null) { return indexedCode; } } return allRules; }
private static TriplePattern makeSubOfSomeTriple(final Node t1, final Node p, final Node t2) { return new TriplePattern(t1, p, t2); }
envFrame.pVars[0] = argVars[0] = standardize(goal.getSubject(), mappedVars); envFrame.pVars[1] = argVars[1] = standardize(goal.getPredicate(), mappedVars); envFrame.pVars[2] = argVars[2] = standardize(goal.getObject(), mappedVars); if (engine.getDerivationLogging()) { ((EnvironmentFrameWithDerivation)envFrame).initDerivationRecord(argVars); setupClauseCall(0, 0, clauses, goal.isGround());
/** * Return true if the given goal is tabled, currently this is true if the * predicate is a tabled predicate or the predicate is a wildcard and some * tabled predicates exist. */ public boolean isTabled(TriplePattern goal) { return isTabled(goal.getPredicate()); }
TriplePattern query = tripleToPattern( queries.next() ); logger.debug("Query: " + query); Iterator<Triple> answers = graph.find(query.asTripleMatch()); while (answers.hasNext()) { Triple ans = answers.next(); logger.debug("ans: " + TriplePattern.simplePrintString(ans)); resultG.add(ans);
/** * Basic pattern lookup interface. * @param pattern a TriplePattern to be matched against the data * @return a ClosableIterator over all Triples in the data set * that match the pattern */ @Override public ExtendedIterator<Triple> find(TriplePattern pattern) { if (graph == null) return new NullIterator<>(); return graph.find(pattern.asTripleMatch()); }
if ( axiom instanceof TriplePattern ) axioms.add( ( (TriplePattern) axiom ).asTriple() );
/** * Return true if the given pattern occurs somewhere in the find sequence. */ @Override public boolean contains(TriplePattern pattern) { return graph.contains(pattern.getSubject(), pattern.getPredicate(), pattern.getObject()); }
private static TriplePattern makeSubclassTriple(final Node t1, final Node t2) { return new TriplePattern(t1, PRED_SUB, t2); }
envFrame.pVars[0] = argVars[0] = standardize(goal.getSubject(), mappedVars); envFrame.pVars[1] = argVars[1] = standardize(goal.getPredicate(), mappedVars); envFrame.pVars[2] = argVars[2] = standardize(goal.getObject(), mappedVars); if (engine.getDerivationLogging()) { ((EnvironmentFrameWithDerivation)envFrame).initDerivationRecord(argVars); setupClauseCall(0, 0, clauses, goal.isGround());
/** * Return true if the given goal is tabled, currently this is true if the * predicate is a tabled predicate or the predicate is a wildcard and some * tabled predicates exist. */ public boolean isTabled(TriplePattern goal) { return isTabled(goal.getPredicate()); }
/** * Return an ordered list of RuleClauseCode objects to implement the given * query pattern. This may use indexing to narrow the rule set more that the predicate-only case. * @param goal the triple pattern that makes up the query */ public List<RuleClauseCode> codeFor(TriplePattern goal) { List<RuleClauseCode> allRules = codeFor(goal.getPredicate()); if (allRules == null) { return allRules; } Map<Node, List<RuleClauseCode>> indexedCodeTable = indexPredicateToCodeMap.get(goal.getPredicate()); if (indexedCodeTable != null) { List<RuleClauseCode> indexedCode = indexedCodeTable.get(goal.getObject()); if (indexedCode != null) { return indexedCode; } } return allRules; }
TriplePattern query = tripleToPattern( queries.next() ); logger.debug("Query: " + query); Iterator<Triple> answers = graph.find(query.asTripleMatch()); while (answers.hasNext()) { Triple ans = answers.next(); logger.debug("ans: " + TriplePattern.simplePrintString(ans)); resultG.add(ans);
/** * Basic pattern lookup interface. * @param pattern a TriplePattern to be matched against the data * @return a ClosableIterator over all Triples in the data set * that match the pattern */ @Override public ExtendedIterator<Triple> find(TriplePattern pattern) { if (graph == null) return new NullIterator<>(); return graph.find(pattern.asTripleMatch()); }
if ( axiom instanceof TriplePattern ) axioms.add( ( (TriplePattern) axiom ).asTriple() );
/** * Return the argument index of the given variable. */ int aIndex(Node n) { TriplePattern tp = (TriplePattern)rule.getHeadElement(0); if (tp.getSubject() == n) { return 0; } else if (tp.getPredicate() == n) { return 1; } else if (tp.getObject() == n) { return 2; } else { return -1; } }
/** * Bind the variables in a goal pattern using the binding environment, to * generate a more specialized goal * @param goal the TriplePattern to be instantiated * @return a TriplePattern obtained from the goal by substituting current bindings */ public TriplePattern partInstantiate(TriplePattern goal) { return new TriplePattern( getGroundVersion(goal.getSubject()), getGroundVersion(goal.getPredicate()), getGroundVersion(goal.getObject()) ); }