/** * {@inheritDoc} */ @Override public void writeGraph(final String file) throws IOException { try (final OutputStream out = new FileOutputStream(file)) { writer().create().writeGraph(out, graph); } }
@Override public void write(final Kryo kryo, final Output output, final TinkerGraph graph) { try (final ByteArrayOutputStream stream = new ByteArrayOutputStream()) { GryoWriter.build().mapper(() -> kryo).create().writeGraph(stream, graph); final byte[] bytes = stream.toByteArray(); output.writeInt(bytes.length); output.write(bytes); } catch (Exception io) { throw new RuntimeException(io); } }
@Override public void write(final Kryo kryo, final Output output, final TinkerGraph graph) { try (final ByteArrayOutputStream stream = new ByteArrayOutputStream()) { GryoWriter.build().mapper(() -> kryo).create().writeGraph(stream, graph); final byte[] bytes = stream.toByteArray(); output.writeInt(bytes.length); output.write(bytes); } catch (Exception io) { throw new RuntimeException(io); } }
@Override public void write(final Kryo kryo, final Output output, final TinkerGraph graph) { try (final ByteArrayOutputStream stream = new ByteArrayOutputStream()) { GryoWriter.build().mapper(() -> kryo).create().writeGraph(stream, graph); final byte[] bytes = stream.toByteArray(); output.writeInt(bytes.length); output.write(bytes); } catch (Exception io) { throw new RuntimeException(io); } }
@Test @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES) @FeatureRequirement(featureClass = EdgePropertyFeatures.class, feature = FEATURE_STRING_VALUES) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES) public void shouldReadWriteSelfLoopingEdges() { final Graph source = graph; final Vertex v1 = source.addVertex(); final Vertex v2 = source.addVertex(); v1.addEdge("CONTROL", v2); v1.addEdge("SELFLOOP", v1); final Configuration targetConf = graphProvider.newGraphConfiguration("target", this.getClass(), name.getMethodName(), null); final Graph target = graphProvider.openTestGraph(targetConf); ; try (ByteArrayOutputStream os = new ByteArrayOutputStream()) { source.io(IoCore.gryo()).writer().create().writeGraph(os, source); try (ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray())) { target.io(IoCore.gryo()).reader().create().readGraph(is, target); } } catch (IOException ioe) { throw new RuntimeException(ioe); } assertEquals(IteratorUtils.count(source.vertices()), IteratorUtils.count(target.vertices())); assertEquals(IteratorUtils.count(source.edges()), IteratorUtils.count(target.edges())); } }
/** * {@inheritDoc} */ @Override public void writeGraph(final String file) throws IOException { try (final OutputStream out = new FileOutputStream(file)) { writer().create().writeGraph(out, graph); } }
@Override public void write(final Kryo kryo, final Output output, final TinkerGraph graph) { try (final ByteArrayOutputStream stream = new ByteArrayOutputStream()) { GryoWriter.build().mapper(() -> kryo).create().writeGraph(stream, graph); final byte[] bytes = stream.toByteArray(); output.writeInt(bytes.length); output.write(bytes); } catch (Exception io) { throw new RuntimeException(io); } }
@Override public void write(final Kryo kryo, final Output output, final TinkerGraph graph) { try (final ByteArrayOutputStream stream = new ByteArrayOutputStream()) { GryoWriter.build().mapper(() -> kryo).create().writeGraph(stream, graph); final byte[] bytes = stream.toByteArray(); output.writeInt(bytes.length); output.write(bytes); } catch (Exception io) { throw new RuntimeException(io); } }
@Override public void write(final Kryo kryo, final Output output, final TinkerGraph graph) { try (final ByteArrayOutputStream stream = new ByteArrayOutputStream()) { GryoWriter.build().mapper(() -> kryo).create().writeGraph(stream, graph); final byte[] bytes = stream.toByteArray(); output.writeInt(bytes.length); output.write(bytes); } catch (Exception io) { throw new RuntimeException(io); } }
@Override public void write(final Kryo kryo, final Output output, final TinkerGraph graph) { try (final ByteArrayOutputStream stream = new ByteArrayOutputStream()) { GryoWriter.build().mapper(() -> kryo).create().writeGraph(stream, graph); final byte[] bytes = stream.toByteArray(); output.writeInt(bytes.length); output.write(bytes); } catch (Exception io) { throw new RuntimeException(io); } }
@Override public void write(final Kryo kryo, final Output output, final TinkerGraph graph) { try (final ByteArrayOutputStream stream = new ByteArrayOutputStream()) { GryoWriter.build().mapper(() -> kryo).create().writeGraph(stream, graph); final byte[] bytes = stream.toByteArray(); output.writeInt(bytes.length); output.write(bytes); } catch (Exception io) { throw new RuntimeException(io); } }
@Override public void write(final Kryo kryo, final Output output, final TinkerGraph graph) { try (final ByteArrayOutputStream stream = new ByteArrayOutputStream()) { GryoWriter.build().mapper(() -> kryo).create().writeGraph(stream, graph); final byte[] bytes = stream.toByteArray(); output.writeInt(bytes.length); output.write(bytes); } catch (Exception io) { throw new RuntimeException(io); } }
@Test @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES) @FeatureRequirement(featureClass = EdgePropertyFeatures.class, feature = FEATURE_STRING_VALUES) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES) public void shouldReadWriteSelfLoopingEdges() { final Graph source = graph; final Vertex v1 = source.addVertex(); final Vertex v2 = source.addVertex(); v1.addEdge("CONTROL", v2); v1.addEdge("SELFLOOP", v1); final Configuration targetConf = graphProvider.newGraphConfiguration("target", this.getClass(), name.getMethodName(), null); final Graph target = graphProvider.openTestGraph(targetConf); ; try (ByteArrayOutputStream os = new ByteArrayOutputStream()) { source.io(IoCore.gryo()).writer().create().writeGraph(os, source); try (ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray())) { target.io(IoCore.gryo()).reader().create().readGraph(is, target); } } catch (IOException ioe) { throw new RuntimeException(ioe); } assertEquals(IteratorUtils.count(source.vertices()), IteratorUtils.count(target.vertices())); assertEquals(IteratorUtils.count(source.edges()), IteratorUtils.count(target.edges())); } }