Class AbstractTinkerGraph
- java.lang.Object
-
- org.apache.tinkerpop.gremlin.tinkergraph.structure.AbstractTinkerGraph
-
- All Implemented Interfaces:
AutoCloseable
,Graph
,Host
- Direct Known Subclasses:
TinkerGraph
,TinkerTransactionGraph
public abstract class AbstractTinkerGraph extends Object implements Graph
Base class forTinkerGraph
andTinkerTransactionGraph
. Contains common methods, variables and constants, but leaves the work with elements and indices to concrete implementations.- Author:
- Valentyn Kahamlyk
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractTinkerGraph.DefaultIdManager
A default set ofAbstractTinkerGraph.IdManager
implementations for common identifier types.static interface
AbstractTinkerGraph.IdManager<T>
TinkerGraph 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.class
AbstractTinkerGraph.TinkerGraphEdgeFeatures
class
AbstractTinkerGraph.TinkerGraphVertexFeatures
class
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
-
Constructor Summary
Constructors Constructor Description AbstractTinkerGraph()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Edge
addEdge(TinkerVertex outVertex, TinkerVertex inVertex, String label, Object... keyValues)
protected abstract void
addInEdge(TinkerVertex vertex, String label, Edge edge)
protected abstract void
addOutEdge(TinkerVertex vertex, String label, Edge edge)
abstract Vertex
addVertex(Object... keyValues)
Add aVertex
to the graph given an optional series of key/value pairs.void
clear()
Clear internal graph datavoid
close()
This method only has an effect if theGREMLIN_TINKERGRAPH_GRAPH_LOCATION
is set, in which case the data in the graph is persisted to that location.GraphComputer
compute()
Generate aGraphComputer
using the default engine of the underlying graph system.<C extends GraphComputer>
Ccompute(Class<C> graphComputerClass)
Declare theGraphComputer
to use for OLAP operations on the graph.org.apache.commons.configuration2.Configuration
configuration()
Get theConfiguration
associated with the construction of this graph.protected TinkerEdge
createTinkerEdge(Object id, Vertex outVertex, String label, Vertex inVertex)
protected TinkerEdge
createTinkerEdge(Object id, Vertex outVertex, String label, Vertex inVertex, long currentVersion)
protected TinkerVertex
createTinkerVertex(Object id, String label, AbstractTinkerGraph graph)
protected TinkerVertex
createTinkerVertex(Object id, String label, AbstractTinkerGraph graph, long currentVersion)
abstract Edge
edge(Object edgeId)
ReturnEdge
by id.abstract Iterator<Edge>
edges(Object... edgeIds)
abstract int
getEdgesCount()
Graph-specific implementation for number of vertices.<E extends Element>
Set<String>getIndexedKeys(Class<E> elementClass)
abstract int
getVerticesCount()
Graph-specific implementation for number of vertices.abstract boolean
hasEdge(Object id)
abstract boolean
hasVertex(Object id)
protected TinkerServiceRegistry.TinkerServiceFactory
instantiate(String className)
<I extends Io>
Iio(Io.Builder<I> builder)
Construct a particularIo
implementation for reading and writing theGraph
and other data.protected void
loadGraph()
abstract void
removeEdge(Object edgeId)
abstract void
removeVertex(Object vertexId)
protected void
saveGraph()
protected static <T extends Element>
AbstractTinkerGraph.IdManager<T>selectIdManager(org.apache.commons.configuration2.Configuration config, String configKey, Class<T> clazz)
Construct anAbstractTinkerGraph.IdManager
from the TinkerGraphConfiguration
.String
toString()
void
touch(TinkerEdge edge)
MarkEdge
as changed in transaction.void
touch(TinkerVertex vertex)
MarkVertex
as changed in transaction.abstract Transaction
tx()
Configure and control the transactions for those graphs that support this feature.Graph.Variables
variables()
A collection of globalGraph.Variables
associated with the graph.abstract Vertex
vertex(Object vertexId)
ReturnVertex
by id.abstract Iterator<Vertex>
vertices(Object... vertexIds)
-
-
-
Field Detail
-
GREMLIN_TINKERGRAPH_VERTEX_ID_MANAGER
public static final String GREMLIN_TINKERGRAPH_VERTEX_ID_MANAGER
- See Also:
- Constant Field Values
-
GREMLIN_TINKERGRAPH_EDGE_ID_MANAGER
public static final String GREMLIN_TINKERGRAPH_EDGE_ID_MANAGER
- See Also:
- Constant Field Values
-
GREMLIN_TINKERGRAPH_VERTEX_PROPERTY_ID_MANAGER
public static final String GREMLIN_TINKERGRAPH_VERTEX_PROPERTY_ID_MANAGER
- See Also:
- Constant Field Values
-
GREMLIN_TINKERGRAPH_DEFAULT_VERTEX_PROPERTY_CARDINALITY
public static final String GREMLIN_TINKERGRAPH_DEFAULT_VERTEX_PROPERTY_CARDINALITY
- See Also:
- Constant Field Values
-
GREMLIN_TINKERGRAPH_GRAPH_LOCATION
public static final String GREMLIN_TINKERGRAPH_GRAPH_LOCATION
- See Also:
- Constant Field Values
-
GREMLIN_TINKERGRAPH_GRAPH_FORMAT
public static final String GREMLIN_TINKERGRAPH_GRAPH_FORMAT
- See Also:
- Constant Field Values
-
GREMLIN_TINKERGRAPH_ALLOW_NULL_PROPERTY_VALUES
public static final String GREMLIN_TINKERGRAPH_ALLOW_NULL_PROPERTY_VALUES
- See Also:
- Constant Field Values
-
GREMLIN_TINKERGRAPH_SERVICE
public static final String GREMLIN_TINKERGRAPH_SERVICE
- See Also:
- Constant Field Values
-
currentId
protected AtomicLong currentId
-
variables
protected TinkerGraphVariables variables
-
graphComputerView
protected TinkerGraphComputerView graphComputerView
-
vertexIndex
protected AbstractTinkerIndex<TinkerVertex> vertexIndex
-
edgeIndex
protected AbstractTinkerIndex<TinkerEdge> edgeIndex
-
vertexIdManager
protected AbstractTinkerGraph.IdManager<Vertex> vertexIdManager
-
edgeIdManager
protected AbstractTinkerGraph.IdManager<Edge> edgeIdManager
-
vertexPropertyIdManager
protected AbstractTinkerGraph.IdManager<VertexProperty> vertexPropertyIdManager
-
defaultVertexPropertyCardinality
protected VertexProperty.Cardinality defaultVertexPropertyCardinality
-
allowNullPropertyValues
protected boolean allowNullPropertyValues
-
serviceRegistry
protected TinkerServiceRegistry serviceRegistry
-
configuration
protected org.apache.commons.configuration2.Configuration configuration
-
graphLocation
protected String graphLocation
-
graphFormat
protected String graphFormat
-
-
Method Detail
-
removeVertex
public abstract void removeVertex(Object vertexId)
-
addEdge
public abstract Edge addEdge(TinkerVertex outVertex, TinkerVertex inVertex, String label, Object... keyValues)
-
removeEdge
public abstract void removeEdge(Object edgeId)
-
touch
public void touch(TinkerVertex vertex)
MarkVertex
as changed in transaction. If the graph does not support transactions, then does nothing.- Parameters:
vertex
-
-
touch
public void touch(TinkerEdge edge)
MarkEdge
as changed in transaction. If the graph does not support transactions, then does nothing.- Parameters:
edge
-
-
vertex
public abstract Vertex vertex(Object vertexId)
ReturnVertex
by id. Does not create an iterator, so is the preferred method when only 1 element needs to be returned.- Parameters:
vertexId
-- Returns:
- Vertex
-
vertices
public abstract Iterator<Vertex> vertices(Object... vertexIds)
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")
-
edge
public abstract Edge edge(Object edgeId)
ReturnEdge
by id. Does not create an iterator, so is the preferred method when only 1 element needs to be returned.- Parameters:
edgeId
-- Returns:
- Edge
-
edges
public abstract Iterator<Edge> edges(Object... edgeIds)
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")
-
tx
public abstract Transaction 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
public abstract boolean hasVertex(Object id)
-
getEdgesCount
public abstract int getEdgesCount()
Graph-specific implementation for number of vertices.- Returns:
- count of vertices in Graph.
-
hasEdge
public abstract boolean hasEdge(Object id)
-
loadGraph
protected void loadGraph()
-
saveGraph
protected void saveGraph()
-
io
public <I extends Io> I io(Io.Builder<I> builder)
Description copied from interface:Graph
Construct a particularIo
implementation for reading and writing theGraph
and other data. End-users will "select" theIo
implementation that they want to use by supplying theIo.Builder
that constructs it. In this way,Graph
vendors can supply theirIoRegistry
to that builder thus allowing for custom serializers to be auto-configured into theIo
instance. Registering custom serializers is particularly useful for those graphs that have complex types forElement
identifiers. 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
public <C extends GraphComputer> C compute(Class<C> graphComputerClass)
Description copied from interface:Graph
Declare theGraphComputer
to use for OLAP operations on the graph. If the graph does not support graph computer then anUnsupportedOperationException
is thrown.
-
compute
public GraphComputer compute()
Description copied from interface:Graph
Generate aGraphComputer
using the default engine of the underlying graph system. This is a shorthand method for the more involved method that usesGraph.compute(Class)
.
-
variables
public Graph.Variables variables()
Description copied from interface:Graph
A collection of globalGraph.Variables
associated with the graph. Variables are used for storing metadata about the graph.
-
clear
public void clear()
Clear internal graph data
-
close
public void close()
This method only has an effect if theGREMLIN_TINKERGRAPH_GRAPH_LOCATION
is 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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceGraph
-
configuration
public org.apache.commons.configuration2.Configuration configuration()
Description copied from interface:Graph
Get theConfiguration
associated with the construction of this graph. Whatever configuration was passed toGraphFactory.open(Configuration)
is what should be returned by this method.- Specified by:
configuration
in interfaceGraph
- Returns:
- the configuration used during graph construction.
-
addOutEdge
protected abstract void addOutEdge(TinkerVertex vertex, String label, Edge edge)
-
addInEdge
protected abstract void addInEdge(TinkerVertex vertex, String label, Edge edge)
-
createTinkerVertex
protected TinkerVertex createTinkerVertex(Object id, String label, AbstractTinkerGraph graph)
-
createTinkerVertex
protected TinkerVertex createTinkerVertex(Object id, String label, AbstractTinkerGraph graph, long currentVersion)
-
createTinkerEdge
protected TinkerEdge createTinkerEdge(Object id, Vertex outVertex, String label, Vertex inVertex)
-
createTinkerEdge
protected TinkerEdge createTinkerEdge(Object id, Vertex outVertex, String label, Vertex inVertex, long currentVersion)
-
getIndexedKeys
public <E extends Element> Set<String> getIndexedKeys(Class<E> elementClass)
- 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.IdManager
from the TinkerGraphConfiguration
.
-
instantiate
protected TinkerServiceRegistry.TinkerServiceFactory instantiate(String className)
-
-