com.tinkerpop.blueprints.oupls.sail
Class GraphSail<T extends KeyIndexableGraph>
java.lang.Object
org.openrdf.sail.helpers.SailBase
org.openrdf.sail.helpers.NotifyingSailBase
com.tinkerpop.blueprints.oupls.sail.GraphSail<T>
- All Implemented Interfaces:
- WrapperGraph<T>, org.openrdf.sail.NotifyingSail, org.openrdf.sail.Sail
public class GraphSail<T extends KeyIndexableGraph>
- extends org.openrdf.sail.helpers.NotifyingSailBase
- implements WrapperGraph<T>
An RDF storage interface for any graph database with a Blueprints IndexableGraph implementation. It models
RDF graphs as property graphs which can be easily traversed and manipulated with other Blueprints-compatible tools.
At the same time, it can be used with OpenRDF-based tools to power a SPARQL endpoint, an RDF reasoner, etc.
RDF resources are stored as vertices, RDF statements as edges using the Blueprints default (automatic) indices.
Namespaces are stored at a special vertex with the id "urn:com.tinkerpop.blueprints.sail:namespaces".
This Sail is as transactional as the underlying graph database: if the provided Graph implements TransactionalGraph
and is in manual transaction mode, then the SailConnection's commit and rollback methods will be used correspondingly.
Retrieval of RDF statements from the store involves both "index-based" and "graph-based" matching, as follows.
For each new statement edge which is added to the store, "p" (predicate), "c" (context), and "pc" (predicate and context)
property values are added and indexed. These allow the statement to be quickly retrieved in a query where only the
predicate and/or context is specified. However, BlueprintsSail will additionally index on any triple pattern which
is supplied to the constructor, boosting query reactivity at the expense of additional storage overhead.
For example, if a "so" pattern is supplied, each new statement edge will also receive an "so" property value which stores the
combination of subject and object of the statement. A subsequent call such as getStatements(john, null, jane) will
match both values simultaneously. This may succeed more quickly than the corresponding graph-based match, which picks
either the john or jane vertex as a starting point and filters on adjacent edges. Graph-based matches are used for
all of the triple patterns s,o,sp,so,sc,po,oc,spo,spc,soc,poc,spoc which have not been explicitly flagged for
index-based matching.
Note: this implementation attaches no semantics to Vertex and Edge IDs, so as to be compatible with Graph
implementations which do no not allow IDs to be chosen.
- Author:
- Joshua Shinavier (http://fortytwo.net)
| Fields inherited from class org.openrdf.sail.helpers.SailBase |
connectionTimeOut, DEFAULT_CONNECTION_TIMEOUT, initializationLock, logger |
|
Constructor Summary |
GraphSail(T graph)
Create a new RDF store using the provided Blueprints graph. |
GraphSail(T graph,
String indexedPatterns)
Create a new RDF store using the provided Blueprints graph. |
| Methods inherited from class org.openrdf.sail.helpers.NotifyingSailBase |
addSailChangedListener, getConnection, notifySailChanged, removeSailChangedListener |
| Methods inherited from class org.openrdf.sail.helpers.SailBase |
connectionClosed, debugEnabled, initialize, isInitialized, shutDown |
| Methods inherited from interface org.openrdf.sail.Sail |
initialize, shutDown |
SEPARATOR
public static final String SEPARATOR
- See Also:
- Constant Field Values
PREDICATE_PROP
public static final String PREDICATE_PROP
- See Also:
- Constant Field Values
CONTEXT_PROP
public static final String CONTEXT_PROP
- See Also:
- Constant Field Values
URI_PREFIX
public static final char URI_PREFIX
- See Also:
- Constant Field Values
BLANK_NODE_PREFIX
public static final char BLANK_NODE_PREFIX
- See Also:
- Constant Field Values
PLAIN_LITERAL_PREFIX
public static final char PLAIN_LITERAL_PREFIX
- See Also:
- Constant Field Values
TYPED_LITERAL_PREFIX
public static final char TYPED_LITERAL_PREFIX
- See Also:
- Constant Field Values
LANGUAGE_TAG_LITERAL_PREFIX
public static final char LANGUAGE_TAG_LITERAL_PREFIX
- See Also:
- Constant Field Values
NULL_CONTEXT_PREFIX
public static final char NULL_CONTEXT_PREFIX
- See Also:
- Constant Field Values
INDEX_PATTERN
public static final Pattern INDEX_PATTERN
BNODE
public static final String BNODE
- See Also:
- Constant Field Values
INFERRED
public static final String INFERRED
- See Also:
- Constant Field Values
KIND
public static final String KIND
- See Also:
- Constant Field Values
LANG
public static final String LANG
- See Also:
- Constant Field Values
LITERAL
public static final String LITERAL
- See Also:
- Constant Field Values
TYPE
public static final String TYPE
- See Also:
- Constant Field Values
URI
public static final String URI
- See Also:
- Constant Field Values
VALUE
public static final String VALUE
- See Also:
- Constant Field Values
NULL_CONTEXT_NATIVE
public static final String NULL_CONTEXT_NATIVE
- See Also:
- Constant Field Values
GraphSail
public GraphSail(T graph)
- Create a new RDF store using the provided Blueprints graph. Default edge indices will be used.
- Parameters:
graph - the storage layer. If the provided graph implements TransactionalGraph and is in manual transaction
mode, then this Sail will also be transactional.
GraphSail
public GraphSail(T graph,
String indexedPatterns)
- Create a new RDF store using the provided Blueprints graph. Additionally, create edge indices for the provided
triple patterns (potentially speeding up certain queries, while increasing storage overhead).
- Parameters:
graph - the storage layer. If the provided graph implements TransactionalGraph and is in manual transaction
mode, then this Sail will also be transactional.
Any vertices and edges in the graph should have been previously created with GraphSail.indexedPatterns - a comma-delimited list of triple patterns for index-based statement matching. Only p,c are required,
while the default patterns are p,c,pc.
getBaseGraph
public T getBaseGraph()
- Specified by:
getBaseGraph in interface WrapperGraph<T extends KeyIndexableGraph>
setDataDir
public void setDataDir(File file)
- Specified by:
setDataDir in interface org.openrdf.sail.Sail- Overrides:
setDataDir in class org.openrdf.sail.helpers.SailBase
getDataDir
public File getDataDir()
- Specified by:
getDataDir in interface org.openrdf.sail.Sail- Overrides:
getDataDir in class org.openrdf.sail.helpers.SailBase
initializeInternal
public void initializeInternal()
throws org.openrdf.sail.SailException
- Overrides:
initializeInternal in class org.openrdf.sail.helpers.SailBase
- Throws:
org.openrdf.sail.SailException
shutDownInternal
public void shutDownInternal()
throws org.openrdf.sail.SailException
- Specified by:
shutDownInternal in class org.openrdf.sail.helpers.SailBase
- Throws:
org.openrdf.sail.SailException
isWritable
public boolean isWritable()
throws org.openrdf.sail.SailException
- Specified by:
isWritable in interface org.openrdf.sail.Sail
- Throws:
org.openrdf.sail.SailException
getConnectionInternal
public org.openrdf.sail.NotifyingSailConnection getConnectionInternal()
throws org.openrdf.sail.SailException
- Overrides:
getConnectionInternal in class org.openrdf.sail.helpers.NotifyingSailBase
- Throws:
org.openrdf.sail.SailException
getValueFactory
public org.openrdf.model.ValueFactory getValueFactory()
- Specified by:
getValueFactory in interface org.openrdf.sail.Sail
useVolatileStatements
public void useVolatileStatements(boolean flag)
- Enables or disables the use of efficient, short-lived statements in the iterators returned by
GraphSailConnection.getStatements() and GraphSailConnection.evaluate().
This feature is disabled by default, and in typical usage scenarios, Java compiler optimization makes it superfluous.
However, it potentially confers a performance advantage when a single thread consumes the iterator,
inspecting and then immediately discarding each statement.
- Parameters:
flag - whether to use volatile statements.
When this method is called, only subsequently created iterators are affected.
enforceUniqueStatements
public void enforceUniqueStatements(boolean flag)
- Enables or disables enforcement of a unique statements policy,
which ensures that no new statement will be added which is identical
(in all of its subject, predicate, object and context) to an existing statement.
If enabled, this policy will first remove any existing statements identical to the to-be-added statement,
before adding the latter statement.
- Parameters:
flag - whether this policy should be enforced
toString
public String toString()
- Overrides:
toString in class org.openrdf.sail.helpers.SailBase
Copyright © 2010-2012 David Wu. All Rights Reserved.