/** Return the number of triples in the inferred graph */ @Override public int graphBaseSize() { checkOpen(); if (!isPrepared) { prepare(); } int baseSize = fdata.getGraph().size(); int dedSize = fdeductions.getGraph().size(); // System.err.println( ">> BasicForwardRuleInfGraph::size = " + baseSize + "(base) + " + dedSize // + "(deductions)" ); return baseSize + dedSize; }
/** * Create the graph used to hold the deductions. Can be overridden by subclasses that need special * purpose graph implementations here. Assumes the graph underlying fdeductions and associated * SafeGraph wrapper can be reused if present thus enabling preservation of listeners. */ protected Graph createDeductionsGraph() { if (fdeductions != null) { Graph dg = fdeductions.getGraph(); if (dg != null) { // Reuse the old graph in order to preserve any listeners safeDeductions.getBulkUpdateHandler().removeAll(); return dg; } } Graph dg = Factory.createGraphMem(style); safeDeductions = new SafeGraph(dg); return dg; }
/** Removes the triple t (if possible) from the set belonging to this graph. */ @Override public void performDelete(Triple t) { version++; if (fdata != null) { Graph data = fdata.getGraph(); if (data != null) { data.delete(t); } } if (isPrepared) { fdeductions.getGraph().delete(t); } }
/** * Adds a set of precomputed triples to the deductions store. These do not, themselves, fire any * rules but provide additional axioms that might enable future rule firing when real data is * added. Used to implement bindSchema processing in the parent Reasoner. * * @return return true if the rule set has also been loaded */ protected boolean preloadDeductions(Graph preloadIn) { Graph d = fdeductions.getGraph(); BasicForwardRuleInfGraph preload = (BasicForwardRuleInfGraph) preloadIn; // If the rule set is the same we can reuse those as well if (preload.rules == rules) { // Load raw deductions for (Iterator<Triple> i = preload.find(null, null, null); i.hasNext(); ) { d.add(i.next()); } engine.setRuleStore(preload.engine.getRuleStore()); return true; } else { return false; } }
/** * Assert a new triple in the deduction graph, bypassing any processing machinery. * * @throws AsyncException * @throws AddDeniedException */ @Override public void silentAdd(ASubCallHandler handler, Triple t) throws AddDeniedException, AsyncException { fdeductions.getGraph().add(handler, t); }
/** Assert a new triple in the deduction graph, bypassing any processing machinery. */ public void silentAdd(Triple t) { fdeductions.getGraph().add(t); }