Class TinkerTransactionGraph
- java.lang.Object
-
- org.apache.tinkerpop.gremlin.tinkergraph.structure.AbstractTinkerGraph
-
- org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerTransactionGraph
-
- All Implemented Interfaces:
AutoCloseable
,Graph
,Host
public final class TinkerTransactionGraph extends AbstractTinkerGraph
An in-memory (with optional persistence on calls toAbstractTinkerGraph.close()
), reference implementation of the property graph interfaces with transaction support provided by TinkerPop.- Author:
- Valentyn Kahamlyk
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
TinkerTransactionGraph.TinkerGraphFeatures
class
TinkerTransactionGraph.TinkerGraphGraphFeatures
-
Nested classes/interfaces inherited from class org.apache.tinkerpop.gremlin.tinkergraph.structure.AbstractTinkerGraph
AbstractTinkerGraph.DefaultIdManager, AbstractTinkerGraph.IdManager<T>, AbstractTinkerGraph.TinkerGraphEdgeFeatures, AbstractTinkerGraph.TinkerGraphVertexFeatures, AbstractTinkerGraph.TinkerGraphVertexPropertyFeatures
-
Nested classes/interfaces inherited from interface org.apache.tinkerpop.gremlin.structure.Graph
Graph.Exceptions, Graph.Features, Graph.Hidden, Graph.OptIn, Graph.OptIns, Graph.OptOut, Graph.OptOuts, Graph.Variables
-
-
Field Summary
-
Fields inherited from class org.apache.tinkerpop.gremlin.tinkergraph.structure.AbstractTinkerGraph
allowNullPropertyValues, configuration, currentId, defaultVertexPropertyCardinality, edgeIdManager, edgeIndex, graphComputerView, graphFormat, graphLocation, GREMLIN_TINKERGRAPH_ALLOW_NULL_PROPERTY_VALUES, GREMLIN_TINKERGRAPH_DEFAULT_VERTEX_PROPERTY_CARDINALITY, GREMLIN_TINKERGRAPH_EDGE_ID_MANAGER, GREMLIN_TINKERGRAPH_GRAPH_FORMAT, GREMLIN_TINKERGRAPH_GRAPH_LOCATION, GREMLIN_TINKERGRAPH_SERVICE, GREMLIN_TINKERGRAPH_VERTEX_ID_MANAGER, GREMLIN_TINKERGRAPH_VERTEX_PROPERTY_ID_MANAGER, serviceRegistry, variables, vertexIdManager, vertexIndex, vertexPropertyIdManager
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Edge
addEdge(TinkerVertex outVertex, TinkerVertex inVertex, String label, Object... keyValues)
protected void
addInEdge(TinkerVertex vertex, String label, Edge edge)
protected void
addOutEdge(TinkerVertex vertex, String label, Edge edge)
Vertex
addVertex(Object... keyValues)
Add aVertex
to the graph given an optional series of key/value pairs.void
clear()
Clear internal graph data<E extends Element>
voidcreateIndex(String key, Class<E> elementClass)
<E extends Element>
voiddropIndex(String key, Class<E> elementClass)
Edge
edge(Object edgeId)
ReturnEdge
by id.Iterator<Edge>
edges(Object... edgeIds)
Graph.Features
features()
Return TinkerGraph feature set.int
getEdgesCount()
Graph-specific implementation for number of vertices.TinkerServiceRegistry
getServiceRegistry()
Get theServiceRegistry
associated with the graph.int
getVerticesCount()
Graph-specific implementation for number of vertices.boolean
hasEdge(Object id)
boolean
hasVertex(Object id)
static TinkerTransactionGraph
open()
Open a newTinkerTransactionGraph
instance.static TinkerTransactionGraph
open(org.apache.commons.configuration2.Configuration configuration)
Open a newTinkerGraph
instance.void
removeEdge(Object edgeId)
void
removeVertex(Object vertexId)
void
touch(TinkerEdge edge)
MarkEdge
as changed in transaction.void
touch(TinkerVertex vertex)
MarkVertex
as changed in transaction.Transaction
tx()
Configure and control the transactions for those graphs that support this feature.Vertex
vertex(Object vertexId)
ReturnVertex
by id.Iterator<Vertex>
vertices(Object... vertexIds)
-
Methods inherited from class org.apache.tinkerpop.gremlin.tinkergraph.structure.AbstractTinkerGraph
close, compute, compute, configuration, createTinkerEdge, createTinkerEdge, createTinkerVertex, createTinkerVertex, getIndexedKeys, instantiate, io, loadGraph, saveGraph, selectIdManager, toString, variables
-
-
-
-
Method Detail
-
open
public static TinkerTransactionGraph open()
Open a newTinkerTransactionGraph
instance. Reference Implementation Help: If aGraph
implementation does not require aConfiguration
(or perhaps has a default configuration) it can choose to implement a zero argumentopen()
method. This is an optional constructor method for TinkerGraph. It is not enforced by the Gremlin Test Suite.
-
open
public static TinkerTransactionGraph open(org.apache.commons.configuration2.Configuration configuration)
Open a newTinkerGraph
instance. Reference Implementation Help: This method is the one use by theGraphFactory
to instantiateGraph
instances. This method must be overridden for the Structure Test Suite to pass. Implementers have latitude in terms of how exceptions are handled within this method. Such exceptions will be considered implementation specific by the test suite as all test generate graph instances by way ofGraphFactory
. As such, the exceptions get generalized behind that facade and sinceGraphFactory
is the preferred method to opening graphs it will be consistent at that level.- Parameters:
configuration
- the configuration for the instance- Returns:
- a newly opened
Graph
-
addVertex
public Vertex addVertex(Object... keyValues)
Description copied from class:AbstractTinkerGraph
Add aVertex
to the graph given an optional series of key/value pairs. These key/values must be provided in an even number where the odd numbered arguments areString
property keys and the even numbered arguments are the related property values.- Specified by:
addVertex
in interfaceGraph
- Specified by:
addVertex
in classAbstractTinkerGraph
- Parameters:
keyValues
- The key/value pairs to turn into vertex properties- Returns:
- The newly created vertex
-
removeVertex
public void removeVertex(Object vertexId)
Description copied from class:AbstractTinkerGraph
- Specified by:
removeVertex
in classAbstractTinkerGraph
-
touch
public void touch(TinkerVertex vertex)
Description copied from class:AbstractTinkerGraph
MarkVertex
as changed in transaction. If the graph does not support transactions, then does nothing.- Overrides:
touch
in classAbstractTinkerGraph
-
touch
public void touch(TinkerEdge edge)
Description copied from class:AbstractTinkerGraph
MarkEdge
as changed in transaction. If the graph does not support transactions, then does nothing.- Overrides:
touch
in classAbstractTinkerGraph
-
addEdge
public Edge addEdge(TinkerVertex outVertex, TinkerVertex inVertex, String label, Object... keyValues)
Description copied from class:AbstractTinkerGraph
- Specified by:
addEdge
in classAbstractTinkerGraph
-
removeEdge
public void removeEdge(Object edgeId)
Description copied from class:AbstractTinkerGraph
- Specified by:
removeEdge
in classAbstractTinkerGraph
-
clear
public void clear()
Description copied from class:AbstractTinkerGraph
Clear internal graph data- Overrides:
clear
in classAbstractTinkerGraph
-
tx
public Transaction tx()
Description copied from class:AbstractTinkerGraph
Configure and control the transactions for those graphs that support this feature.- Specified by:
tx
in interfaceGraph
- Specified by:
tx
in classAbstractTinkerGraph
-
getVerticesCount
public int getVerticesCount()
Description copied from class:AbstractTinkerGraph
Graph-specific implementation for number of vertices.- Specified by:
getVerticesCount
in classAbstractTinkerGraph
- Returns:
- count of vertices in Graph.
-
hasVertex
public boolean hasVertex(Object id)
Description copied from class:AbstractTinkerGraph
- Specified by:
hasVertex
in classAbstractTinkerGraph
-
getEdgesCount
public int getEdgesCount()
Description copied from class:AbstractTinkerGraph
Graph-specific implementation for number of vertices.- Specified by:
getEdgesCount
in classAbstractTinkerGraph
- Returns:
- count of vertices in Graph.
-
hasEdge
public boolean hasEdge(Object id)
Description copied from class:AbstractTinkerGraph
- Specified by:
hasEdge
in classAbstractTinkerGraph
-
getServiceRegistry
public TinkerServiceRegistry getServiceRegistry()
Description copied from interface:Graph
Get theServiceRegistry
associated with the graph. Used byCallStep
to invoke service calls.- Returns:
- The registry of callable services
-
vertex
public Vertex vertex(Object vertexId)
Description copied from class:AbstractTinkerGraph
ReturnVertex
by id. Does not create an iterator, so is the preferred method when only 1 element needs to be returned.- Specified by:
vertex
in classAbstractTinkerGraph
- Returns:
- Vertex
-
vertices
public Iterator<Vertex> vertices(Object... vertexIds)
Description copied from class:AbstractTinkerGraph
Get theVertex
objects in this graph with the provided vertex ids orVertex
objects themselves. If no ids are provided, get all vertices. Note that a vertex identifier does not need to correspond to the actual id used in the graph. It needs to be a bit more flexible than that in that given theGraph.Features
around id support, multiple arguments might be applicable here. If the graph returntrue
forGraph.Features.ElementFeatures.supportsNumericIds()
then it should support filters as with:- g.vertices(v)
- g.vertices(v.id())
- g.vertices(1)
- g.vertices(1L)
- g.vertices(1.0d)
- g.vertices(1.0f)
- g.vertices("1")
true
forGraph.Features.ElementFeatures.supportsCustomIds()
()} then it should support filters as with:- g.vertices(v)
- g.vertices(v.id())
- g.vertices(v.id().toString())
true
forGraph.Features.ElementFeatures.supportsAnyIds()
()} then it should support filters as with:- g.vertices(v)
- g.vertices(v.id())
true
forGraph.Features.ElementFeatures.supportsStringIds()
()} then it should support filters as with:- g.vertices(v)
- g.vertices(v.id().toString())
- g.vertices("id")
true
forGraph.Features.ElementFeatures.supportsStringIds()
()} then it should support filters as with:- g.vertices(v)
- g.vertices(v.id().toString())
- g.vertices("id")
- Specified by:
vertices
in interfaceGraph
- Specified by:
vertices
in classAbstractTinkerGraph
- Parameters:
vertexIds
- the ids of the vertices to get- Returns:
- an
Iterator
of vertices that match the provided vertex ids
-
edge
public Edge edge(Object edgeId)
Description copied from class:AbstractTinkerGraph
ReturnEdge
by id. Does not create an iterator, so is the preferred method when only 1 element needs to be returned.- Specified by:
edge
in classAbstractTinkerGraph
- Returns:
- Edge
-
edges
public Iterator<Edge> edges(Object... edgeIds)
Description copied from class:AbstractTinkerGraph
Get theEdge
objects in this graph with the provided edge ids orEdge
objects. If no ids are provided, get all edges. Note that an edge identifier does not need to correspond to the actual id used in the graph. It needs to be a bit more flexible than that in that given theGraph.Features
around id support, multiple arguments might be applicable here. If the graph returntrue
forGraph.Features.ElementFeatures.supportsNumericIds()
then it should support filters as with:- g.edges(e)
- g.edges(e.id())
- g.edges(1)
- g.edges(1L)
- g.edges(1.0d)
- g.edges(1.0f)
- g.edges("1")
true
forGraph.Features.ElementFeatures.supportsCustomIds()
()} then it should support filters as with:- g.edges(e)
- g.edges(e.id())
- g.edges(e.id().toString())
true
forGraph.Features.ElementFeatures.supportsAnyIds()
()} then it should support filters as with:- g.edges(e)
- g.edges(e.id())
true
forGraph.Features.ElementFeatures.supportsStringIds()
()} then it should support filters as with:- g.edges(e)
- g.edges(e.id().toString())
- g.edges("id")
- Specified by:
edges
in interfaceGraph
- Specified by:
edges
in classAbstractTinkerGraph
- Parameters:
edgeIds
- the ids of the edges to get- Returns:
- an
Iterator
of edges that match the provided edge ids
-
addOutEdge
protected void addOutEdge(TinkerVertex vertex, String label, Edge edge)
- Specified by:
addOutEdge
in classAbstractTinkerGraph
-
addInEdge
protected void addInEdge(TinkerVertex vertex, String label, Edge edge)
- Specified by:
addInEdge
in classAbstractTinkerGraph
-
features
public Graph.Features features()
Return TinkerGraph feature set. Reference Implementation Help: Implementers only need to implement features for which there are negative or instance configured features. By default, allGraph.Features
return true.
-
createIndex
public <E extends Element> void createIndex(String key, Class<E> elementClass)
Create an index for said element class (Vertex
orEdge
) and said property key. Whenever an element has the specified key mutated, the index is updated. When the index is created, all existing elements are indexed to ensure that they are captured by the index.- Type Parameters:
E
- The type of the element class- Parameters:
key
- the property key to indexelementClass
- the element class to index
-
-