/** * Match a pattern just against the stored data (raw data, schema, * axioms) but no derivation. */ @Override public ExtendedIterator<Triple> findDataMatches(TriplePattern pattern) { return dataFind.find(pattern); }
/** * 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 (second == null) { return first.find(pattern); } else if (first == null) { return second.find(pattern); } else { return first.findWithContinuation(pattern, second); } }
/** * Search the combination of data and deductions graphs for the given triple pattern. * This may different from the normal find operation in the base of hybrid reasoners * where we are side-stepping the backward deduction step. */ @Override public ExtendedIterator<Triple> findDataMatches(TriplePattern pattern) { return dataFind.find(pattern); }
/** * 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 (second == null) { return first.find(pattern); } else if (first == null) { return second.find(pattern); } else { return first.findWithContinuation(pattern, second); } }
/** * Match a pattern just against the stored data (raw data, schema, * axioms) but no derivation. */ @Override public ExtendedIterator<Triple> findDataMatches(TriplePattern pattern) { return dataFind.find(pattern); }
/** * Search the combination of data and deductions graphs for the given triple pattern. * This may different from the normal find operation in the base of hybrid reasoners * where we are side-stepping the backward deduction step. */ @Override public ExtendedIterator<Triple> findDataMatches(TriplePattern pattern) { return dataFind.find(pattern); }
/** * Search the combination of data and deductions graphs for the given triple pattern. * This may different from the normal find operation in the base of hybrid reasoners * where we are side-stepping the backward deduction step. */ @Override public ExtendedIterator<Triple> findDataMatches(Node subject, Node predicate, Node object) { return dataFind.find(new TriplePattern(subject, predicate, object)); }
/** * Search the combination of data and deductions graphs for the given triple pattern. * This may different from the normal find operation in the base of hybrid reasoners * where we are side-stepping the backward deduction step. */ @Override public ExtendedIterator<Triple> findDataMatches(Node subject, Node predicate, Node object) { return dataFind.find(new TriplePattern(subject, predicate, object)); }
/** * Extended find interface used in situations where the implementator * may or may not be able to answer the complete query. It will * attempt to answer the pattern but if its answers are not known * to be complete then it will also pass the request on to the nested * Finder to append more results. * @param pattern a TriplePattern to be matched against the data * @param continuation either a Finder or a normal Graph which * will be asked for additional match results if the implementor * may not have completely satisfied the query. */ @Override public ExtendedIterator<Triple> findWithContinuation(TriplePattern pattern, Finder continuation) { return (FinderUtil.cascade(first, second, continuation)).find(pattern); }
/** * Extended find interface used in situations where the implementator * may or may not be able to answer the complete query. It will * attempt to answer the pattern but if its answers are not known * to be complete then it will also pass the request on to the nested * Finder to append more results. * @param pattern a TriplePattern to be matched against the data * @param continuation either a Finder or a normal Graph which * will be asked for additional match results if the implementor * may not have completely satisfied the query. */ @Override public ExtendedIterator<Triple> findWithContinuation(TriplePattern pattern, Finder continuation) { return (FinderUtil.cascade(first, second, continuation)).find(pattern); }
/** * Helper - returns the (singleton) value for the given property on the given * root node in the data graph. */ public static Node getPropValue(Node root, Node prop, Finder context) { return doGetPropValue(context.find(new TriplePattern(root, prop, null))); }
/** * Helper - returns the (singleton) value for the given property on the given * root node in the data graph. */ public static Node getPropValue(Node root, Node prop, Finder context) { return doGetPropValue(context.find(new TriplePattern(root, prop, null))); }
/** * Extended find interface used in situations where the implementator * may or may not be able to answer the complete query. It will * attempt to answer the pattern but if its answers are not known * to be complete then it will also pass the request on to the nested * Finder to append more results. * @param pattern a TriplePattern to be matched against the data * @param continuation either a Finder or a normal Graph which * will be asked for additional match results if the implementor * may not have completely satisfied the query. */ @Override public ExtendedIterator<Triple> findWithContinuation(TriplePattern pattern, Finder continuation) { checkOpen(); this.requirePrepared(); Finder cascade = transitiveEngine.getFinder(pattern, FinderUtil.cascade(tbox, continuation)); return cascade.find(pattern).filterKeep( new UniqueFilter<Triple>()); }
/** * Cache all instances of the given predicate which are * present in the given Graph. * @param graph the searchable set of triples to cache * @param predicate the predicate to cache, need not be the registered * predicate due to subProperty declarations * @return returns true if new information has been cached */ public boolean cacheAll(Finder graph, Node predicate) { ExtendedIterator<Triple> it = graph.find(new TriplePattern(null, predicate, null)); boolean foundsome = it.hasNext(); while (it.hasNext()) { addRelation(it.next()); } it.close(); return foundsome; }
/** * Cache all instances of the given predicate which are * present in the given Graph. * @param graph the searchable set of triples to cache * @param predicate the predicate to cache, need not be the registered * predicate due to subProperty declarations * @return returns true if new information has been cached */ public boolean cacheAll(Finder graph, Node predicate) { ExtendedIterator<Triple> it = graph.find(new TriplePattern(null, predicate, null)); boolean foundsome = it.hasNext(); while (it.hasNext()) { addRelation(it.next()); } it.close(); return foundsome; }
/** * Extended find interface used in situations where the implementator * may or may not be able to answer the complete query. It will * attempt to answer the pattern but if its answers are not known * to be complete then it will also pass the request on to the nested * Finder to append more results. * @param pattern a TriplePattern to be matched against the data * @param continuation either a Finder or a normal Graph which * will be asked for additional match results if the implementor * may not have completely satisfied the query. */ @Override public ExtendedIterator<Triple> findWithContinuation(TriplePattern pattern, Finder continuation) { checkOpen(); this.requirePrepared(); Finder cascade = transitiveEngine.getFinder(pattern, FinderUtil.cascade(tbox, continuation)); return cascade.find(pattern).filterKeep( new UniqueFilter<Triple>()); }
/** * Extended find interface used in situations where the implementator * may or may not be able to answer the complete query. It will * attempt to answer the pattern but if its answers are not known * to be complete then it will also pass the request on to the nested * Finder to append more results. * @param pattern a TriplePattern to be matched against the data * @param continuation either a Finder or a normal Graph which * will be asked for additional match results if the implementor * may not have completely satisfied the query. */ @Override public ExtendedIterator<Triple> findWithContinuation(TriplePattern pattern, Finder continuation) { if (graph == null) return new NullIterator<>(); if (continuation == null) { return graph.find(pattern.asTripleMatch()); } else { return graph.find(pattern.asTripleMatch()).andThen(continuation.find(pattern)); } }
/** * Extended find interface used in situations where the implementator * may or may not be able to answer the complete query. It will * attempt to answer the pattern but if its answers are not known * to be complete then it will also pass the request on to the nested * Finder to append more results. * @param pattern a TriplePattern to be matched against the data * @param continuation either a Finder or a normal Graph which * will be asked for additional match results if the implementor * may not have completely satisfied the query. */ @Override public synchronized ExtendedIterator<Triple> findWithContinuation(TriplePattern pattern, Finder continuation) { checkOpen(); this.requirePrepared(); ExtendedIterator<Triple> result = engine.find(pattern).filterKeep( new UniqueFilter<Triple>()); if (continuation != null) { result = result.andThen(continuation.find(pattern)); } return result.filterDrop(Functor.acceptFilter); }
@Override public ExtendedIterator<Triple> findWithContinuation(final TriplePattern pattern, final Finder finder) { prepare(); final Node subject = pattern.getSubject(); final Node predicate = pattern.getPredicate(); final Node object = pattern.getObject(); ExtendedIterator<Triple> i = GraphQueryHandler.findTriple(_kb, this, subject, predicate, object); final ATerm predicateTerm = predicate.isURI() ? ATermUtils.makeTermAppl(predicate.getURI()) : null; // look at asserted triples at the _end but only for annotation properties, other triples should be inferred if (finder != null && (predicateTerm == null || !_kb.isObjectProperty(predicateTerm) && !_kb.isDatatypeProperty(predicateTerm))) { final TriplePattern tp = new TriplePattern(subject, predicate, object); i = i.andThen(finder.find(tp)); } // make sure we don't have duplicates return i.filterKeep(new UniqueFilter<Triple>()); }
@Override public ExtendedIterator<Triple> findWithContinuation(final TriplePattern pattern, final Finder finder) { prepare(); final Node subject = pattern.getSubject(); final Node predicate = pattern.getPredicate(); final Node object = pattern.getObject(); ExtendedIterator<Triple> i = GraphQueryHandler.findTriple(_kb, this, subject, predicate, object); final ATerm predicateTerm = predicate.isURI() ? ATermUtils.makeTermAppl(predicate.getURI()) : null; // look at asserted triples at the _end but only for annotation properties, other triples should be inferred if (finder != null && (predicateTerm == null || !_kb.isObjectProperty(predicateTerm) && !_kb.isDatatypeProperty(predicateTerm))) { final TriplePattern tp = new TriplePattern(subject, predicate, object); i = i.andThen(finder.find(tp)); } // make sure we don't have duplicates return i.filterKeep(new UniqueFilter<Triple>()); }