My favorites | Sign in
Project Logo
                
Search
for
Updated Aug 19, 2008 by andrewfnewman
PersistentGraphs  
Storing and loading graphs in JRDF.

Persistent JRDF Graphs

JRDF has evolved to support basic persistence of graphs. Graphs can be created using the PersistentJRDFFactoryImpl. This requires a DirectoryHandler in order to be created.

Lifecycle

The lifecycle of a JRDF graph is currently tied to the factory that creates it. Typically, the code to use is:

DirectoryHandler handler = new TempDirectoryHandler();
PersistentJRDFFactory factory = PersistentJRDFFactoryImpl.getFactory(handler);
try {
  Graph graph = factory.getGraph("graph1");
  ...
  graph operations
  ...
} finally {
  factory.close();
}

Until the factory is closed, the operations made on the graphs cannot be considered persisted to disk. Graphs are not treated individually. The persistence lifecycle still follows the original lifecyce, that is, load RDF, do some work, then save. Allowing graphs to be persisted indvidually is currently being worked on.

Directory Handler

The DirectoryHandler interface is designed to manage the location where the indexes and system graph are stored. It is used by the persistent graph factories.

Currently, there is only one DirectoryHandler implementation called TempDirectoryHandler. It uses the current user name and system temporary directory property ("java.io.tmpdir") to create a directory. For example, with a user name of "andrew" on Windows it creates a "C:\temp\jrdf_andrew" directory.

System Graph

The system graph is an NTriples file, "graphs.nt", that is stored with the other indexes. Each named graph adds three statements to the file, for example:

_:a <http://jrdf.sf.net/name> "graph1" .
_:a <http://jrdf.sf.net/id> "1"^^<http://www.w3.org/2001/XMLSchema#long> .
_:a <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://jrdf.sf.net/graph> .

This indicates that the resources for "graph1" uses the id 1. So there should be files associated with this id including the node pool/string pool and indexes, for example: the node pool "00000000.jdb" and indexes "spo1", "osp1" and "pos1".

All persistent graph implementations track the creation and deletion of named graphs. The interface has the following methods that operate on the system graph:


Sign in to add a comment
Hosted by Google Code