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 forTinkerGraphandTinkerTransactionGraph. 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 classAbstractTinkerGraph.DefaultIdManagerA default set ofAbstractTinkerGraph.IdManagerimplementations for common identifier types.static interfaceAbstractTinkerGraph.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.classAbstractTinkerGraph.TinkerGraphEdgeFeaturesclassAbstractTinkerGraph.TinkerGraphVertexFeaturesclassAbstractTinkerGraph.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 EdgeaddEdge(TinkerVertex outVertex, TinkerVertex inVertex, String label, Object... keyValues)protected abstract voidaddInEdge(TinkerVertex vertex, String label, Edge edge)protected abstract voidaddOutEdge(TinkerVertex vertex, String label, Edge edge)abstract VertexaddVertex(Object... keyValues)Add aVertexto the graph given an optional series of key/value pairs.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.GraphComputercompute()Generate aGraphComputerusing the default engine of the underlying graph system.<C extends GraphComputer>
Ccompute(Class<C> graphComputerClass)Declare theGraphComputerto use for OLAP operations on the graph.org.apache.commons.configuration2.Configurationconfiguration()Get theConfigurationassociated with the construction of this graph.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)abstract Edgeedge(Object edgeId)ReturnEdgeby id.abstract Iterator<Edge>edges(Object... edgeIds)abstract intgetEdgesCount()Graph-specific implementation for number of vertices.<E extends Element>
Set<String>getIndexedKeys(Class<E> elementClass)abstract intgetVerticesCount()Graph-specific implementation for number of vertices.abstract booleanhasEdge(Object id)abstract booleanhasVertex(Object id)protected TinkerServiceRegistry.TinkerServiceFactoryinstantiate(String className)<I extends Io>
Iio(Io.Builder<I> builder)Construct a particularIoimplementation for reading and writing theGraphand other data.protected voidloadGraph()abstract voidremoveEdge(Object edgeId)abstract voidremoveVertex(Object vertexId)protected voidsaveGraph()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.StringtoString()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.Graph.Variablesvariables()A collection of globalGraph.Variablesassociated with the graph.abstract Vertexvertex(Object vertexId)ReturnVertexby 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)
MarkVertexas changed in transaction. If the graph does not support transactions, then does nothing.- Parameters:
vertex-
-
touch
public void touch(TinkerEdge edge)
MarkEdgeas changed in transaction. If the graph does not support transactions, then does nothing.- Parameters:
edge-
-
vertex
public abstract Vertex vertex(Object vertexId)
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
public abstract Iterator<Vertex> vertices(Object... vertexIds)
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
public abstract Edge edge(Object edgeId)
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
public abstract Iterator<Edge> edges(Object... edgeIds)
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
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: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
public <C extends GraphComputer> C compute(Class<C> graphComputerClass)
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
public GraphComputer 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
public Graph.Variables variables()
Description copied from interface:GraphA collection of globalGraph.Variablesassociated 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_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
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.IdManagerfrom the TinkerGraphConfiguration.
-
instantiate
protected TinkerServiceRegistry.TinkerServiceFactory instantiate(String className)
-
-