com.bigdata.rdf.store
Class TripleStoreUtility

java.lang.Object
  extended by com.bigdata.rdf.store.TripleStoreUtility

public class TripleStoreUtility
extends Object

Utility class for comparing graphs for equality, bulk export, etc.

Version:
$Id: TripleStoreUtility.java 5291 2011-10-05 19:48:13Z thompsonbry $
Author:
Bryan Thompson

Field Summary
protected static org.apache.log4j.Logger log
           
 
Constructor Summary
TripleStoreUtility()
           
 
Method Summary
static TempTripleStore bulkExport(AbstractTripleStore db)
          Exports all statements found in the data and all backchained entailments for the db into a TempTripleStore.
static void log(String s)
           
static void main(String[] args)
          Compares two LocalTripleStores
static boolean modelsEqual(AbstractTripleStore expected, AbstractTripleStore actual)
          Compares two RDF graphs for equality (same statements).
static ICloseableIterator<BigdataStatement> notFoundInTarget(AbstractTripleStore expected, AbstractTripleStore actual)
          Visits expected BigdataStatements not found in actual.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.apache.log4j.Logger log
Constructor Detail

TripleStoreUtility

public TripleStoreUtility()
Method Detail

modelsEqual

public static boolean modelsEqual(AbstractTripleStore expected,
                                  AbstractTripleStore actual)
                           throws Exception
Compares two RDF graphs for equality (same statements).

Note: This does NOT handle bnodes, which much be treated as variables for RDF semantics.

Note: Comparison is performed in terms of the externalized RDF Statements rather than SPOs since different graphs use different lexicons.

Note: If the graphs differ in which entailments they are storing in their data and which entailments are backchained then you MUST make them consistent in this regard. You can do this by exporting one or both using bulkExport(AbstractTripleStore), which will cause all entailments to be materialized in the returned TempTripleStore.

Parameters:
expected - One graph.
actual - Another graph with a consistent policy for forward and backchained entailments.
Returns:
true if all statements in the expected graph are in the actual graph and if the actual graph does not contain any statements that are not also in the expected graph.
Throws:
Exception

log

public static void log(String s)

notFoundInTarget

public static ICloseableIterator<BigdataStatement> notFoundInTarget(AbstractTripleStore expected,
                                                                    AbstractTripleStore actual)
                                                             throws InterruptedException,
                                                                    ExecutionException
Visits expected BigdataStatements not found in actual.

Parameters:
expected -
actual -
Returns:
An iterator visiting BigdataStatements present in expected but not found in actual.
Throws:
ExecutionException
InterruptedException

bulkExport

public static TempTripleStore bulkExport(AbstractTripleStore db)
Exports all statements found in the data and all backchained entailments for the db into a TempTripleStore. This may be used to compare graphs purely in their data by pre-generation of all backchained entailments.

Note: This is not a general purpose bulk export as it uses only a single access path, does not store justifications, and does retain the Axioms model of the source graph. This method is specifically designed to export "just the triples", e.g., for purposes of comparison.

Parameters:
db - The source database.
Returns:
The TempTripleStore.

main

public static void main(String[] args)
                 throws Exception
Compares two LocalTripleStores

Parameters:
args - filename filename (namespace)
Throws:
Exception
TODO:
namespace for each, could be the same file, and timestamp for each., handle other database modes.


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