/** * Create a continuation object which is a cascade of four * continuation objects. * @param first the first Graph/Finder to try * @param second the second Graph/Finder to try * @param third the third Graph/Finder to try * @param fourth the third Graph/Finder to try */ public static Finder cascade(Finder first, Finder second, Finder third, Finder fourth) { return new Cascade(first, cascade(second, cascade(third, fourth))); }
/** * Create a continuation object which is a cascade of four * continuation objects. * @param first the first Graph/Finder to try * @param second the second Graph/Finder to try * @param third the third Graph/Finder to try * @param fourth the third Graph/Finder to try */ public static Finder cascade(Finder first, Finder second, Finder third, Finder fourth) { return new Cascade(first, cascade(second, cascade(third, fourth))); }
/** * Create a continuation object which is a cascade of three * continuation objects. * @param first the first Graph/Finder to try * @param second the second Graph/Finder to try * @param third the third Graph/Finder to try */ public static Finder cascade(Finder first, Finder second, Finder third) { return new Cascade(first, cascade(second, third)); }
/** * Create a continuation object which is a cascade of three * continuation objects. * @param first the first Graph/Finder to try * @param second the second Graph/Finder to try * @param third the third Graph/Finder to try */ public static Finder cascade(Finder first, Finder second, Finder third) { return new Cascade(first, cascade(second, third)); }
/** * 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); }
/** * Return a Finder instance appropriate for the given query. */ public Finder getFinder(TriplePattern pattern, Finder continuation) { if (!isPrepared) prepare(); Node predicate = pattern.getPredicate(); if (predicate.isVariable()) { // Want everything in the cache, the tbox and the continuation return FinderUtil.cascade(subPropertyCache, subClassCache, continuation); } else if (subPropertyAliases.contains(predicate)) { return subPropertyCache; } else if (subClassAliases.contains(predicate)) { return subClassCache; } else { return continuation; } }
/** * Return a Finder instance appropriate for the given query. */ public Finder getFinder(TriplePattern pattern, Finder continuation) { if (!isPrepared) prepare(); Node predicate = pattern.getPredicate(); if (predicate.isVariable()) { // Want everything in the cache, the tbox and the continuation return FinderUtil.cascade(subPropertyCache, subClassCache, continuation); } else if (subPropertyAliases.contains(predicate)) { return subPropertyCache; } else if (subClassAliases.contains(predicate)) { return subClassCache; } else { return continuation; } }
/** * Perform any initial processing and caching. This call is optional. Most * engines either have negligable set up work or will perform an implicit * "prepare" if necessary. The call is provided for those occasions where * substantial preparation work is possible (e.g. running a forward chaining * rule system) and where an application might wish greater control over when * this preparation is done. */ @Override public synchronized void prepare() { if (this.isPrepared()) return; fdeductions = new FGraph( Factory.createGraphMem() ); extractAxioms(); dataFind = fdata; if (fdeductions != null) { dataFind = FinderUtil.cascade(dataFind, fdeductions); } if (fschema != null) { dataFind = FinderUtil.cascade(dataFind, fschema); } this.setPreparedState(true); }
/** * Perform any initial processing and caching. This call is optional. Most * engines either have negligable set up work or will perform an implicit * "prepare" if necessary. The call is provided for those occasions where * substantial preparation work is possible (e.g. running a forward chaining * rule system) and where an application might wish greater control over when * this preparation is done. */ @Override public synchronized void prepare() { if (this.isPrepared()) return; fdeductions = new FGraph( Factory.createGraphMem() ); extractAxioms(); dataFind = fdata; if (fdeductions != null) { dataFind = FinderUtil.cascade(dataFind, fdeductions); } if (fschema != null) { dataFind = FinderUtil.cascade(dataFind, fschema); } this.setPreparedState(true); }
/** * 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) { checkOpen(); this.requirePrepared(); Finder cascade = transitiveEngine.getFinder(pattern, FinderUtil.cascade(tbox, continuation)); return cascade.find(pattern).filterKeep( new UniqueFilter<Triple>()); }
/** * Internals of findWithContinuation implementation which allows control * over functor filtering. */ private ExtendedIterator<Triple> findWithContinuation(TriplePattern pattern, Finder continuation, boolean filter) { checkOpen(); this.requirePrepared(); ExtendedIterator<Triple> result = null; if (fdata == null) { result = fdeductions.findWithContinuation(pattern, continuation); } else { if (continuation == null) { result = fdata.findWithContinuation(pattern, fdeductions); } else { result = fdata.findWithContinuation(pattern, FinderUtil.cascade(fdeductions, continuation) ); } } if (filter && filterFunctors) { return result.filterDrop(Functor.acceptFilter); } else { return result; } }
/** * Internals of findWithContinuation implementation which allows control * over functor filtering. */ private ExtendedIterator<Triple> findWithContinuation(TriplePattern pattern, Finder continuation, boolean filter) { checkOpen(); this.requirePrepared(); ExtendedIterator<Triple> result = null; if (fdata == null) { result = fdeductions.findWithContinuation(pattern, continuation); } else { if (continuation == null) { result = fdata.findWithContinuation(pattern, fdeductions); } else { result = fdata.findWithContinuation(pattern, FinderUtil.cascade(fdeductions, continuation) ); } } if (filter && filterFunctors) { return result.filterDrop(Functor.acceptFilter); } else { return result; } }
/** * Prepare the engine by inserting any new data not already included * in the existing caches. * @param baseData the base dataset on which the initial caches were based, could be null * @param newData a dataset to be added to the engine, not known to be already * included in the caches from construction time * @return a concatenation of the inserted data and the original data */ public Finder insert(Finder baseData, FGraph newData) { Graph newDataG = newData.getGraph(); if (baseData != null) { data = FinderUtil.cascade(baseData, newData); } else { data = newData; } if ((TransitiveEngine.checkOccuranceUtility(subPropertyOf, newDataG, subPropertyCache) || TransitiveEngine.checkOccuranceUtility(subClassOf, newDataG, subPropertyCache))) { subClassCache = new TransitiveGraphCache(directSubClassOf, subClassOf); subPropertyCache = new TransitiveGraphCache(directSubPropertyOf, subPropertyOf); TransitiveEngine.cacheSubPropUtility(data, subPropertyCache); TransitiveEngine.cacheSubClassUtility(data, subPropertyCache, subClassCache); } return data; }
/** * Prepare the engine by inserting any new data not already included * in the existing caches. * @param baseData the base dataset on which the initial caches were based, could be null * @param newData a dataset to be added to the engine, not known to be already * included in the caches from construction time * @return a concatenation of the inserted data and the original data */ public Finder insert(Finder baseData, FGraph newData) { Graph newDataG = newData.getGraph(); if (baseData != null) { data = FinderUtil.cascade(baseData, newData); } else { data = newData; } if ((TransitiveEngine.checkOccuranceUtility(subPropertyOf, newDataG, subPropertyCache) || TransitiveEngine.checkOccuranceUtility(subClassOf, newDataG, subPropertyCache))) { subClassCache = new TransitiveGraphCache(directSubClassOf, subClassOf); subPropertyCache = new TransitiveGraphCache(directSubPropertyOf, subPropertyOf); TransitiveEngine.cacheSubPropUtility(data, subPropertyCache); TransitiveEngine.cacheSubClassUtility(data, subPropertyCache, subClassCache); } return data; }
fdeductions = new FGraph( createDeductionsGraph() ); dataFind = (data == null) ? fdeductions : FinderUtil.cascade(fdeductions, fdata); Finder dataSource = fdata; dataFind = FinderUtil.cascade(dataFind, transitiveEngine.getSubClassCache(), transitiveEngine.getSubPropertyCache()); dataSource = FinderUtil.cascade(dataSource, transitiveEngine.getSubClassCache(), transitiveEngine.getSubPropertyCache()); dataSource = FinderUtil.cascade(fdata, finserts); dataFind = FinderUtil.cascade(dataFind, finserts); Graph rawPreload = ((InfGraph)schemaGraph).getRawGraph(); if (rawPreload != null) { dataFind = FinderUtil.cascade(dataFind, new FGraph(rawPreload));
fdeductions = new FGraph( createDeductionsGraph() ); dataFind = (data == null) ? fdeductions : FinderUtil.cascade(fdeductions, fdata); Finder dataSource = fdata; dataFind = FinderUtil.cascade(dataFind, transitiveEngine.getSubClassCache(), transitiveEngine.getSubPropertyCache()); dataSource = FinderUtil.cascade(dataSource, transitiveEngine.getSubClassCache(), transitiveEngine.getSubPropertyCache()); dataSource = FinderUtil.cascade(fdata, finserts); dataFind = FinderUtil.cascade(dataFind, finserts); Graph rawPreload = ((InfGraph)schemaGraph).getRawGraph(); if (rawPreload != null) { dataFind = FinderUtil.cascade(dataFind, new FGraph(rawPreload));