Class AbstractTinkerGraph
java.lang.Object
org.apache.tinkerpop.gremlin.tinkergraph.structure.AbstractTinkerGraph
- All Implemented Interfaces:
AutoCloseable,Graph,Host
- Direct Known Subclasses:
TinkerGraph,TinkerTransactionGraph
Base class for
TinkerGraph and TinkerTransactionGraph.
Contains common methods, variables and constants, but leaves the work with elements and indices
to concrete implementations.- Author:
- Valentyn Kahamlyk
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumA default set ofAbstractTinkerGraph.IdManagerimplementations for common identifier types.static interfaceTinkerGraph will use an implementation of this interface to generate identifiers when a user does not supply them and to handle identifier conversions when querying to provide better flexibility with respect to handling different data types that mean the same thing.classclassclassNested 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
FieldsModifier and TypeFieldDescriptionprotected booleanprotected org.apache.commons.configuration2.Configurationprotected AtomicLongprotected Stringprotected Stringprotected VertexProperty.Cardinalityprotected AbstractTinkerGraph.IdManager<Edge>protected AbstractTinkerIndex<TinkerEdge>protected LabelCardinalityprotected TinkerGraphComputerViewprotected Stringprotected Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected TinkerServiceRegistryprotected TinkerGraphVariablesprotected AbstractTinkerGraph.IdManager<Vertex>protected AbstractTinkerIndex<TinkerVertex>protected LabelCardinalityprotected Map<Object,VertexProperty> protected AbstractTinkerGraph.IdManager<VertexProperty> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract EdgeaddEdge(TinkerVertex outVertex, TinkerVertex inVertex, String label, Object... keyValues) abstract voidaddEdgeToAdjacency(TinkerEdge edge, String label) Add an edge to the per-vertex adjacency maps under the given label.protected abstract voidaddInEdge(TinkerVertex vertex, String label, Edge edge) protected abstract voidaddOutEdge(TinkerVertex vertex, String label, Edge edge) abstract VertexAdd aVertexto the graph given an optional series of key/value pairs.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.voidclear()Clear internal graph datavoidclose()This method only has an effect if theGREMLIN_TINKERGRAPH_GRAPH_LOCATIONis set, in which case the data in the graph is persisted to that location.compute()Generate aGraphComputerusing the default engine of the underlying graph system.<C extends GraphComputer>
CDeclare theGraphComputerto use for OLAP operations on the graph.org.apache.commons.configuration2.ConfigurationGet theConfigurationassociated with the construction of this graph.longcountEdgesByLabel(String label) Returns the number of edges with the given label.longcountVerticesByLabel(String label) Returns the number of vertices with the given label.protected TinkerEdgecreateTinkerEdge(Object id, Vertex outVertex, String label, Vertex inVertex) protected TinkerEdgecreateTinkerEdge(Object id, Vertex outVertex, String label, Vertex inVertex, long currentVersion) protected TinkerVertexcreateTinkerVertex(Object id, String label, AbstractTinkerGraph graph) protected TinkerVertexcreateTinkerVertex(Object id, String label, AbstractTinkerGraph graph, long currentVersion) protected TinkerVertexcreateTinkerVertex(Object id, Set<String> labels, AbstractTinkerGraph graph) Creates a TinkerVertex with multiple labels.abstract EdgeReturnEdgeby id.abstract intGraph-specific implementation for number of vertices.getIndexedKeys(Class<E> elementClass) abstract intGraph-specific implementation for number of vertices.abstract booleanabstract booleanbooleanReturns true if aVertexPropertywith the given identifier exists in this graph.index()Returns theGraph.Indexaccessor for this graph.instantiate(String className) <I extends Io>
Iio(Io.Builder<I> builder) Construct a particularIoimplementation for reading and writing theGraphand other data.protected voidabstract voidremoveEdge(Object edgeId) abstract voidremoveEdgeFromAdjacency(TinkerEdge edge, String label) Remove an edge from the per-vertex adjacency maps for the given label.abstract voidremoveVertex(Object vertexId) 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.protected voidprotected static <T extends Element>
AbstractTinkerGraph.IdManager<T>selectIdManager(org.apache.commons.configuration2.Configuration config, String configKey, Class<T> clazz) Construct anAbstractTinkerGraph.IdManagerfrom the TinkerGraphConfiguration.toString()voidtouch(TinkerEdge edge) MarkEdgeas changed in transaction.voidtouch(TinkerVertex vertex) MarkVertexas changed in transaction.abstract Transactiontx()Configure and control the transactions for those graphs that support this feature.A collection of globalGraph.Variablesassociated with the graph.abstract VertexReturnVertexby id.
-
Field Details
-
GREMLIN_TINKERGRAPH_VERTEX_ID_MANAGER
- See Also:
-
GREMLIN_TINKERGRAPH_EDGE_ID_MANAGER
- See Also:
-
GREMLIN_TINKERGRAPH_VERTEX_PROPERTY_ID_MANAGER
- See Also:
-
GREMLIN_TINKERGRAPH_DEFAULT_VERTEX_PROPERTY_CARDINALITY
- See Also:
-
GREMLIN_TINKERGRAPH_GRAPH_LOCATION
- See Also:
-
GREMLIN_TINKERGRAPH_GRAPH_FORMAT
- See Also:
-
GREMLIN_TINKERGRAPH_ALLOW_NULL_PROPERTY_VALUES
- See Also:
-
GREMLIN_TINKERGRAPH_SERVICE
- See Also:
-
GREMLIN_TINKERGRAPH_VERTEX_LABEL_CARDINALITY
- See Also:
-
currentId
-
vertexProperties
-
variables
-
graphComputerView
-
vertexIndex
-
edgeIndex
-
vertexIdManager
-
edgeIdManager
-
vertexPropertyIdManager
-
defaultVertexPropertyCardinality
-
allowNullPropertyValues
protected boolean allowNullPropertyValues -
vertexLabelCardinality
-
edgeLabelCardinality
-
defaultVertexLabel
-
defaultEdgeLabel
-
serviceRegistry
-
configuration
protected org.apache.commons.configuration2.Configuration configuration -
graphLocation
-
graphFormat
-
-
Constructor Details
-
AbstractTinkerGraph
public AbstractTinkerGraph()
-
-
Method Details
-
addVertex
-
removeVertex
-
addEdge
public abstract Edge addEdge(TinkerVertex outVertex, TinkerVertex inVertex, String label, Object... keyValues) -
removeEdge
-
touch
MarkVertexas changed in transaction. If the graph does not support transactions, then does nothing.- Parameters:
vertex-
-
touch
MarkEdgeas changed in transaction. If the graph does not support transactions, then does nothing.- Parameters:
edge-
-
vertex
ReturnVertexby id. Does not create an iterator, so is the preferred method when only 1 element needs to be returned.- Parameters:
vertexId-- Returns:
- Vertex
-
vertices
Get 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")
-
edge
ReturnEdgeby id. Does not create an iterator, so is the preferred method when only 1 element needs to be returned.- Parameters:
edgeId-- Returns:
- Edge
-
edges
Get 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")
-
tx
Configure and control the transactions for those graphs that support this feature. -
getVerticesCount
public abstract int getVerticesCount()Graph-specific implementation for number of vertices.- Returns:
- count of vertices in Graph.
-
hasVertex
-
getEdgesCount
public abstract int getEdgesCount()Graph-specific implementation for number of vertices.- Returns:
- count of vertices in Graph.
-
countVerticesByLabel
Returns 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
-
countEdgesByLabel
Returns 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
-
index
Description copied from interface:GraphReturns theGraph.Indexaccessor for this graph. The default implementation returnsGraph.Index.EMPTY, whose methods return conservative values indicating that no property index is available.Graph implementations that maintain property indexes should override this method and return an
Graph.Indexbacked by their index structures. The GQL executor uses theGraph.Indexto replace full vertex scans with targeted lookups for selective predicates. -
hasEdge
-
hasVertexProperty
Returns true if aVertexPropertywith the given identifier exists in this graph. -
loadGraph
protected void loadGraph() -
saveGraph
protected void saveGraph() -
io
Description copied from interface:GraphConstruct a particularIoimplementation for reading and writing theGraphand other data. End-users will "select" theIoimplementation that they want to use by supplying theIo.Builderthat constructs it. In this way,Graphvendors can supply theirIoRegistryto that builder thus allowing for custom serializers to be auto-configured into theIoinstance. Registering custom serializers is particularly useful for those graphs that have complex types forElementidentifiers. For those graphs that do not need to register any custom serializers, the default implementation should suffice. If the default is overridden, take care to register the current graph via theIo.Builder.graph(Graph)method. -
compute
Description copied from interface:GraphDeclare theGraphComputerto use for OLAP operations on the graph. If the graph does not support graph computer then anUnsupportedOperationExceptionis thrown. -
compute
Description copied from interface:GraphGenerate aGraphComputerusing the default engine of the underlying graph system. This is a shorthand method for the more involved method that usesGraph.compute(Class). -
variables
Description copied from interface:GraphA collection of globalGraph.Variablesassociated with the graph. Variables are used for storing metadata about the graph. -
toString
-
clear
public void clear()Clear internal graph data -
close
public void close()This method only has an effect if theGREMLIN_TINKERGRAPH_GRAPH_LOCATIONis set, in which case the data in the graph is persisted to that location. This method may be called multiple times and does not release resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceGraph
-
configuration
public org.apache.commons.configuration2.Configuration configuration()Description copied from interface:GraphGet theConfigurationassociated with the construction of this graph. Whatever configuration was passed toGraphFactory.open(Configuration)is what should be returned by this method.- Specified by:
configurationin interfaceGraph- Returns:
- the configuration used during graph construction.
-
addOutEdge
-
addInEdge
-
addEdgeToAdjacency
Add an edge to the per-vertex adjacency maps under the given label. Used when labels are added to an existing edge.- Parameters:
edge- the edge to registerlabel- the label under which to register the edge- Since:
- 4.0.0
-
removeEdgeFromAdjacency
Remove an edge from the per-vertex adjacency maps for the given label. Used when labels are removed from an existing edge.- Parameters:
edge- the edge to unregisterlabel- the label from which to unregister the edge- Since:
- 4.0.0
-
addVertexLabels
Called when one or more labels have been added to an existing vertex, allowing the graph to update any internal label indices.- Parameters:
vertex- the vertex to which labels were addedlabelsAdded- the labels that were newly added to the vertex- Since:
- 4.0.0
-
removeVertexLabels
Called when one or more labels have been removed from an existing vertex, allowing the graph to update any internal label indices.- Parameters:
vertex- the vertex from which labels were removedlabelsRemoved- the labels that were actually removed from the vertex- Since:
- 4.0.0
-
createTinkerVertex
-
createTinkerVertex
protected TinkerVertex createTinkerVertex(Object id, String label, AbstractTinkerGraph graph, long currentVersion) -
createTinkerVertex
Creates a TinkerVertex with multiple labels.- Parameters:
id- the vertex idlabels- the set of labels for the vertexgraph- the graph instance- Returns:
- a new TinkerVertex
- Since:
- 4.0.0
-
createTinkerEdge
-
createTinkerEdge
protected TinkerEdge createTinkerEdge(Object id, Vertex outVertex, String label, Vertex inVertex, long currentVersion) -
getIndexedKeys
- Type Parameters:
E- The type of the element class- Parameters:
elementClass- the element class to get the indexed keys for- Returns:
- the set of keys currently being indexed
-
selectIdManager
protected static <T extends Element> AbstractTinkerGraph.IdManager<T> selectIdManager(org.apache.commons.configuration2.Configuration config, String configKey, Class<T> clazz) Construct anAbstractTinkerGraph.IdManagerfrom the TinkerGraphConfiguration. -
instantiate
-