Class GryoWriter

  • All Implemented Interfaces:
    GraphWriter

    public final class GryoWriter
    extends Object
    implements GraphWriter
    The GraphWriter 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 GraphWriter instance per thread.

    Author:
    Stephen Mallette (http://stephen.genoprime.com)
    • Method Detail

      • writeVertices

        public void writeVertices​(OutputStream outputStream,
                                  Iterator<Vertex> vertexIterator,
                                  Direction direction)
                           throws IOException
        Write a list of vertices from a Traversal to a stream with its associated edges. Only write edges as defined by the requested direction.
        Specified by:
        writeVertices in interface GraphWriter
        Parameters:
        outputStream - the stream to write to.
        vertexIterator - a traversal that returns a list of vertices.
        direction - the direction of edges to write or null if no edges are to be written.
        Throws:
        IOException
      • writeVertices

        public void writeVertices​(OutputStream outputStream,
                                  Iterator<Vertex> vertexIterator)
                           throws IOException
        Write a vertex to a stream without writing its edges.
        Specified by:
        writeVertices in interface GraphWriter
        Parameters:
        outputStream - the stream to write to.
        vertexIterator - a iterator that returns a list of vertices.
        Throws:
        IOException
      • writeVertex

        public void writeVertex​(OutputStream outputStream,
                                Vertex v,
                                Direction direction)
                         throws IOException
        Write a vertex to a stream with its associated edges. Only write edges as defined by the requested direction.
        Specified by:
        writeVertex in interface GraphWriter
        Parameters:
        outputStream - the stream to write to.
        v - the vertex to write.
        direction - the direction of edges to write or null if no edges are to be written.
        Throws:
        IOException
      • writeObject

        public void writeObject​(OutputStream outputStream,
                                Object object)
        Writes an arbitrary object to the stream.
        Specified by:
        writeObject in interface GraphWriter
        Parameters:
        outputStream - the stream to write to.
        object - the object to write which will use the standard serializer set.