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
An in-memory (with optional persistence on calls to
AbstractTinkerGraph.close()), reference implementation of the property
graph interfaces with transaction support provided by TinkerPop.- Author:
- Valentyn Kahamlyk
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassclassNested classes/interfaces inherited from class org.apache.tinkerpop.gremlin.tinkergraph.structure.AbstractTinkerGraph
AbstractTinkerGraph.DefaultIdManager, AbstractTinkerGraph.IdManager<T>, AbstractTinkerGraph.TinkerGraphEdgeFeatures, AbstractTinkerGraph.TinkerGraphVertexFeatures, AbstractTinkerGraph.TinkerGraphVertexPropertyFeaturesNested classes/interfaces inherited from interface org.apache.tinkerpop.gremlin.structure.Graph
Graph.Exceptions, Graph.Features, Graph.Hidden, Graph.Index, 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, defaultEdgeLabel, defaultVertexLabel, defaultVertexPropertyCardinality, edgeIdManager, edgeIndex, edgeLabelCardinality, 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_LABEL_CARDINALITY, GREMLIN_TINKERGRAPH_VERTEX_PROPERTY_ID_MANAGER, serviceRegistry, variables, vertexIdManager, vertexIndex, vertexLabelCardinality, vertexProperties, vertexPropertyIdManager -
Method Summary
Modifier and TypeMethodDescriptionaddEdge(TinkerVertex outVertex, TinkerVertex inVertex, String label, Object... keyValues) voidaddEdgeToAdjacency(TinkerEdge edge, String label) Add an edge to the per-vertex adjacency maps under the given label.protected voidaddInEdge(TinkerVertex vertex, String label, Edge edge) protected voidaddOutEdge(TinkerVertex vertex, String label, Edge edge) Add aVertexto the graph given an optional series of key/value pairs.voidclear()Clear internal graph datalongcountEdgesByLabel(String label) Returns the number of edges with the given label.longcountVerticesByLabel(String label) Returns the number of vertices with the given label.<E extends Element>
voidcreateIndex(String key, Class<E> elementClass) <E extends Element>
voidReturnEdgeby id.features()Return TinkerGraph feature set.intGraph-specific implementation for number of vertices.Get theServiceRegistryassociated with the graph.intGraph-specific implementation for number of vertices.booleanbooleanstatic TinkerTransactionGraphopen()Open a newTinkerTransactionGraphinstance.static TinkerTransactionGraphopen(org.apache.commons.configuration2.Configuration configuration) Open a newTinkerGraphinstance.voidremoveEdge(Object edgeId) voidremoveEdgeFromAdjacency(TinkerEdge edge, String label) Remove an edge from the per-vertex adjacency maps for the given label.voidremoveVertex(Object vertexId) voidtouch(TinkerEdge edge) MarkEdgeas changed in transaction.voidtouch(TinkerVertex vertex) MarkVertexas changed in transaction.tx()Configure and control the transactions for those graphs that support this feature.ReturnVertexby id.Methods inherited from class org.apache.tinkerpop.gremlin.tinkergraph.structure.AbstractTinkerGraph
addVertexLabels, close, compute, compute, configuration, createTinkerEdge, createTinkerEdge, createTinkerVertex, createTinkerVertex, createTinkerVertex, getIndexedKeys, hasVertexProperty, index, instantiate, io, loadGraph, removeVertexLabels, saveGraph, selectIdManager, toString, variables
-
Method Details
-
open
Open a newTinkerTransactionGraphinstance. Reference Implementation Help: If aGraphimplementation 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 newTinkerGraphinstance. Reference Implementation Help: This method is the one use by theGraphFactoryto instantiateGraphinstances. 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 sinceGraphFactoryis 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
Description copied from class:AbstractTinkerGraphAdd aVertexto 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 areStringproperty keys and the even numbered arguments are the related property values.- Specified by:
addVertexin interfaceGraph- Specified by:
addVertexin classAbstractTinkerGraph- Parameters:
keyValues- The key/value pairs to turn into vertex properties- Returns:
- The newly created vertex
-
removeVertex
Description copied from class:AbstractTinkerGraph- Specified by:
removeVertexin classAbstractTinkerGraph
-
touch
Description copied from class:AbstractTinkerGraphMarkVertexas changed in transaction. If the graph does not support transactions, then does nothing.- Overrides:
touchin classAbstractTinkerGraph
-
touch
Description copied from class:AbstractTinkerGraphMarkEdgeas changed in transaction. If the graph does not support transactions, then does nothing.- Overrides:
touchin classAbstractTinkerGraph
-
addEdge
public Edge addEdge(TinkerVertex outVertex, TinkerVertex inVertex, String label, Object... keyValues) Description copied from class:AbstractTinkerGraph- Specified by:
addEdgein classAbstractTinkerGraph
-
removeEdge
Description copied from class:AbstractTinkerGraph- Specified by:
removeEdgein classAbstractTinkerGraph
-
clear
public void clear()Description copied from class:AbstractTinkerGraphClear internal graph data- Overrides:
clearin classAbstractTinkerGraph
-
tx
Description copied from class:AbstractTinkerGraphConfigure and control the transactions for those graphs that support this feature.- Specified by:
txin interfaceGraph- Specified by:
txin classAbstractTinkerGraph
-
getVerticesCount
public int getVerticesCount()Description copied from class:AbstractTinkerGraphGraph-specific implementation for number of vertices.- Specified by:
getVerticesCountin classAbstractTinkerGraph- Returns:
- count of vertices in Graph.
-
hasVertex
Description copied from class:AbstractTinkerGraph- Specified by:
hasVertexin classAbstractTinkerGraph
-
getEdgesCount
public int getEdgesCount()Description copied from class:AbstractTinkerGraphGraph-specific implementation for number of vertices.- Specified by:
getEdgesCountin classAbstractTinkerGraph- Returns:
- count of vertices in Graph.
-
countVerticesByLabel
Description copied from class:AbstractTinkerGraphReturns the number of vertices with the given label. Anulllabel returns the total vertex count. The default implementation does a full vertex scan; subclasses that maintain a label index should override this for O(1) performance.- Specified by:
countVerticesByLabelin interfaceGraph- Overrides:
countVerticesByLabelin classAbstractTinkerGraph
-
countEdgesByLabel
Description copied from class:AbstractTinkerGraphReturns the number of edges with the given label. Anulllabel returns the total edge count. The default implementation does a full edge scan; subclasses that maintain a label index should override this for O(1) performance.- Specified by:
countEdgesByLabelin interfaceGraph- Overrides:
countEdgesByLabelin classAbstractTinkerGraph
-
hasEdge
Description copied from class:AbstractTinkerGraph- Specified by:
hasEdgein classAbstractTinkerGraph
-
getServiceRegistry
Description copied from interface:GraphGet theServiceRegistryassociated with the graph. Used byCallStepto invoke service calls.- Returns:
- The registry of callable services
-
vertex
Description copied from class:AbstractTinkerGraphReturnVertexby id. Does not create an iterator, so is the preferred method when only 1 element needs to be returned.- Specified by:
vertexin classAbstractTinkerGraph- Returns:
- Vertex
-
vertices
Description copied from class:AbstractTinkerGraphGet theVertexobjects in this graph with the provided vertex ids orVertexobjects 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.Featuresaround id support, multiple arguments might be applicable here. If the graph returntrueforGraph.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")
trueforGraph.Features.ElementFeatures.supportsCustomIds()()} then it should support filters as with:- g.vertices(v)
- g.vertices(v.id())
- g.vertices(v.id().toString())
trueforGraph.Features.ElementFeatures.supportsAnyIds()()} then it should support filters as with:- g.vertices(v)
- g.vertices(v.id())
trueforGraph.Features.ElementFeatures.supportsStringIds()()} then it should support filters as with:- g.vertices(v)
- g.vertices(v.id().toString())
- g.vertices("id")
trueforGraph.Features.ElementFeatures.supportsStringIds()()} then it should support filters as with:- g.vertices(v)
- g.vertices(v.id().toString())
- g.vertices("id")
- Specified by:
verticesin interfaceGraph- Specified by:
verticesin classAbstractTinkerGraph- Parameters:
vertexIds- the ids of the vertices to get- Returns:
- an
Iteratorof vertices that match the provided vertex ids
-
edge
Description copied from class:AbstractTinkerGraphReturnEdgeby id. Does not create an iterator, so is the preferred method when only 1 element needs to be returned.- Specified by:
edgein classAbstractTinkerGraph- Returns:
- Edge
-
edges
Description copied from class:AbstractTinkerGraphGet theEdgeobjects in this graph with the provided edge ids orEdgeobjects. 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.Featuresaround id support, multiple arguments might be applicable here. If the graph returntrueforGraph.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")
trueforGraph.Features.ElementFeatures.supportsCustomIds()()} then it should support filters as with:- g.edges(e)
- g.edges(e.id())
- g.edges(e.id().toString())
trueforGraph.Features.ElementFeatures.supportsAnyIds()()} then it should support filters as with:- g.edges(e)
- g.edges(e.id())
trueforGraph.Features.ElementFeatures.supportsStringIds()()} then it should support filters as with:- g.edges(e)
- g.edges(e.id().toString())
- g.edges("id")
- Specified by:
edgesin interfaceGraph- Specified by:
edgesin classAbstractTinkerGraph- Parameters:
edgeIds- the ids of the edges to get- Returns:
- an
Iteratorof edges that match the provided edge ids
-
addOutEdge
- Specified by:
addOutEdgein classAbstractTinkerGraph
-
addInEdge
- Specified by:
addInEdgein classAbstractTinkerGraph
-
addEdgeToAdjacency
Description copied from class:AbstractTinkerGraphAdd an edge to the per-vertex adjacency maps under the given label. Used when labels are added to an existing edge.- Specified by:
addEdgeToAdjacencyin classAbstractTinkerGraph- Parameters:
edge- the edge to registerlabel- the label under which to register the edge
-
removeEdgeFromAdjacency
Description copied from class:AbstractTinkerGraphRemove an edge from the per-vertex adjacency maps for the given label. Used when labels are removed from an existing edge.- Specified by:
removeEdgeFromAdjacencyin classAbstractTinkerGraph- Parameters:
edge- the edge to unregisterlabel- the label from which to unregister the edge
-
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.Featuresreturn true. -
createIndex
Create an index for said element class (VertexorEdge) 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
-
dropIndex
- Type Parameters:
E- The type of the element class- Parameters:
key- the property key to stop indexingelementClass- the element class of the index to drop
-