/** * Read a {@link Property} from output generated by {@link GryoWriter#writeProperty(OutputStream, Property)} or * via an {@link Property} passed to {@link GryoWriter#writeObject(OutputStream, Object)}. * * @param inputStream a stream containing at least one {@link Property} as written by the accompanying * {@link GraphWriter#writeProperty(OutputStream, Property)} method. * @param propertyAttachMethod a function that creates re-attaches a {@link Property} to a {@link Host} object. */ @Override public Property readProperty(final InputStream inputStream, final Function<Attachable<Property>, Property> propertyAttachMethod) throws IOException { final Input input = new Input(inputStream); readHeader(input); final Attachable<Property> attachable = kryo.readObject(input, DetachedProperty.class); return propertyAttachMethod.apply(attachable); }
/** * Read an {@link Edge} from output generated by {@link GryoWriter#writeEdge(OutputStream, Edge)} or via * an {@link Edge} passed to {@link GryoWriter#writeObject(OutputStream, Object)}. * * @param inputStream a stream containing at least one {@link Edge} as defined by the accompanying * {@link GraphWriter#writeEdge(OutputStream, Edge)} method. * @param edgeAttachMethod a function that creates re-attaches a {@link Edge} to a {@link Host} object. */ @Override public Edge readEdge(final InputStream inputStream, final Function<Attachable<Edge>, Edge> edgeAttachMethod) throws IOException { final Input input = new Input(inputStream); readHeader(input); final Attachable<Edge> attachable = kryo.readObject(input, DetachedEdge.class); return edgeAttachMethod.apply(attachable); }
/** * Read a {@link VertexProperty} from output generated by * {@link GryoWriter#writeVertexProperty(OutputStream, VertexProperty)} or via an {@link VertexProperty} passed * to {@link GryoWriter#writeObject(OutputStream, Object)}. * * @param inputStream a stream containing at least one {@link VertexProperty} as written by the accompanying * {@link GraphWriter#writeVertexProperty(OutputStream, VertexProperty)} method. * @param vertexPropertyAttachMethod a function that creates re-attaches a {@link VertexProperty} to a * {@link Host} object. */ @Override public VertexProperty readVertexProperty(final InputStream inputStream, final Function<Attachable<VertexProperty>, VertexProperty> vertexPropertyAttachMethod) throws IOException { final Input input = new Input(inputStream); readHeader(input); final Attachable<VertexProperty> attachable = kryo.readObject(input, DetachedVertexProperty.class); return vertexPropertyAttachMethod.apply(attachable); }
@Override public Optional<Vertex> readVertex(final InputStream inputStream, final GraphFilter graphFilter) throws IOException { StarGraphGryoSerializer serializer = this.graphFilterCache.get(graphFilter); if (null == serializer) { serializer = StarGraphGryoSerializer.withGraphFilter(graphFilter); this.graphFilterCache.put(graphFilter, serializer); } final Input input = new Input(inputStream); this.readHeader(input); final StarGraph starGraph = this.kryo.readObject(input, StarGraph.class, serializer); // read the terminator this.kryo.readClassAndObject(input); return Optional.ofNullable(starGraph == null ? null : starGraph.getStarVertex()); }
private Vertex readVertexInternal(final Function<Attachable<Vertex>, Vertex> vertexMaker, final Function<Attachable<Edge>, Edge> edgeMaker, final Direction d, final Input input) throws IOException { readHeader(input); final StarGraph starGraph = kryo.readObject(input, StarGraph.class); // read the terminator kryo.readClassAndObject(input); final Vertex v = vertexMaker.apply(starGraph.getStarVertex()); if (edgeMaker != null) starGraph.getStarVertex().edges(d).forEachRemaining(e -> edgeMaker.apply((Attachable<Edge>) e)); return v; }
/** * Read an {@link Edge} from output generated by {@link GryoWriter#writeEdge(OutputStream, Edge)} or via * an {@link Edge} passed to {@link GryoWriter#writeObject(OutputStream, Object)}. * * @param inputStream a stream containing at least one {@link Edge} as defined by the accompanying * {@link GraphWriter#writeEdge(OutputStream, Edge)} method. * @param edgeAttachMethod a function that creates re-attaches a {@link Edge} to a {@link Host} object. */ @Override public Edge readEdge(final InputStream inputStream, final Function<Attachable<Edge>, Edge> edgeAttachMethod) throws IOException { final Input input = new Input(inputStream); readHeader(input); final Attachable<Edge> attachable = kryo.readObject(input, DetachedEdge.class); return edgeAttachMethod.apply(attachable); }
/** * Read a {@link Property} from output generated by {@link GryoWriter#writeProperty(OutputStream, Property)} or * via an {@link Property} passed to {@link GryoWriter#writeObject(OutputStream, Object)}. * * @param inputStream a stream containing at least one {@link Property} as written by the accompanying * {@link GraphWriter#writeProperty(OutputStream, Property)} method. * @param propertyAttachMethod a function that creates re-attaches a {@link Property} to a {@link Host} object. */ @Override public Property readProperty(final InputStream inputStream, final Function<Attachable<Property>, Property> propertyAttachMethod) throws IOException { final Input input = new Input(inputStream); readHeader(input); final Attachable<Property> attachable = kryo.readObject(input, DetachedProperty.class); return propertyAttachMethod.apply(attachable); }
/** * Read a {@link VertexProperty} from output generated by * {@link GryoWriter#writeVertexProperty(OutputStream, VertexProperty)} or via an {@link VertexProperty} passed * to {@link GryoWriter#writeObject(OutputStream, Object)}. * * @param inputStream a stream containing at least one {@link VertexProperty} as written by the accompanying * {@link GraphWriter#writeVertexProperty(OutputStream, VertexProperty)} method. * @param vertexPropertyAttachMethod a function that creates re-attaches a {@link VertexProperty} to a * {@link Host} object. */ @Override public VertexProperty readVertexProperty(final InputStream inputStream, final Function<Attachable<VertexProperty>, VertexProperty> vertexPropertyAttachMethod) throws IOException { final Input input = new Input(inputStream); readHeader(input); final Attachable<VertexProperty> attachable = kryo.readObject(input, DetachedVertexProperty.class); return vertexPropertyAttachMethod.apply(attachable); }
private Vertex readVertexInternal(final Function<Attachable<Vertex>, Vertex> vertexMaker, final Function<Attachable<Edge>, Edge> edgeMaker, final Direction d, final Input input) throws IOException { readHeader(input); final StarGraph starGraph = kryo.readObject(input, StarGraph.class); // read the terminator kryo.readClassAndObject(input); final Vertex v = vertexMaker.apply(starGraph.getStarVertex()); if (edgeMaker != null) starGraph.getStarVertex().edges(d).forEachRemaining(e -> edgeMaker.apply((Attachable<Edge>) e)); return v; }
@Override public Optional<Vertex> readVertex(final InputStream inputStream, final GraphFilter graphFilter) throws IOException { StarGraphGryoSerializer serializer = this.graphFilterCache.get(graphFilter); if (null == serializer) { serializer = StarGraphGryoSerializer.withGraphFilter(graphFilter); this.graphFilterCache.put(graphFilter, serializer); } final Input input = new Input(inputStream); this.readHeader(input); final StarGraph starGraph = this.kryo.readObject(input, StarGraph.class, serializer); // read the terminator this.kryo.readClassAndObject(input); return Optional.ofNullable(starGraph == null ? null : starGraph.getStarVertex()); }