public class BatchGraph<G extends Graph> extends Object implements Graph
BatchGraph is a wrapper that enables batch loading of a large number of edges and vertices by chunking the entire
load into smaller batches and maintaining a sideEffects-efficient vertex cache so that the entire transactional state can
be flushed after each chunk is loaded.
BatchGraph is ONLY meant for loading data and does not support any retrieval or removal operations.
That is, BatchGraph only supports the following methods:
- addVertex(Object...) for adding vertices
- Vertex.addEdge(String, org.apache.tinkerpop.gremlin.structure.Vertex, Object...) for adding edges
- Property getter, setter and removal methods for vertices and edges.
BatchGraph can also automatically set the provided element ids as properties on the respective element. Use
BatchGraph.Builder.vertexIdKey(String) and BatchGraph.Builder.edgeIdKey(String) to set the keys
for the vertex and edge properties respectively. This allows to make the loaded baseGraph compatible for later
operation with org.apache.tinkerpop.gremlin.structure.strategy.IdStrategy.
BatchGraph itself is not a org.apache.tinkerpop.gremlin.structure.strategy.GraphStrategy because
it requires that the Vertex implementation not hold on to the underlying Vertex reference and
org.apache.tinkerpop.gremlin.structure.strategy.StrategyVertex does that by it's very nature. While it might
be possible to work around this issue, it is likely better for performance to simply leave this as a "half-wrapper"
implementation, instead of forcing it into a org.apache.tinkerpop.gremlin.structure.strategy.GraphStrategy.| Modifier and Type | Class and Description |
|---|---|
static class |
BatchGraph.Builder<G extends Graph> |
Graph.Exceptions, Graph.Features, Graph.Helper, Graph.Hidden, Graph.Io, Graph.OptIn, Graph.OptIns, Graph.OptOut, Graph.OptOuts, Graph.Variables| Modifier and Type | Field and Description |
|---|---|
static long |
DEFAULT_BUFFER_SIZE
Default buffer size is 10000.
|
| Modifier and Type | Method and Description |
|---|---|
Vertex |
addVertex(Object... keyValues)
Add a
Vertex to the graph given an optional series of key/value pairs. |
static <T extends Graph> |
build(T g) |
void |
close() |
GraphComputer |
compute() |
<C extends GraphComputer> |
compute(Class<C> graphComputerClass)
Declare the
GraphComputer to use for OLAP operations on the graph. |
Configuration |
configuration()
Get the
org.apache.commons.configuration.Configuration associated with the construction of this graph. |
Iterator<Edge> |
edges(Object... edgeIds)
Get the
Edge objects in this graph with the provided edge ids. |
Graph.Features |
features()
Gets the
Graph.Features exposed by the underlying Graph implementation. |
Transaction |
tx()
Configure and control the transactions for those graphs that support this feature.
|
Graph.Variables |
variables()
A collection of global
Graph.Variables associated with the graph. |
Iterator<Vertex> |
vertices(Object... vertexIds)
Get the
Vertex objects in this graph with the provided vertex ids. |
public static final long DEFAULT_BUFFER_SIZE
public Iterator<Vertex> vertices(Object... vertexIds)
GraphVertex objects in this graph with the provided vertex ids. If no ids are provided, get all vertices.public Iterator<Edge> edges(Object... edgeIds)
GraphEdge objects in this graph with the provided edge ids. If no ids are provided, get all edges.public <C extends GraphComputer> C compute(Class<C> graphComputerClass)
GraphGraphComputer to use for OLAP operations on the graph.
If the graph does not support graph computer then an UnsupportedOperationException is thrown.public GraphComputer compute()
public Transaction tx()
Graphpublic Graph.Variables variables()
GraphGraph.Variables associated with the graph.
Variables are used for storing metadata about the graph.public Configuration configuration()
Graphorg.apache.commons.configuration.Configuration associated with the construction of this graph.
Whatever configuration was passed to org.apache.tinkerpop.gremlin.structure.util.GraphFactory#open(org.apache.commons.configuration.Configuration)
is what should be returned by this method.configuration in interface Graphpublic Graph.Features features()
GraphGraph.Features exposed by the underlying Graph implementation.public void close()
throws Exception
close in interface AutoCloseableExceptionpublic static <T extends Graph> BatchGraph.Builder build(T g)
Copyright © 2013–2015 Apache Software Foundation. All rights reserved.