Class GryoReader
java.lang.Object
org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader
- All Implemented Interfaces:
GraphReader
The
GraphReader 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 one GryoReader instance per thread.- Author:
- Stephen Mallette (http://stephen.genoprime.com), Marko A. Rodriguez (http://markorodriguez.com)
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.apache.tinkerpop.gremlin.structure.io.GraphReader
GraphReader.ReaderBuilder<T extends GraphReader> -
Method Summary
Modifier and TypeMethodDescriptionstatic GryoReader.Builderbuild()readEdge(InputStream inputStream, Function<Attachable<Edge>, Edge> edgeAttachMethod) Read anEdgefrom output generated byGryoWriter.writeEdge(OutputStream, Edge)or via anEdgepassed toGryoWriter.writeObject(OutputStream, Object).voidreadGraph(InputStream inputStream, Graph graphToWriteTo) Read data into aGraphfrom output generated by any of theGryoWriterwriteVertexorwriteVerticesmethods or byGryoWriter.writeGraph(OutputStream, Graph).<C> CreadObject(InputStream inputStream, Class<? extends C> clazz) Reads an arbitrary object using the registered serializers.readProperty(InputStream inputStream, Function<Attachable<Property>, Property> propertyAttachMethod) Read aPropertyfrom output generated byGryoWriter.writeProperty(OutputStream, Property)or via anPropertypassed toGryoWriter.writeObject(OutputStream, Object).readVertex(InputStream inputStream, Function<Attachable<Vertex>, Vertex> vertexAttachMethod) Read aVertexfrom output generated by any of theGryoWriterwriteVertexorwriteVerticesmethods or byGryoWriter.writeGraph(OutputStream, Graph).readVertex(InputStream inputStream, Function<Attachable<Vertex>, Vertex> vertexAttachMethod, Function<Attachable<Edge>, Edge> edgeAttachMethod, Direction attachEdgesOfThisDirection) Read aVertexfrom output generated by any of theGryoWriterwriteVertexorwriteVerticesmethods or byGryoWriter.writeGraph(OutputStream, Graph).readVertex(InputStream inputStream, GraphFilter graphFilter) Reads a single vertex from anInputStream.readVertexProperty(InputStream inputStream, Function<Attachable<VertexProperty>, VertexProperty> vertexPropertyAttachMethod) Read aVertexPropertyfrom output generated byGryoWriter.writeVertexProperty(OutputStream, VertexProperty)or via anVertexPropertypassed toGryoWriter.writeObject(OutputStream, Object).readVertices(InputStream inputStream, Function<Attachable<Vertex>, Vertex> vertexAttachMethod, Function<Attachable<Edge>, Edge> edgeAttachMethod, Direction attachEdgesOfThisDirection) ReadVertexobjects from output generated by any of theGryoWriterwriteVertexorwriteVerticesmethods or byGryoWriter.writeGraph(OutputStream, Graph).
-
Method Details
-
readGraph
Read data into aGraphfrom output generated by any of theGryoWriterwriteVertexorwriteVerticesmethods or byGryoWriter.writeGraph(OutputStream, Graph).- Specified by:
readGraphin 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:GraphReaderReads 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 returnedOptionalis empty.- Specified by:
readVertexin interfaceGraphReader- Parameters:
inputStream- a stream containing at least a single vertex as defined by the accompanyingGraphWriter.writeVertex(OutputStream, Vertex).graphFilter- TheGraphFilterto 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<Attachable<Vertex>, Vertex> vertexAttachMethod, Function<Attachable<Edge>, throws IOExceptionEdge> edgeAttachMethod, Direction attachEdgesOfThisDirection) ReadVertexobjects from output generated by any of theGryoWriterwriteVertexorwriteVerticesmethods or byGryoWriter.writeGraph(OutputStream, Graph).- Specified by:
readVerticesin interfaceGraphReader- Parameters:
inputStream- a stream containing at least oneVertexas defined by the accompanyingGraphWriter.writeVertices(OutputStream, Iterator, Direction)orGraphWriter.writeVertices(OutputStream, Iterator)methods.vertexAttachMethod- a function that creates re-attaches aVertexto aHostobject.edgeAttachMethod- a function that creates re-attaches aEdgeto aHostobject.attachEdgesOfThisDirection- only edges of this direction are passed to theedgeMaker.- Throws:
IOException
-
readVertex
public Vertex readVertex(InputStream inputStream, Function<Attachable<Vertex>, Vertex> vertexAttachMethod) throws IOExceptionRead aVertexfrom output generated by any of theGryoWriterwriteVertexorwriteVerticesmethods or byGryoWriter.writeGraph(OutputStream, Graph).- Specified by:
readVertexin 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 aVertexto aHostobject.- Throws:
IOException
-
readVertex
public Vertex readVertex(InputStream inputStream, Function<Attachable<Vertex>, Vertex> vertexAttachMethod, Function<Attachable<Edge>, throws IOExceptionEdge> edgeAttachMethod, Direction attachEdgesOfThisDirection) Read aVertexfrom output generated by any of theGryoWriterwriteVertexorwriteVerticesmethods or byGryoWriter.writeGraph(OutputStream, Graph).- Specified by:
readVertexin interfaceGraphReader- Parameters:
inputStream- a stream containing at least oneVertexas defined by the accompanyingGraphWriter.writeVertices(OutputStream, Iterator, Direction)method.vertexAttachMethod- a function that creates re-attaches aVertexto aHostobject.edgeAttachMethod- a function that creates re-attaches aEdgeto aHostobject.attachEdgesOfThisDirection- only edges of this direction are passed to theedgeMaker.- Throws:
IOException
-
readEdge
public Edge readEdge(InputStream inputStream, Function<Attachable<Edge>, Edge> edgeAttachMethod) throws IOExceptionRead anEdgefrom output generated byGryoWriter.writeEdge(OutputStream, Edge)or via anEdgepassed toGryoWriter.writeObject(OutputStream, Object).- Specified by:
readEdgein interfaceGraphReader- Parameters:
inputStream- a stream containing at least oneEdgeas defined by the accompanyingGraphWriter.writeEdge(OutputStream, Edge)method.edgeAttachMethod- a function that creates re-attaches aEdgeto aHostobject.- Throws:
IOException
-
readVertexProperty
public VertexProperty readVertexProperty(InputStream inputStream, Function<Attachable<VertexProperty>, VertexProperty> vertexPropertyAttachMethod) throws IOExceptionRead aVertexPropertyfrom output generated byGryoWriter.writeVertexProperty(OutputStream, VertexProperty)or via anVertexPropertypassed toGryoWriter.writeObject(OutputStream, Object).- Specified by:
readVertexPropertyin interfaceGraphReader- Parameters:
inputStream- a stream containing at least oneVertexPropertyas written by the accompanyingGraphWriter.writeVertexProperty(OutputStream, VertexProperty)method.vertexPropertyAttachMethod- a function that creates re-attaches aVertexPropertyto aHostobject.- Returns:
- the value returned by the attach method.
- Throws:
IOException
-
readProperty
public Property readProperty(InputStream inputStream, Function<Attachable<Property>, Property> propertyAttachMethod) throws IOExceptionRead aPropertyfrom output generated byGryoWriter.writeProperty(OutputStream, Property)or via anPropertypassed toGryoWriter.writeObject(OutputStream, Object).- Specified by:
readPropertyin interfaceGraphReader- Parameters:
inputStream- a stream containing at least onePropertyas written by the accompanyingGraphWriter.writeProperty(OutputStream, Property)method.propertyAttachMethod- a function that creates re-attaches aPropertyto aHostobject.- Returns:
- the value returned by the attach method.
- Throws:
IOException
-
readObject
Reads an arbitrary object using the registered serializers.- Specified by:
readObjectin 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
-