public class BlazeGraphEmbedded extends BlazeGraph
Currently BlazeGraphEmbedded is the only concrete implementation of the Blazegraph Tinkerpop3 API. BlazeGraphEmbedded is backed by an embedded (same JVM) instance of Blazegraph. This puts the enterprise features of Blazegraph (high-availability, scale-out, etc.) out of reach for the 1.0 version of the TP3 integration, since those features are accessed via Blazegraph's client/server API. A TP3 integration with the client/server version of Blazegraph is reserved for a future blazegraph-tinkerpop release.
Blazegraph's concurrency model is MVCC, which more or less lines up with Tinkerpop's Transaction model. When you open a BlazeGraphEmbedded instance, you are working with the unisolated (writer) view of the database. This view supports Tinkerpop Transactions, and reads are done against the unisolated connection, so uncommitted changes will be visible. A BlazeGraphEmbedded can be shared across multiple threads, but only one thread can have a Tinkerpop Transaction open at a time (other threads will be blocked until the transaction is closed). A TP3 Transaction is automatically opened on any read or write operation, and automatically closed on any commit or rollback operation. The Transaction can also be closed manually, which you will need to do after read operations to unblock other waiting threads.
BlazegraphGraphEmbedded's database operations are thus single-threaded, but Blazegraph/MVCC allows for many concurrent readers in parallel with both the single writer and other readers. This is possible by opening a read-only view that will read against the last commit point on the database. The read-only view can be be accessed in parallel to the writer without any of the restrictions described above. To get a read-only snapshot, use the following pattern:
final BlazeGraphEmbedded unisolated = ...;
final BlazeGraphReadOnly readOnly = unisolated.readOnlyConnection();
try {
// read operations against readOnly
} finally {
readOnly.close();
}
BlazeGraphReadOnly extends BlazeGraphEmbedded and thus offers all the same operations, except write operations will not be permitted (BlazeGraphReadOnly.tx() will throw an exception). You can open as many read-only views as you like, but we recommend you use a connection pool so as not to overtax system resources. Applications should be written with the one-writer many-readers paradigm front of mind.
Important: Make sure to close the read-only view as soon as you are done with it.
| Modifier and Type | Class and Description |
|---|---|
class |
BlazeGraphEmbedded.BlazeTransaction
Tinkerpop3 Transaction object.
|
BlazeGraph.Exceptions, BlazeGraph.GraphStreamer<E>, BlazeGraph.Match, BlazeGraph.Options, BlazeGraph.Transformsorg.apache.tinkerpop.gremlin.structure.Graph.Features, org.apache.tinkerpop.gremlin.structure.Graph.Hidden, org.apache.tinkerpop.gremlin.structure.Graph.OptIn, org.apache.tinkerpop.gremlin.structure.Graph.OptIns, org.apache.tinkerpop.gremlin.structure.Graph.OptOut, org.apache.tinkerpop.gremlin.structure.Graph.OptOuts, org.apache.tinkerpop.gremlin.structure.Graph.Variables| Modifier and Type | Field and Description |
|---|---|
protected boolean |
closed
Close the unisolated connection if open and close the repository.
|
protected com.blazegraph.gremlin.embedded.BlazeGraphEmbedded.ChangeLogTransformer |
listener
Listen for change events from the SAIL (RDF), convert to PG data
(
BlazeGraphEdits), forward notifications to
BlazeGraphListeners. |
protected List<BlazeGraphListener> |
listeners
Graph listeners.
|
protected com.bigdata.rdf.sail.BigdataSailRepository |
repo
Embedded SAIL repository.
|
config, sparqlLog, sparqlLogMax, transforms| Modifier | Constructor and Description |
|---|---|
protected |
BlazeGraphEmbedded(com.bigdata.rdf.sail.BigdataSailRepository repo,
org.apache.commons.configuration.Configuration config)
Hidden constructor - use
open(BigdataSailRepository, Configuration). |
| Modifier and Type | Method and Description |
|---|---|
void |
__tearDownUnitTest()
DO NOT INVOKE FROM APPLICATION CODE - this method
deletes the KB instance and destroys the backing database instance.
|
protected boolean |
_ask(String queryStr,
String extQueryId)
Internal Sparql ask method.
|
protected Stream<org.openrdf.model.Statement> |
_project(String queryStr,
String extQueryId)
Internal Sparql project method.
|
protected Stream<org.openrdf.query.BindingSet> |
_select(String queryStr,
String extQueryId)
Internal Sparql select method.
|
protected void |
_update(String queryStr,
String extQueryId)
Internal Sparql update method.
|
void |
addListener(BlazeGraphListener listener)
Add a
BlazeGraphListener. |
void |
cancel(com.bigdata.rdf.sail.model.RunningQuery rQuery)
Cancel a running query.
|
void |
cancel(UUID queryId)
Cancel a running query by internal id.
|
void |
close()
Close the graph.
|
void |
commit()
Pass through to tx().commit().
|
com.bigdata.rdf.sail.BigdataSailRepositoryConnection |
cxn()
Return the unisolated SAIL connection.
|
String |
dumpStore()
Dump all the statements in the store to a String.
|
void |
flush()
Pass through to tx().flush().
|
Collection<com.bigdata.rdf.sail.model.RunningQuery> |
getRunningQueries()
Return a list of all running queries.
|
long |
historicalStatementCount()
Count all the statements in the store including deleted statements.
|
protected static long |
lastCommitTime(com.bigdata.rdf.sail.BigdataSailRepository repo)
Take a quick peek at the last commit time on the supplied journal file.
|
static BlazeGraphEmbedded |
open(com.bigdata.rdf.sail.BigdataSailRepository repo)
Open a BlazeGraphEmbedded (unisolated) instance wrapping the provided
SAIL repository with no additional configuration options.
|
static BlazeGraphEmbedded |
open(com.bigdata.rdf.sail.BigdataSailRepository repo,
org.apache.commons.configuration.Configuration config)
Open a BlazeGraphEmbedded (unisolated) instance wrapping the provided
SAIL repository and using the supplied configuration.
|
com.bigdata.rdf.model.BigdataValueFactory |
rdfValueFactory()
Return the RDF value factory.
|
BlazeGraphReadOnly |
readOnlyConnection()
Open a read-only view of the data at the last commit point.
|
void |
removeListener(BlazeGraphListener listener)
Remove a
BlazeGraphListener. |
void |
rollback()
Pass through to tx().rollbakc().
|
String |
runningQueriesToString()
Return a list of all running queries in string form.
|
long |
statementCount()
Count all the statements in the store.
|
BlazeGraphEmbedded.BlazeTransaction |
tx()
Return the
BlazeGraphEmbedded.BlazeTransaction instance. |
addEdge, addVertex, ask, ask, bulkLoad, bulkLoad, bulkLoad, compute, compute, configuration, edge, edgeCount, edges, features, graphAtomTransform, history, history, isBulkLoad, project, project, search, select, select, setBulkLoad, setMaxQueryTime, toString, update, update, valueFactory, variables, vertex, vertexCount, verticesprotected final com.bigdata.rdf.sail.BigdataSailRepository repo
protected final List<BlazeGraphListener> listeners
BlazeGraphListenerprotected final com.blazegraph.gremlin.embedded.BlazeGraphEmbedded.ChangeLogTransformer listener
BlazeGraphEdits), forward notifications to
BlazeGraphListeners.protected volatile boolean closed
Transaction.CLOSE_BEHAVIORprotected BlazeGraphEmbedded(com.bigdata.rdf.sail.BigdataSailRepository repo,
org.apache.commons.configuration.Configuration config)
open(BigdataSailRepository, Configuration).repo - an open and initialized repositoryconfig - additional configurationpublic static BlazeGraphEmbedded open(com.bigdata.rdf.sail.BigdataSailRepository repo)
repo - an open and initialized repositorypublic static BlazeGraphEmbedded open(com.bigdata.rdf.sail.BigdataSailRepository repo, org.apache.commons.configuration.Configuration config)
config - additional configurationprotected static long lastCommitTime(com.bigdata.rdf.sail.BigdataSailRepository repo)
public BlazeGraphReadOnly readOnlyConnection()
These should be bounded in number by your application and always closed when done using them.
public BlazeGraphEmbedded.BlazeTransaction tx()
BlazeGraphEmbedded.BlazeTransaction instance.tx in interface org.apache.tinkerpop.gremlin.structure.Graphtx in class BlazeGraphBlazeGraphEmbedded.BlazeTransactionpublic com.bigdata.rdf.sail.BigdataSailRepositoryConnection cxn()
cxn in class BlazeGraphpublic void commit()
AbstractTransaction.commit()public void rollback()
AbstractTransaction.rollback()public void flush()
public void close()
BlazeGraphclose in interface AutoCloseableclose in interface org.apache.tinkerpop.gremlin.structure.Graphclose in class BlazeGraphclose()public void addListener(BlazeGraphListener listener)
BlazeGraphListener.listener - the listenerpublic void removeListener(BlazeGraphListener listener)
BlazeGraphListener.listener - the listenerpublic com.bigdata.rdf.model.BigdataValueFactory rdfValueFactory()
rdfValueFactory in class BlazeGraphBigdataValueFactoryprotected Stream<org.openrdf.query.BindingSet> _select(String queryStr, String extQueryId)
BlazeGraph.GraphStreamer.
Callers MUST close this stream when finished.
Logs the query at INFO and logs the optimized AST at TRACE._select in class BlazeGraphprotected Stream<org.openrdf.model.Statement> _project(String queryStr, String extQueryId)
BlazeGraph.GraphStreamer.
Callers MUST close this stream when finished.
Logs the query at INFO and logs the optimized AST at TRACE._project in class BlazeGraphprotected boolean _ask(String queryStr, String extQueryId)
_ask in class BlazeGraphprotected void _update(String queryStr, String extQueryId)
_update in class BlazeGraphpublic String dumpStore() throws Exception
flush() to get an accurate picture.Exceptionpublic long statementCount()
throws Exception
flush() to get an accurate picture.Exceptionpublic long historicalStatementCount()
throws Exception
flush() to get an accurate
picture.Exceptionpublic String runningQueriesToString()
public Collection<com.bigdata.rdf.sail.model.RunningQuery> getRunningQueries()
getRunningQueries in class BlazeGraphpublic void cancel(UUID queryId)
cancel in class BlazeGraphpublic void cancel(com.bigdata.rdf.sail.model.RunningQuery rQuery)
cancel in class BlazeGraphpublic void __tearDownUnitTest()
Copyright © 2015–2016 SYSTAP, LLC DBA Blazegraph. All rights reserved.