com.bigdata.rdf.rules
Class TMUtility

java.lang.Object
  extended by com.bigdata.rdf.rules.TMUtility

public class TMUtility
extends Object

A utility class for performing rule re-writes for RDF truth maintenance using a "focusStore" in addition to the primary database. The focusStore is typically used in one of two ways: (1) incremental loading of new data into the database; and (2) collecting entailments of statements that are being removed during truth maintenance.

Note: When loading a new data set into the database, the "focusStore" should contain the statements that were read from the data source, e.g., some RDF/XML file and the "buffer" should be configured to write on the "database".

Version:
$Id: TMUtility.java 3448 2010-08-18 20:55:58Z thompsonbry $
Author:
Bryan Thompson
TODO:
There are no unit tests for the magic predicate handling or handling of non-SPORelation Predicates. The code tests on the SPOPredicate class, so it will break when generalizing to other relations. At some point, we should add a predicate "name" attribute, which is really the relation base name (without its container) and then test on the predicate name rather than its Class. The test in this class could then be written as pred.isInstance(relationBaseName) and the predicate interface could be constrained to only allow the predicate view to include relations sharing the same base name.

Field Summary
static TMUtility DEBUG
          Alternative instance constructs programs with sequential steps for easier debugging.
static TMUtility INSTANCE
          Default instance constructs programs with parallel steps.
 
Constructor Summary
TMUtility(boolean parallel)
           
 
Method Summary
 Program mapForTruthMaintenance(IStep step, String focusStore)
           
 Program mapProgramForTruthMaintenance(IProgram program, String focusStore)
          Map a IProgram for truth maintenance.
 Program mapRuleForTruthMaintenance(IRule rule, String focusStore)
          Truth maintenance for RDF needs to compute the entailments as if the statements in a temporary triple store (known as the focusStore) were already part of the database (for insert) or as if they had already been removed (for delete).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final transient TMUtility INSTANCE
Default instance constructs programs with parallel steps.


DEBUG

public static final transient TMUtility DEBUG
Alternative instance constructs programs with sequential steps for easier debugging.

Constructor Detail

TMUtility

public TMUtility(boolean parallel)
Parameters:
parallel - When true, the new IRules will be added to a program that executes its steps in parallel.
Method Detail

mapRuleForTruthMaintenance

public Program mapRuleForTruthMaintenance(IRule rule,
                                          String focusStore)
Truth maintenance for RDF needs to compute the entailments as if the statements in a temporary triple store (known as the focusStore) were already part of the database (for insert) or as if they had already been removed (for delete). Given a single rule with N predicates in the tail, we generate N new rules that we will run instead of the original rule. For each of those N new rules in turn, we set the relation for tail[i] to focusStore. When the new rule is run, tail[i] will read from the [focusStore] rather than the original database. All other predicates in the tail are modified to read from the fused view of the [database + focusStore]. As a special case, when the rule has a single predicate in the tail, the predicate is only run against the focusStore rather than database or the fused view [database + focusStore]. For all cases, the head of the rule is unchanged - this is the relation on which the rules will write and it should always be the database.

Parameters:
rule - The original rule. The IPredicates in this Rule should identify the IRelation for the database for which truth maintenance will be performed.
focusStore - The temporary database containing the statements to be added to (or removed from) the database during truth maintenance.
Returns:
An IProgram constructed as specified above. When they are executed, all of the resulting rules should write on the same buffer. This has the same effect as a UNION over the entailments of the individual rules.

mapProgramForTruthMaintenance

public Program mapProgramForTruthMaintenance(IProgram program,
                                             String focusStore)
Map a IProgram for truth maintenance.

Parameters:
program - The program.
focusStore - The focus store.
Returns:
The new program.
TODO:
unit tests.

mapForTruthMaintenance

public Program mapForTruthMaintenance(IStep step,
                                      String focusStore)


Copyright © 2006-2011 SYSTAP, LLC. All Rights Reserved.