Class TinkerGraph
- java.lang.Object
-
- org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph
-
- All Implemented Interfaces:
AutoCloseable,Graph,Host
public final class TinkerGraph extends Object implements Graph
An in-memory (with optional persistence on calls toclose()), reference implementation of the property graph interfaces provided by TinkerPop.- Author:
- Marko A. Rodriguez (http://markorodriguez.com), Stephen Mallette (http://stephen.genoprime.com)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTinkerGraph.DefaultIdManagerA default set ofTinkerGraph.IdManagerimplementations for common identifier types.static interfaceTinkerGraph.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.classTinkerGraph.TinkerGraphEdgeFeaturesclassTinkerGraph.TinkerGraphFeaturesclassTinkerGraph.TinkerGraphGraphFeaturesclassTinkerGraph.TinkerGraphVertexFeaturesclassTinkerGraph.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
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description VertexaddVertex(Object... keyValues)Add aVertexto the graph given an optional series of key/value pairs.voidclear()voidclose()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.<E extends Element>
voidcreateIndex(String key, Class<E> elementClass)<E extends Element>
voiddropIndex(String key, Class<E> elementClass)Iterator<Edge>edges(Object... edgeIds)Graph.Featuresfeatures()Return TinkerGraph feature set.<E extends Element>
Set<String>getIndexedKeys(Class<E> elementClass)TinkerServiceRegistrygetServiceRegistry()Get theServiceRegistryassociated with the graph.<I extends Io>
Iio(Io.Builder<I> builder)Construct a particularIoimplementation for reading and writing theGraphand other data.static TinkerGraphopen()Open a newTinkerGraphinstance.static TinkerGraphopen(org.apache.commons.configuration2.Configuration configuration)Open a newTinkerGraphinstance.StringtoString()Transactiontx()Configure and control the transactions for those graphs that support this feature.Graph.Variablesvariables()A collection of globalGraph.Variablesassociated with the graph.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 org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIndex<TinkerVertex> vertexIndex
-
edgeIndex
protected org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIndex<TinkerEdge> edgeIndex
-
vertexIdManager
protected final TinkerGraph.IdManager<?> vertexIdManager
-
edgeIdManager
protected final TinkerGraph.IdManager<?> edgeIdManager
-
vertexPropertyIdManager
protected final TinkerGraph.IdManager<?> vertexPropertyIdManager
-
defaultVertexPropertyCardinality
protected final VertexProperty.Cardinality defaultVertexPropertyCardinality
-
allowNullPropertyValues
protected final boolean allowNullPropertyValues
-
serviceRegistry
protected final TinkerServiceRegistry serviceRegistry
-
-
Method Detail
-
open
public static TinkerGraph open()
Open a newTinkerGraphinstance. 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 TinkerGraph. It is not enforced by the Gremlin Test Suite.
-
open
public static TinkerGraph open(org.apache.commons.configuration2.Configuration configuration)
Open a newTinkerGraphinstance. 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
-
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.
-
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.
-
clear
public void clear()
-
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
-
tx
public Transaction tx()
Description copied from interface:GraphConfigure and control the transactions for those graphs that support this feature.
-
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.
-
getServiceRegistry
public TinkerServiceRegistry getServiceRegistry()
Description copied from interface:GraphGet theServiceRegistryassociated with the graph. Used byCallStepto invoke service calls.- Specified by:
getServiceRegistryin interfaceGraph- Returns:
- The registry of callable services
-
vertices
public Iterator<Vertex> vertices(Object... vertexIds)
Description copied from interface:GraphGet 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")
-
edges
public Iterator<Edge> edges(Object... edgeIds)
Description copied from interface:GraphGet 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")
-
features
public Graph.Features 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.
-
createIndex
public <E extends Element> void createIndex(String key, Class<E> elementClass)
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.- Type Parameters:
E- The type of the element class- Parameters:
key- the property key to indexelementClass- the element class to index
-
dropIndex
public <E extends Element> void dropIndex(String key, Class<E> elementClass)
- 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
-
-