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)
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()
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()
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
- Specified by:
addVertex
in interfaceGraph
- Specified by:
addVertex
in classAbstractTinkerGraph
-
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
- 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()
-
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
- Specified by:
vertices
in interfaceGraph
- Specified by:
vertices
in classAbstractTinkerGraph
-
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
- Specified by:
edges
in interfaceGraph
- Specified by:
edges
in classAbstractTinkerGraph
-
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
-
-