Java Code Examples for org.apache.tinkerpop.shaded.kryo.io.Output#writeInt()

The following examples show how to use org.apache.tinkerpop.shaded.kryo.io.Output#writeInt() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TinkerGraphTest.java    From tinkergraph-gremlin with Apache License 2.0 6 votes vote down vote up
@Override
public void write(final Kryo kryo, final Output output, final Color color) {
    final TinkerGraph graph = TinkerGraph.open();
    final Vertex v = graph.addVertex(T.id, 1, T.label, "color", "name", color.toString());
    final Vertex vRed = graph.addVertex(T.id, 2, T.label, "primary", "name", "red");
    final Vertex vGreen = graph.addVertex(T.id, 3, T.label, "primary", "name", "green");
    final Vertex vBlue = graph.addVertex(T.id, 4, T.label, "primary", "name", "blue");

    v.addEdge("hasComponent", vRed, "amount", color.getRed());
    v.addEdge("hasComponent", vGreen, "amount", color.getGreen());
    v.addEdge("hasComponent", vBlue, "amount", color.getBlue());

    // make some junk so the graph is kinda big
    generate(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 ex) {
        ex.printStackTrace();
    }
}
 
Example 2
Source File: TinkerGraphTest.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Override
public void write(final Kryo kryo, final Output output, final Color color) {
    final TinkerGraph graph = TinkerGraph.open();
    final Vertex v = graph.addVertex(T.id, 1, T.label, "color", "name", color.toString());
    final Vertex vRed = graph.addVertex(T.id, 2, T.label, "primary", "name", "red");
    final Vertex vGreen = graph.addVertex(T.id, 3, T.label, "primary", "name", "green");
    final Vertex vBlue = graph.addVertex(T.id, 4, T.label, "primary", "name", "blue");

    v.addEdge("hasComponent", vRed, "amount", color.getRed());
    v.addEdge("hasComponent", vGreen, "amount", color.getGreen());
    v.addEdge("hasComponent", vBlue, "amount", color.getBlue());

    // make some junk so the graph is kinda big
    generate(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 ex) {
        ex.printStackTrace();
    }
}
 
Example 3
Source File: HugeGryoModule.java    From hugegraph with Apache License 2.0 5 votes vote down vote up
private static void writeEntry(Kryo kryo,
                               Output output,
                               Map<HugeKeys, Object> schema) {
    /* Write columns size and data */
    output.writeInt(schema.keySet().size());
    for (Map.Entry<HugeKeys, Object> entry : schema.entrySet()) {
        kryo.writeObject(output, entry.getKey());
        kryo.writeClassAndObject(output, entry.getValue());
    }
}
 
Example 4
Source File: TinkerIoRegistryV1d0.java    From tinkergraph-gremlin with Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example 5
Source File: TinkerIoRegistryV3d0.java    From tinkergraph-gremlin with Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example 6
Source File: TinkerIoRegistryV2d0.java    From tinkergraph-gremlin with Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example 7
Source File: TinkerIoRegistryV1d0.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example 8
Source File: TinkerIoRegistryV3d0.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example 9
Source File: TinkerIoRegistryV2d0.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example 10
Source File: RecordId.java    From sqlg with MIT License 5 votes vote down vote up
@Override
public void write(Kryo kryo, Output output) {
    output.writeString(this.getSchemaTable().getSchema());
    output.writeString(this.getSchemaTable().getTable());
    if (hasSequenceId()) {
        output.writeString("s");
        output.writeLong(this.getID().sequenceId);
    } else {
        output.writeString("i");
        output.writeInt(getIdentifiers().size());
        for (Comparable identifier : getIdentifiers()) {
            output.writeString((CharSequence) identifier);
        }
    }
}