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)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()<C extends GraphComputer>
Ccompute(Class<C> graphComputerClass)org.apache.commons.configuration2.Configurationconfiguration()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)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()Graph.Variablesvariables()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
-
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
-
tx
public abstract Transaction tx()
-
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)
-
compute
public <C extends GraphComputer> C compute(Class<C> graphComputerClass)
-
compute
public GraphComputer compute()
-
variables
public Graph.Variables variables()
-
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()
- Specified by:
configurationin interfaceGraph
-
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)
-
-