/** * 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))); }
/** * Process all available data. This version expects that all the axioms * have already be preprocessed and the clause index already exists. * @param inserts the set of triples to be processed, normally this is the * raw data graph but may include additional deductions made by preprocessing hooks */ @Override public void fastInit(Finder inserts) { findAndProcessActions(); // Create the reasoning context BFRuleContext context = new BFRuleContext(infGraph); // Insert the data if (wildcardRule) { for (Iterator<Triple> i = inserts.find(new TriplePattern(null, null, null)); i.hasNext(); ) { context.addTriple(i.next()); } } else { for ( Node predicate : predicatesUsed ) { for ( Iterator<Triple> i = inserts.find( new TriplePattern( null, predicate, null ) ); i.hasNext(); ) { context.addTriple( i.next() ); } } } // Run the engine addSet(context); }
/** * Process all available data. This version expects that all the axioms * have already be preprocessed and the clause index already exists. * @param inserts the set of triples to be processed, normally this is the * raw data graph but may include additional deductions made by preprocessing hooks */ @Override public void fastInit(Finder inserts) { findAndProcessActions(); // Create the reasoning context BFRuleContext context = new BFRuleContext(infGraph); // Insert the data if (wildcardRule) { for (Iterator<Triple> i = inserts.find(new TriplePattern(null, null, null)); i.hasNext(); ) { context.addTriple(i.next()); } } else { for ( Node predicate : predicatesUsed ) { for ( Iterator<Triple> i = inserts.find( new TriplePattern( null, predicate, null ) ); i.hasNext(); ) { context.addTriple( i.next() ); } } } // Run the engine addSet(context); }
for (Iterator<Triple> i = inserts.find(new TriplePattern(null, null, null)); i.hasNext(); ) { addTriple( i.next(), false ); for (Map.Entry<Node, Node> ent : predicatePatterns.entrySet()) { for (Iterator<Triple> i = inserts.find(new TriplePattern(null, ent.getKey(), ent.getValue())); i.hasNext(); ) { Triple t = i.next(); addTriple(t, false);
for (Iterator<Triple> i = inserts.find(new TriplePattern(null, null, null)); i.hasNext(); ) { addTriple( i.next(), false ); for (Map.Entry<Node, Node> ent : predicatePatterns.entrySet()) { for (Iterator<Triple> i = inserts.find(new TriplePattern(null, ent.getKey(), ent.getValue())); i.hasNext(); ) { Triple t = i.next(); addTriple(t, false);
/** * Extended find interface used in situations where the implementator * may or may not be able to answer the complete query. * <p> * In this case any query on the direct or closed predicates will * be assumed complete, any other query will pass on to the continuation.</p> * @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) { Node p = pattern.getPredicate(); if (p.isVariable()) { // wildcard predicate so return merge of cache and continuation return find(pattern).andThen(continuation.find(pattern)); } else if (p.equals(directPredicate) || p.equals(closedPredicate)) { // Satisfy entire query from the cache return find(pattern); } else { // No matching triples in this cache so just search the continuation return continuation.find(pattern); } }
/** * Extended find interface used in situations where the implementator * may or may not be able to answer the complete query. * <p> * In this case any query on the direct or closed predicates will * be assumed complete, any other query will pass on to the continuation.</p> * @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) { Node p = pattern.getPredicate(); if (p.isVariable()) { // wildcard predicate so return merge of cache and continuation return find(pattern).andThen(continuation.find(pattern)); } else if (p.equals(directPredicate) || p.equals(closedPredicate)) { // Satisfy entire query from the cache return find(pattern); } else { // No matching triples in this cache so just search the continuation return 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) { 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; }