Class TinkerMemoryGraph
java.lang.Object
org.apache.tinkerpop.gremlin.tinkergraph.structure.AbstractTinkerGraph
org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerMemoryGraph
- All Implemented Interfaces:
AutoCloseable,Graph,Host,TinkerGraph
The purely in-memory implementation of the
TinkerGraph interface and the reference implementation of the
property graph interfaces provided by TinkerPop. This graph holds no data across JVM restarts; use
g.io(...).write() / g.io(...).read() for interchange, or TinkerStorageGraph for durable
persistence.- Author:
- Marko A. Rodriguez (http://markorodriguez.com), Stephen Mallette (http://stephen.genoprime.com)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassclassNested classes/interfaces inherited from class org.apache.tinkerpop.gremlin.tinkergraph.structure.AbstractTinkerGraph
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.VariablesNested classes/interfaces inherited from interface org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph
TinkerGraph.DefaultIdManager, TinkerGraph.IdManager<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionFields inherited from class org.apache.tinkerpop.gremlin.tinkergraph.structure.AbstractTinkerGraph
allowNullPropertyValues, configuration, currentId, defaultEdgeLabel, defaultVertexLabel, defaultVertexPropertyCardinality, edgeIdManager, edgeIndex, edgeLabelCardinality, graphComputerView, serviceRegistry, variables, vertexIdManager, vertexIndex, vertexLabelCardinality, vertexProperties, vertexPropertyIdManagerFields inherited from interface org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph
GREMLIN_TINKERGRAPH_ALLOW_NULL_PROPERTY_VALUES, GREMLIN_TINKERGRAPH_DEFAULT_VERTEX_PROPERTY_CARDINALITY, GREMLIN_TINKERGRAPH_EDGE_ID_MANAGER, GREMLIN_TINKERGRAPH_SERVICE, GREMLIN_TINKERGRAPH_STORAGE, GREMLIN_TINKERGRAPH_STORAGE_COMPACT_THRESHOLD, GREMLIN_TINKERGRAPH_STORAGE_DIRECTORY, GREMLIN_TINKERGRAPH_STORAGE_PRESERVE_VP_IDS, GREMLIN_TINKERGRAPH_STORAGE_RECOVER, GREMLIN_TINKERGRAPH_STORAGE_SYNC, GREMLIN_TINKERGRAPH_VERTEX_ID_MANAGER, GREMLIN_TINKERGRAPH_VERTEX_LABEL_CARDINALITY, GREMLIN_TINKERGRAPH_VERTEX_PROPERTY_ID_MANAGER -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEdgeToAdjacency(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) voidaddVertexLabels(TinkerVertex vertex, Set<String> labelsAdded) Called when one or more labels have been added to an existing vertex, allowing the graph to update any internal label indices.protected EdgedoAddEdge(TinkerVertex outVertex, TinkerVertex inVertex, String label, Object... keyValues) Implementation ofAbstractTinkerGraph.addEdge(org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertex, org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertex, java.lang.String, java.lang.Object...), called once the graph is known to be open.protected VertexdoAddVertex(Object... keyValues) Implementation ofAbstractTinkerGraph.addVertex(java.lang.Object...), called once the graph is known to be open.protected voiddoClear()Implementation ofAbstractTinkerGraph.clear().protected longdoCountEdgesByLabel(String label) Implementation ofAbstractTinkerGraph.countEdgesByLabel(java.lang.String).protected longdoCountVerticesByLabel(String label) Implementation ofAbstractTinkerGraph.countVerticesByLabel(java.lang.String).protected <E extends Element>
voiddoCreateIndex(String key, Class<E> elementClass) protected <E extends Element>
voiddoDropIndex(String key, Class<E> elementClass) protected EdgeImplementation ofAbstractTinkerGraph.edge(java.lang.Object), called once the graph is known to be open.Implementation ofAbstractTinkerGraph.edges(java.lang.Object...), called once the graph is known to be open.protected intImplementation ofAbstractTinkerGraph.getEdgesCount(), called once the graph is known to be open.protected intImplementation ofAbstractTinkerGraph.getVerticesCount(), called once the graph is known to be open.protected booleanImplementation ofAbstractTinkerGraph.hasEdge(java.lang.Object), called once the graph is known to be open.protected booleandoHasVertex(Object id) Implementation ofAbstractTinkerGraph.hasVertex(java.lang.Object), called once the graph is known to be open.protected voiddoRemoveEdge(Object edgeId) Implementation ofAbstractTinkerGraph.removeEdge(java.lang.Object), called once the graph is known to be open.protected voiddoRemoveVertex(Object vertexId) Implementation ofAbstractTinkerGraph.removeVertex(java.lang.Object), called once the graph is known to be open.protected TransactiondoTx()Implementation ofAbstractTinkerGraph.tx(), called once the graph is known to be open.protected VertexImplementation ofAbstractTinkerGraph.vertex(java.lang.Object), called once the graph is known to be open.doVertices(Object... vertexIds) Implementation ofAbstractTinkerGraph.vertices(java.lang.Object...), called once the graph is known to be open.features()Return TinkerGraph feature set.Gets the registry of service factories forcall()steps.static TinkerMemoryGraphopen()Open a newTinkerMemoryGraphinstance.static TinkerMemoryGraphopen(org.apache.commons.configuration2.Configuration configuration) Open a newTinkerMemoryGraphinstance.voidremoveEdgeFromAdjacency(TinkerEdge edge, String label) Remove an edge from the per-vertex adjacency maps for the given label.voidremoveVertexLabels(TinkerVertex vertex, Set<String> labelsRemoved) Called when one or more labels have been removed from an existing vertex, allowing the graph to update any internal label indices.Methods inherited from class org.apache.tinkerpop.gremlin.tinkergraph.structure.AbstractTinkerGraph
addEdge, addVertex, checkOpen, clear, close, compute, compute, configuration, countEdgesByLabel, countVerticesByLabel, createIndex, createTinkerEdge, createTinkerEdge, createTinkerVertex, createTinkerVertex, createTinkerVertex, doTouch, doTouch, dropIndex, edge, edges, getEdgesCount, getIndexedKeys, getVerticesCount, hasEdge, hasVertex, hasVertexProperty, index, instantiate, io, isTxMode, removeEdge, removeVertex, selectIdManager, toString, touch, touch, tx, variables, vertex, vertices
-
Field Details
-
vertices
-
edges
-
-
Method Details
-
open
Open a newTinkerMemoryGraphinstance. 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 TinkerMemoryGraph. It is not enforced by the Gremlin Test Suite. -
open
Open a newTinkerMemoryGraphinstance. 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
-
doAddVertex
Description copied from class:AbstractTinkerGraphImplementation ofAbstractTinkerGraph.addVertex(java.lang.Object...), called once the graph is known to be open.- Specified by:
doAddVertexin classAbstractTinkerGraph
-
doRemoveVertex
Description copied from class:AbstractTinkerGraphImplementation ofAbstractTinkerGraph.removeVertex(java.lang.Object), called once the graph is known to be open.- Specified by:
doRemoveVertexin classAbstractTinkerGraph
-
doAddEdge
protected Edge doAddEdge(TinkerVertex outVertex, TinkerVertex inVertex, String label, Object... keyValues) Description copied from class:AbstractTinkerGraphImplementation ofAbstractTinkerGraph.addEdge(org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertex, org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertex, java.lang.String, java.lang.Object...), called once the graph is known to be open.- Specified by:
doAddEdgein classAbstractTinkerGraph
-
doRemoveEdge
Description copied from class:AbstractTinkerGraphImplementation ofAbstractTinkerGraph.removeEdge(java.lang.Object), called once the graph is known to be open.- Specified by:
doRemoveEdgein classAbstractTinkerGraph
-
doCountVerticesByLabel
Description copied from class:AbstractTinkerGraphImplementation ofAbstractTinkerGraph.countVerticesByLabel(java.lang.String). The default implementation does a full vertex scan; subclasses that maintain a label index should override this for O(1) performance.- Overrides:
doCountVerticesByLabelin classAbstractTinkerGraph
-
doCountEdgesByLabel
Description copied from class:AbstractTinkerGraphImplementation ofAbstractTinkerGraph.countEdgesByLabel(java.lang.String). The default implementation does a full edge scan; subclasses that maintain a label index should override this for O(1) performance.- Overrides:
doCountEdgesByLabelin classAbstractTinkerGraph
-
addVertexLabels
Description copied from class:AbstractTinkerGraphCalled when one or more labels have been added to an existing vertex, allowing the graph to update any internal label indices.- Overrides:
addVertexLabelsin classAbstractTinkerGraph- Parameters:
vertex- the vertex to which labels were addedlabelsAdded- the labels that were newly added to the vertex
-
removeVertexLabels
Description copied from class:AbstractTinkerGraphCalled when one or more labels have been removed from an existing vertex, allowing the graph to update any internal label indices.- Overrides:
removeVertexLabelsin classAbstractTinkerGraph- Parameters:
vertex- the vertex from which labels were removedlabelsRemoved- the labels that were actually removed from the vertex
-
doClear
protected void doClear()Description copied from class:AbstractTinkerGraphImplementation ofAbstractTinkerGraph.clear(). Subclasses that hold more data extend it and call this one.- Overrides:
doClearin classAbstractTinkerGraph
-
doTx
Description copied from class:AbstractTinkerGraphImplementation ofAbstractTinkerGraph.tx(), called once the graph is known to be open. Element reads and iterators already being consumed also call it after the graph is closed, so they can keep reading the in-memory state as it stood at close.- Specified by:
doTxin classAbstractTinkerGraph
-
doGetVerticesCount
protected int doGetVerticesCount()Description copied from class:AbstractTinkerGraphImplementation ofAbstractTinkerGraph.getVerticesCount(), called once the graph is known to be open.- Specified by:
doGetVerticesCountin classAbstractTinkerGraph
-
doHasVertex
Description copied from class:AbstractTinkerGraphImplementation ofAbstractTinkerGraph.hasVertex(java.lang.Object), called once the graph is known to be open.- Specified by:
doHasVertexin classAbstractTinkerGraph
-
doGetEdgesCount
protected int doGetEdgesCount()Description copied from class:AbstractTinkerGraphImplementation ofAbstractTinkerGraph.getEdgesCount(), called once the graph is known to be open.- Specified by:
doGetEdgesCountin classAbstractTinkerGraph
-
doHasEdge
Description copied from class:AbstractTinkerGraphImplementation ofAbstractTinkerGraph.hasEdge(java.lang.Object), called once the graph is known to be open.- Specified by:
doHasEdgein classAbstractTinkerGraph
-
getServiceRegistry
Description copied from interface:TinkerGraphGets the registry of service factories forcall()steps.- Returns:
- The registry of callable services
-
doVertex
Description copied from class:AbstractTinkerGraphImplementation ofAbstractTinkerGraph.vertex(java.lang.Object), called once the graph is known to be open. Element reads and iterators already being consumed also call it after the graph is closed, so they can keep reading the in-memory state as it stood at close.- Specified by:
doVertexin classAbstractTinkerGraph
-
doVertices
Description copied from class:AbstractTinkerGraphImplementation ofAbstractTinkerGraph.vertices(java.lang.Object...), called once the graph is known to be open. Element reads and iterators already being consumed also call it after the graph is closed, so they can keep reading the in-memory state as it stood at close.- Specified by:
doVerticesin classAbstractTinkerGraph
-
doEdges
Description copied from class:AbstractTinkerGraphImplementation ofAbstractTinkerGraph.edges(java.lang.Object...), called once the graph is known to be open. Element reads and iterators already being consumed also call it after the graph is closed, so they can keep reading the in-memory state as it stood at close.- Specified by:
doEdgesin classAbstractTinkerGraph
-
doEdge
Description copied from class:AbstractTinkerGraphImplementation ofAbstractTinkerGraph.edge(java.lang.Object), called once the graph is known to be open. Element reads and iterators already being consumed also call it after the graph is closed, so they can keep reading the in-memory state as it stood at close.- Specified by:
doEdgein classAbstractTinkerGraph
-
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. -
doCreateIndex
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.- Specified by:
doCreateIndexin classAbstractTinkerGraph- Type Parameters:
E- The type of the element class- Parameters:
key- the property key to indexelementClass- the element class to index
-
doDropIndex
- Specified by:
doDropIndexin classAbstractTinkerGraph- 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
-