Interface GraphReader
- 
- All Known Implementing Classes:
- GraphMLReader,- GraphSONReader,- GryoReader
 
 public interface GraphReaderFunctions for reading a graph and its graph elements from a different serialization format. Implementations of this class do not need to explicitly guarantee that an object read with one method must have its format equivalent to another. In other words the input toreadVertex(InputStream, Function)} need not also be readable byreadObject(InputStream, Class). In other words, implementations are free to optimize as is possible for a specific serialization method. That said, it is however important that the complementary "write" operation inGraphWriterbe capable of writing output compatible to its reader. In other words, the output ofGraphWriter.writeObject(OutputStream, Object)should always be readable byreadObject(InputStream, Class)and the output ofGraphWriter.writeGraph(OutputStream, Graph)should always be readable byreadGraph(InputStream, Graph).- Author:
- Stephen Mallette (http://stephen.genoprime.com)
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Interface Description static interfaceGraphReader.ReaderBuilder<T extends GraphReader>Largely a marker interface for builder classes that construct aGraphReader.
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description EdgereadEdge(InputStream inputStream, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Edge>,Edge> edgeAttachMethod)Reads a single edge from anInputStream.voidreadGraph(InputStream inputStream, Graph graphToWriteTo)Reads an entire graph from anInputStream.<C> CreadObject(InputStream inputStream, Class<? extends C> clazz)Reads an arbitrary object using the registered serializers.PropertyreadProperty(InputStream inputStream, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Property>,Property> propertyAttachMethod)Reads a single property from anInputStream.VertexreadVertex(InputStream inputStream, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Vertex>,Vertex> vertexAttachMethod)Reads a single vertex from anInputStream.VertexreadVertex(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)Reads a single vertex from anInputStream.default Optional<Vertex>readVertex(InputStream inputStream, GraphFilter graphFilter)Reads a single vertex from anInputStream.VertexPropertyreadVertexProperty(InputStream inputStream, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<VertexProperty>,VertexProperty> vertexPropertyAttachMethod)Reads a single vertex property from anInputStream.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)Reads a set of one or more vertices from anInputStreamwhich were written byGraphWriter.writeVertices(OutputStream, Iterator).
 
- 
- 
- 
Method Detail- 
readGraphvoid readGraph(InputStream inputStream, Graph graphToWriteTo) throws IOException Reads an entire graph from anInputStream. This method is mean to load an emptyGraph. It is up to individual implementations to manage transactions, but it is not required or enforced. Consult the documentation of an implementation to understand the approach it takes.- 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
 
 - 
readVertexdefault Optional<Vertex> readVertex(InputStream inputStream, GraphFilter graphFilter) throws IOException 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 returnedOptionalis empty.- Parameters:
- inputStream- a stream containing at least a single vertex as defined by the accompanying- GraphWriter.writeVertex(OutputStream, Vertex).
- graphFilter- The- GraphFilterto 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
 
 - 
readVertexVertex readVertex(InputStream inputStream, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Vertex>,Vertex> vertexAttachMethod) throws IOException Reads a single vertex from anInputStream. This method will read vertex properties but not edges. It is expected that the user will manager their own transaction context with respect to this method (i.e. implementations should not commit the transaction for the user).- 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- Vertexto a- Hostobject.
- Throws:
- IOException
 
 - 
readVertexVertex 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 Reads a single vertex from anInputStream. This method will read vertex properties as well as edges given the direction supplied as an argument. It is expected that the user will manager their own transaction context with respect to this method (i.e. implementations should not commit the transaction for the user).- Parameters:
- inputStream- a stream containing at least one- Vertexas defined by the accompanying- GraphWriter.writeVertices(OutputStream, Iterator, Direction)method.
- vertexAttachMethod- a function that creates re-attaches a- Vertexto a- Hostobject.
- edgeAttachMethod- a function that creates re-attaches a- Edgeto a- Hostobject.
- attachEdgesOfThisDirection- only edges of this direction are passed to the- edgeMaker.
- Throws:
- IOException
 
 - 
readVerticesIterator<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 Reads a set of one or more vertices from anInputStreamwhich were written byGraphWriter.writeVertices(OutputStream, Iterator). This method will read vertex properties as well as edges given the direction supplied as an argument. It is expected that the user will manager their own transaction context with respect to this method (i.e. implementations should not commit the transaction for the user).- Parameters:
- inputStream- a stream containing at least one- Vertexas defined by the accompanying- GraphWriter.writeVertices(OutputStream, Iterator, Direction)or- GraphWriter.writeVertices(OutputStream, Iterator)methods.
- vertexAttachMethod- a function that creates re-attaches a- Vertexto a- Hostobject.
- edgeAttachMethod- a function that creates re-attaches a- Edgeto a- Hostobject.
- attachEdgesOfThisDirection- only edges of this direction are passed to the- edgeMaker.
- Throws:
- IOException
 
 - 
readEdgeEdge readEdge(InputStream inputStream, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Edge>,Edge> edgeAttachMethod) throws IOException Reads a single edge from anInputStream. It is expected that the user will manager their own transaction context with respect to this method (i.e. implementations should not commit the transaction for the user).- Parameters:
- inputStream- a stream containing at least one- Edgeas defined by the accompanying- GraphWriter.writeEdge(OutputStream, Edge)method.
- edgeAttachMethod- a function that creates re-attaches a- Edgeto a- Hostobject.
- Throws:
- IOException
 
 - 
readVertexPropertyVertexProperty readVertexProperty(InputStream inputStream, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<VertexProperty>,VertexProperty> vertexPropertyAttachMethod) throws IOException Reads a single vertex property from anInputStream. It is expected that the user will manager their own transaction context with respect to this method (i.e. implementations should not commit the transaction for the user).- Parameters:
- inputStream- a stream containing at least one- VertexPropertyas written by the accompanying- GraphWriter.writeVertexProperty(OutputStream, VertexProperty)method.
- vertexPropertyAttachMethod- a function that creates re-attaches a- VertexPropertyto a- Hostobject.
- Returns:
- the value returned by the attach method.
- Throws:
- IOException
 
 - 
readPropertyProperty readProperty(InputStream inputStream, Function<org.apache.tinkerpop.gremlin.structure.util.Attachable<Property>,Property> propertyAttachMethod) throws IOException Reads a single property from anInputStream. It is expected that the user will manager their own transaction context with respect to this method (i.e. implementations should not commit the transaction for the user).- Parameters:
- inputStream- a stream containing at least one- Propertyas written by the accompanying- GraphWriter.writeProperty(OutputStream, Property)method.
- propertyAttachMethod- a function that creates re-attaches a- Propertyto a- Hostobject.
- Returns:
- the value returned by the attach method.
- Throws:
- IOException
 
 - 
readObject<C> C readObject(InputStream inputStream, Class<? extends C> clazz) throws IOException Reads an arbitrary object using the registered serializers.- 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
 
 
- 
 
-