Class GryoReader
- java.lang.Object
-
- org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader
-
- All Implemented Interfaces:
GraphReader
public final class GryoReader extends Object implements GraphReader
TheGraphReader
for the Gremlin Structure serialization format based on Kryo. The format is meant to be non-lossy in terms of Gremlin Structure to Gremlin Structure migrations (assuming both structure implementations support the same graph features). This implementation is not thread-safe. Have oneGryoReader
instance per thread.- Author:
- Stephen Mallette (http://stephen.genoprime.com), Marko A. Rodriguez (http://markorodriguez.com)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GryoReader.Builder
-
Nested classes/interfaces inherited from interface org.apache.tinkerpop.gremlin.structure.io.GraphReader
GraphReader.ReaderBuilder<T extends GraphReader>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static GryoReader.Builder
build()
Edge
readEdge(InputStream inputStream, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Edge>,Edge> edgeAttachMethod)
Read anEdge
from output generated byGryoWriter.writeEdge(OutputStream, Edge)
or via anEdge
passed toGryoWriter.writeObject(OutputStream, Object)
.void
readGraph(InputStream inputStream, Graph graphToWriteTo)
Read data into aGraph
from output generated by any of theGryoWriter
writeVertex
orwriteVertices
methods or byGryoWriter.writeGraph(OutputStream, Graph)
.<C> C
readObject(InputStream inputStream, Class<? extends C> clazz)
Reads an arbitrary object using the registered serializers.Property
readProperty(InputStream inputStream, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Property>,Property> propertyAttachMethod)
Read aProperty
from output generated byGryoWriter.writeProperty(OutputStream, Property)
or via anProperty
passed toGryoWriter.writeObject(OutputStream, Object)
.Vertex
readVertex(InputStream inputStream, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Vertex>,Vertex> vertexAttachMethod)
Read aVertex
from output generated by any of theGryoWriter
writeVertex
orwriteVertices
methods or byGryoWriter.writeGraph(OutputStream, Graph)
.Vertex
readVertex(InputStream inputStream, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Vertex>,Vertex> vertexAttachMethod, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Edge>,Edge> edgeAttachMethod, Direction attachEdgesOfThisDirection)
Read aVertex
from output generated by any of theGryoWriter
writeVertex
orwriteVertices
methods or byGryoWriter.writeGraph(OutputStream, Graph)
.Optional<Vertex>
readVertex(InputStream inputStream, GraphFilter graphFilter)
Reads a single vertex from anInputStream
.VertexProperty
readVertexProperty(InputStream inputStream, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<VertexProperty>,VertexProperty> vertexPropertyAttachMethod)
Read aVertexProperty
from output generated byGryoWriter.writeVertexProperty(OutputStream, VertexProperty)
or via anVertexProperty
passed toGryoWriter.writeObject(OutputStream, Object)
.Iterator<Vertex>
readVertices(InputStream inputStream, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Vertex>,Vertex> vertexAttachMethod, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Edge>,Edge> edgeAttachMethod, Direction attachEdgesOfThisDirection)
ReadVertex
objects from output generated by any of theGryoWriter
writeVertex
orwriteVertices
methods or byGryoWriter.writeGraph(OutputStream, Graph)
.
-
-
-
Method Detail
-
readGraph
public void readGraph(InputStream inputStream, Graph graphToWriteTo) throws IOException
Read data into aGraph
from output generated by any of theGryoWriter
writeVertex
orwriteVertices
methods or byGryoWriter.writeGraph(OutputStream, Graph)
.- Specified by:
readGraph
in interfaceGraphReader
- Parameters:
inputStream
- a stream containing an entire graph of vertices and edges as defined by the accompanyingGraphWriter.writeGraph(OutputStream, Graph)
.graphToWriteTo
- the graph to write to when reading from the stream.- Throws:
IOException
-
readVertex
public Optional<Vertex> readVertex(InputStream inputStream, GraphFilter graphFilter) throws IOException
Description copied from interface:GraphReader
Reads a single vertex from anInputStream
. This method will filter the read the read vertex by the providedGraphFilter
. If the graph filter will filter the vertex itself, then the returnedOptional
is empty.- Specified by:
readVertex
in interfaceGraphReader
- Parameters:
inputStream
- a stream containing at least a single vertex as defined by the accompanyingGraphWriter.writeVertex(OutputStream, Vertex)
.graphFilter
- TheGraphFilter
to filter the vertex and its associated edges by.- Returns:
- the vertex with filtered edges or
Optional.empty()
if the vertex itself was filtered. - Throws:
IOException
-
readVertices
public Iterator<Vertex> readVertices(InputStream inputStream, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Vertex>,Vertex> vertexAttachMethod, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Edge>,Edge> edgeAttachMethod, Direction attachEdgesOfThisDirection) throws IOException
ReadVertex
objects from output generated by any of theGryoWriter
writeVertex
orwriteVertices
methods or byGryoWriter.writeGraph(OutputStream, Graph)
.- Specified by:
readVertices
in interfaceGraphReader
- Parameters:
inputStream
- a stream containing at least oneVertex
as defined by the accompanyingGraphWriter.writeVertices(OutputStream, Iterator, Direction)
orGraphWriter.writeVertices(OutputStream, Iterator)
methods.vertexAttachMethod
- a function that creates re-attaches aVertex
to aHost
object.edgeAttachMethod
- a function that creates re-attaches aEdge
to aHost
object.attachEdgesOfThisDirection
- only edges of this direction are passed to theedgeMaker
.- Throws:
IOException
-
readVertex
public Vertex readVertex(InputStream inputStream, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Vertex>,Vertex> vertexAttachMethod) throws IOException
Read aVertex
from output generated by any of theGryoWriter
writeVertex
orwriteVertices
methods or byGryoWriter.writeGraph(OutputStream, Graph)
.- Specified by:
readVertex
in interfaceGraphReader
- Parameters:
inputStream
- a stream containing at least a single vertex as defined by the accompanyingGraphWriter.writeVertex(OutputStream, Vertex)
.vertexAttachMethod
- a function that creates re-attaches aVertex
to aHost
object.- Throws:
IOException
-
readVertex
public Vertex readVertex(InputStream inputStream, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Vertex>,Vertex> vertexAttachMethod, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Edge>,Edge> edgeAttachMethod, Direction attachEdgesOfThisDirection) throws IOException
Read aVertex
from output generated by any of theGryoWriter
writeVertex
orwriteVertices
methods or byGryoWriter.writeGraph(OutputStream, Graph)
.- Specified by:
readVertex
in interfaceGraphReader
- Parameters:
inputStream
- a stream containing at least oneVertex
as defined by the accompanyingGraphWriter.writeVertices(OutputStream, Iterator, Direction)
method.vertexAttachMethod
- a function that creates re-attaches aVertex
to aHost
object.edgeAttachMethod
- a function that creates re-attaches aEdge
to aHost
object.attachEdgesOfThisDirection
- only edges of this direction are passed to theedgeMaker
.- Throws:
IOException
-
readEdge
public Edge readEdge(InputStream inputStream, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Edge>,Edge> edgeAttachMethod) throws IOException
Read anEdge
from output generated byGryoWriter.writeEdge(OutputStream, Edge)
or via anEdge
passed toGryoWriter.writeObject(OutputStream, Object)
.- Specified by:
readEdge
in interfaceGraphReader
- Parameters:
inputStream
- a stream containing at least oneEdge
as defined by the accompanyingGraphWriter.writeEdge(OutputStream, Edge)
method.edgeAttachMethod
- a function that creates re-attaches aEdge
to aHost
object.- Throws:
IOException
-
readVertexProperty
public VertexProperty readVertexProperty(InputStream inputStream, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<VertexProperty>,VertexProperty> vertexPropertyAttachMethod) throws IOException
Read aVertexProperty
from output generated byGryoWriter.writeVertexProperty(OutputStream, VertexProperty)
or via anVertexProperty
passed toGryoWriter.writeObject(OutputStream, Object)
.- Specified by:
readVertexProperty
in interfaceGraphReader
- Parameters:
inputStream
- a stream containing at least oneVertexProperty
as written by the accompanyingGraphWriter.writeVertexProperty(OutputStream, VertexProperty)
method.vertexPropertyAttachMethod
- a function that creates re-attaches aVertexProperty
to aHost
object.- Returns:
- the value returned by the attach method.
- Throws:
IOException
-
readProperty
public Property readProperty(InputStream inputStream, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Property>,Property> propertyAttachMethod) throws IOException
Read aProperty
from output generated byGryoWriter.writeProperty(OutputStream, Property)
or via anProperty
passed toGryoWriter.writeObject(OutputStream, Object)
.- Specified by:
readProperty
in interfaceGraphReader
- Parameters:
inputStream
- a stream containing at least oneProperty
as written by the accompanyingGraphWriter.writeProperty(OutputStream, Property)
method.propertyAttachMethod
- a function that creates re-attaches aProperty
to aHost
object.- Returns:
- the value returned by the attach method.
- Throws:
IOException
-
readObject
public <C> C readObject(InputStream inputStream, Class<? extends C> clazz) throws IOException
Reads an arbitrary object using the registered serializers.- Specified by:
readObject
in interfaceGraphReader
- Parameters:
inputStream
- a stream containing an object.clazz
- the class expected to be in the stream - may or may not be used by the underlying implementation.- Throws:
IOException
-
build
public static GryoReader.Builder build()
-
-