org.apache.tinkerpop.gremlin.structure.io.gryo

## 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

  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 Classes
    Modifier and Type | Class and 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 and Description
    --- | ---
    `static GryoReader.Builder` | `build()`
    `Edge` | `readEdge(InputStream inputStream, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Edge>,Edge> edgeAttachMethod)` Read an `Edge` from output generated by `GryoWriter.writeEdge(OutputStream, Edge)` or via an `Edge` passed to `GryoWriter.writeObject(OutputStream, Object)`.
    `void` | `readGraph(InputStream inputStream, Graph graphToWriteTo)` Read data into a `Graph` from output generated by any of the `GryoWriter` `writeVertex` or `writeVertices` methods or by `GryoWriter.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 a `Property` from output generated by `GryoWriter.writeProperty(OutputStream, Property)` or via an `Property` passed to `GryoWriter.writeObject(OutputStream, Object)`.
    `Vertex` | `readVertex(InputStream inputStream, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Vertex>,Vertex> vertexAttachMethod)` Read a `Vertex` from output generated by any of the `GryoWriter` `writeVertex` or `writeVertices` methods or by `GryoWriter.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 a `Vertex` from output generated by any of the `GryoWriter` `writeVertex` or `writeVertices` methods or by `GryoWriter.writeGraph(OutputStream, Graph)`.
    `Optional<Vertex>` | `readVertex(InputStream inputStream, GraphFilter graphFilter)` Reads a single vertex from an `InputStream`.
    `VertexProperty` | `readVertexProperty(InputStream inputStream, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<VertexProperty>,VertexProperty> vertexPropertyAttachMethod)` Read a `VertexProperty` from output generated by `GryoWriter.writeVertexProperty(OutputStream, VertexProperty)` or via an `VertexProperty` passed to `GryoWriter.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)` Read `Vertex` objects from output generated by any of the `GryoWriter` `writeVertex` or `writeVertices` methods or by `GryoWriter.writeGraph(OutputStream, Graph)`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### readGraph

          public void readGraph(InputStream inputStream,
                                Graph graphToWriteTo)
                         throws IOException

      Read data into a `Graph` from output generated by any of the `GryoWriter` `writeVertex` or `writeVertices` methods or by `GryoWriter.writeGraph(OutputStream, Graph)`.
      Specified by:
        `readGraph` in interface `GraphReader`
      Parameters:
        `inputStream` - a stream containing an entire graph of vertices and edges as defined by the accompanying `GraphWriter.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 an `InputStream`. This method will filter the read the read vertex by the provided `GraphFilter`. If the graph filter will filter the vertex itself, then the returned `Optional` is empty.
      Specified by:
        `readVertex` in interface `GraphReader`
      Parameters:
        `inputStream` - a stream containing at least a single vertex as defined by the accompanying `GraphWriter.writeVertex(OutputStream, Vertex)`.
        `graphFilter` - The `GraphFilter` 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

      Read `Vertex` objects from output generated by any of the `GryoWriter` `writeVertex` or `writeVertices` methods or by `GryoWriter.writeGraph(OutputStream, Graph)`.
      Specified by:
        `readVertices` in interface `GraphReader`
      Parameters:
        `inputStream` - a stream containing at least one `Vertex` as defined by the accompanying `GraphWriter.writeVertices(OutputStream, Iterator, Direction)` or `GraphWriter.writeVertices(OutputStream, Iterator)` methods.
        `vertexAttachMethod` - a function that creates re-attaches a `Vertex` to a `Host` object.
        `edgeAttachMethod` - a function that creates re-attaches a `Edge` to a `Host` object.
        `attachEdgesOfThisDirection` - only edges of this direction are passed to the `edgeMaker`.
      Throws:
        `IOException`

    - #### readVertex

          public Vertex readVertex(InputStream inputStream,
                                   Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Vertex>,Vertex> vertexAttachMethod)
                            throws IOException

      Read a `Vertex` from output generated by any of the `GryoWriter` `writeVertex` or `writeVertices` methods or by `GryoWriter.writeGraph(OutputStream, Graph)`.
      Specified by:
        `readVertex` in interface `GraphReader`
      Parameters:
        `inputStream` - a stream containing at least a single vertex as defined by the accompanying `GraphWriter.writeVertex(OutputStream, Vertex)`.
        `vertexAttachMethod` - a function that creates re-attaches a `Vertex` to a `Host` 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 a `Vertex` from output generated by any of the `GryoWriter` `writeVertex` or `writeVertices` methods or by `GryoWriter.writeGraph(OutputStream, Graph)`.
      Specified by:
        `readVertex` in interface `GraphReader`
      Parameters:
        `inputStream` - a stream containing at least one `Vertex` as defined by the accompanying `GraphWriter.writeVertices(OutputStream, Iterator, Direction)` method.
        `vertexAttachMethod` - a function that creates re-attaches a `Vertex` to a `Host` object.
        `edgeAttachMethod` - a function that creates re-attaches a `Edge` to a `Host` object.
        `attachEdgesOfThisDirection` - only edges of this direction are passed to the `edgeMaker`.
      Throws:
        `IOException`

    - #### readEdge

          public Edge readEdge(InputStream inputStream,
                               Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Edge>,Edge> edgeAttachMethod)
                        throws IOException

      Read an `Edge` from output generated by `GryoWriter.writeEdge(OutputStream, Edge)` or via an `Edge` passed to `GryoWriter.writeObject(OutputStream, Object)`.
      Specified by:
        `readEdge` in interface `GraphReader`
      Parameters:
        `inputStream` - a stream containing at least one `Edge` as defined by the accompanying `GraphWriter.writeEdge(OutputStream, Edge)` method.
        `edgeAttachMethod` - a function that creates re-attaches a `Edge` to a `Host` object.
      Throws:
        `IOException`

    - #### readVertexProperty

          public VertexProperty readVertexProperty(InputStream inputStream,
                                                   Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<VertexProperty>,VertexProperty> vertexPropertyAttachMethod)
                                            throws IOException

      Read a `VertexProperty` from output generated by `GryoWriter.writeVertexProperty(OutputStream, VertexProperty)` or via an `VertexProperty` passed to `GryoWriter.writeObject(OutputStream, Object)`.
      Specified by:
        `readVertexProperty` in interface `GraphReader`
      Parameters:
        `inputStream` - a stream containing at least one `VertexProperty` as written by the accompanying `GraphWriter.writeVertexProperty(OutputStream, VertexProperty)` method.
        `vertexPropertyAttachMethod` - a function that creates re-attaches a `VertexProperty` to a `Host` 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 a `Property` from output generated by `GryoWriter.writeProperty(OutputStream, Property)` or via an `Property` passed to `GryoWriter.writeObject(OutputStream, Object)`.
      Specified by:
        `readProperty` in interface `GraphReader`
      Parameters:
        `inputStream` - a stream containing at least one `Property` as written by the accompanying `GraphWriter.writeProperty(OutputStream, Property)` method.
        `propertyAttachMethod` - a function that creates re-attaches a `Property` to a `Host` 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 interface `GraphReader`
      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()

Copyright © 2013–2021 Apache Software Foundation. All rights reserved.