当前位置: 首页>>代码示例>>Java>>正文


Java GryoWriter类代码示例

本文整理汇总了Java中org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter的典型用法代码示例。如果您正苦于以下问题:Java GryoWriter类的具体用法?Java GryoWriter怎么用?Java GryoWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GryoWriter类属于org.apache.tinkerpop.gremlin.structure.io.gryo包,在下文中一共展示了GryoWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: write

import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter; //导入依赖的package包/类
@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();
    }
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:25,代码来源:TinkerGraphTest.java

示例2: shouldSerializeVertexAsDetached

import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter; //导入依赖的package包/类
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeVertexAsDetached() throws Exception {
    final GryoIo gryoIo = graph.io(GryoIo.build());
    final GryoWriter gryoWriter = gryoIo.writer().create();
    final GryoReader gryoReader = gryoIo.reader().create();

    final Vertex v = graph.vertices(convertToVertexId("marko")).next();
    final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    gryoWriter.writeObject(outputStream, v);

    final ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
    final Vertex detached = gryoReader.readObject(inputStream, DetachedVertex.class);
    assertNotNull(detached);
    assertEquals(v.label(), detached.label());
    assertEquals(v.id(), detached.id());
    assertEquals(v.value("name").toString(), detached.value("name"));
    assertEquals((Integer) v.value("age"), detached.value("age"));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:20,代码来源:SerializationTest.java

示例3: shouldSerializeEdgeAsDetached

import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter; //导入依赖的package包/类
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeEdgeAsDetached() throws Exception {
    final GryoIo gryoIo = graph.io(GryoIo.build());
    final GryoWriter gryoWriter = gryoIo.writer().create();
    final GryoReader gryoReader = gryoIo.reader().create();

    final Edge e = g.E(convertToEdgeId("marko", "knows", "vadas")).next();
    final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    gryoWriter.writeObject(outputStream, e);

    final ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
    final Edge detached = gryoReader.readObject(inputStream, DetachedEdge.class);
    assertNotNull(detached);
    assertEquals(e.label(), detached.label());
    assertEquals(e.id(), detached.id());
    assertEquals((Double) e.value("weight"), detached.value("weight"));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:19,代码来源:SerializationTest.java

示例4: shouldSerializePropertyAsDetached

import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter; //导入依赖的package包/类
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializePropertyAsDetached() throws Exception {
    final GryoIo gryoIo = graph.io(GryoIo.build());
    final GryoWriter gryoWriter = gryoIo.writer().create();
    final GryoReader gryoReader = gryoIo.reader().create();

    final Property property = g.E(convertToEdgeId("marko", "knows", "vadas")).next().property("weight");
    final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    gryoWriter.writeObject(outputStream, property);

    final ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
    final Property detached = gryoReader.readObject(inputStream, DetachedProperty.class);
    assertNotNull(detached);
    assertEquals(property.key(), detached.key());
    assertEquals(property.value(), detached.value());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:18,代码来源:SerializationTest.java

示例5: shouldSerializeVertexPropertyAsDetached

import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter; //导入依赖的package包/类
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeVertexPropertyAsDetached() throws Exception {
    final GryoIo gryoIo = graph.io(GryoIo.build());
    final GryoWriter gryoWriter = gryoIo.writer().create();
    final GryoReader gryoReader = gryoIo.reader().create();

    final VertexProperty vertexProperty = graph.vertices(convertToVertexId("marko")).next().property("name");
    final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    gryoWriter.writeObject(outputStream, vertexProperty);

    final ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
    final VertexProperty detached = gryoReader.readObject(inputStream, DetachedVertexProperty.class);
    assertNotNull(detached);
    assertEquals(vertexProperty.label(), detached.label());
    assertEquals(vertexProperty.id(), detached.id());
    assertEquals(vertexProperty.value(), detached.value());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:19,代码来源:SerializationTest.java

示例6: shouldSerializeVertexPropertyWithPropertiesAsDetached

import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter; //导入依赖的package包/类
@Test
@LoadGraphWith(LoadGraphWith.GraphData.CREW)
public void shouldSerializeVertexPropertyWithPropertiesAsDetached() throws Exception {
    final GryoIo gryoIo = graph.io(GryoIo.build());
    final GryoWriter gryoWriter = gryoIo.writer().create();
    final GryoReader gryoReader = gryoIo.reader().create();

    final VertexProperty<?> vertexProperty = IteratorUtils.filter(graph.vertices(convertToVertexId("marko")).next().properties("location"), p -> p.value().equals("brussels")).next();
    final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    gryoWriter.writeObject(outputStream, vertexProperty);

    final ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
    final VertexProperty<?> detached = gryoReader.readObject(inputStream, DetachedVertexProperty.class);

    assertNotNull(detached);
    assertEquals(vertexProperty.label(), detached.label());
    assertEquals(vertexProperty.id(), detached.id());
    assertEquals(vertexProperty.value(), detached.value());
    assertEquals(vertexProperty.values("startTime").next(), detached.values("startTime").next());
    assertEquals(vertexProperty.properties("startTime").next().key(), detached.properties("startTime").next().key());
    assertEquals(vertexProperty.values("endTime").next(), detached.values("endTime").next());
    assertEquals(vertexProperty.properties("endTime").next().key(), detached.properties("endTime").next().key());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:24,代码来源:SerializationTest.java

示例7: shouldSerializeTraversalMetrics

import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter; //导入依赖的package包/类
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeTraversalMetrics() throws Exception {
    final GryoIo gryoIo = graph.io(GryoIo.build());
    final GryoWriter gryoWriter = gryoIo.writer().create();
    final GryoReader gryoReader = gryoIo.reader().create();

    final TraversalMetrics before = (TraversalMetrics) g.V().both().profile().next();
    final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    gryoWriter.writeObject(outputStream, before);

    final ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
    final TraversalMetrics after = gryoReader.readObject(inputStream, TraversalMetrics.class);
    assertNotNull(after);
    assertEquals(before.getMetrics().size(), after.getMetrics().size());
    assertEquals(before.getDuration(TimeUnit.MILLISECONDS), after.getDuration(TimeUnit.MILLISECONDS));
    assertEquals(before.getMetrics(0).getCounts(), after.getMetrics(0).getCounts());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:19,代码来源:SerializationTest.java

示例8: shouldSerializeTree

import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter; //导入依赖的package包/类
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeTree() throws Exception {
    final GryoIo gryoIo = graph.io(GryoIo.build());
    final GryoWriter gryoWriter = gryoIo.writer().create();
    final GryoReader gryoReader = gryoIo.reader().create();

    final Tree before = g.V(convertToVertexId("marko")).out().properties("name").tree().next();
    
    final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    gryoWriter.writeObject(outputStream, before);

    final ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
    final Tree after = gryoReader.readObject(inputStream, Tree.class);
    assertNotNull(after);
    //The following assertions should be sufficent.
    assertThat("Type does not match", after, instanceOf(Tree.class));
    assertEquals("The objects differ", after, before);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:20,代码来源:SerializationTest.java

示例9: shouldSerializeVertexAsDetached

import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter; //导入依赖的package包/类
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeVertexAsDetached() throws Exception {
    final GryoIo gryoIo = graph.io(GryoIo.build(GryoVersion.V1_0));
    final GryoWriter gryoWriter = gryoIo.writer().create();
    final GryoReader gryoReader = gryoIo.reader().create();

    final Vertex v = graph.vertices(convertToVertexId("marko")).next();
    final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    gryoWriter.writeObject(outputStream, v);

    final ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
    final Vertex detached = gryoReader.readObject(inputStream, DetachedVertex.class);
    assertNotNull(detached);
    assertEquals(v.label(), detached.label());
    assertEquals(v.id(), detached.id());
    assertEquals(v.value("name").toString(), detached.value("name"));
    assertEquals((Integer) v.value("age"), detached.value("age"));
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:20,代码来源:SerializationTest.java

示例10: shouldSerializeEdgeAsDetached

import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter; //导入依赖的package包/类
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeEdgeAsDetached() throws Exception {
    final GryoIo gryoIo = graph.io(GryoIo.build(GryoVersion.V1_0));
    final GryoWriter gryoWriter = gryoIo.writer().create();
    final GryoReader gryoReader = gryoIo.reader().create();

    final Edge e = g.E(convertToEdgeId("marko", "knows", "vadas")).next();
    final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    gryoWriter.writeObject(outputStream, e);

    final ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
    final Edge detached = gryoReader.readObject(inputStream, DetachedEdge.class);
    assertNotNull(detached);
    assertEquals(e.label(), detached.label());
    assertEquals(e.id(), detached.id());
    assertEquals((Double) e.value("weight"), detached.value("weight"));
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:19,代码来源:SerializationTest.java

示例11: shouldSerializePropertyAsDetached

import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter; //导入依赖的package包/类
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializePropertyAsDetached() throws Exception {
    final GryoIo gryoIo = graph.io(GryoIo.build(GryoVersion.V1_0));
    final GryoWriter gryoWriter = gryoIo.writer().create();
    final GryoReader gryoReader = gryoIo.reader().create();

    final Property property = g.E(convertToEdgeId("marko", "knows", "vadas")).next().property("weight");
    final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    gryoWriter.writeObject(outputStream, property);

    final ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
    final Property detached = gryoReader.readObject(inputStream, DetachedProperty.class);
    assertNotNull(detached);
    assertEquals(property.key(), detached.key());
    assertEquals(property.value(), detached.value());
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:18,代码来源:SerializationTest.java

示例12: shouldSerializeVertexPropertyAsDetached

import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter; //导入依赖的package包/类
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeVertexPropertyAsDetached() throws Exception {
    final GryoIo gryoIo = graph.io(GryoIo.build(GryoVersion.V1_0));
    final GryoWriter gryoWriter = gryoIo.writer().create();
    final GryoReader gryoReader = gryoIo.reader().create();

    final VertexProperty vertexProperty = graph.vertices(convertToVertexId("marko")).next().property("name");
    final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    gryoWriter.writeObject(outputStream, vertexProperty);

    final ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
    final VertexProperty detached = gryoReader.readObject(inputStream, DetachedVertexProperty.class);
    assertNotNull(detached);
    assertEquals(vertexProperty.label(), detached.label());
    assertEquals(vertexProperty.id(), detached.id());
    assertEquals(vertexProperty.value(), detached.value());
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:19,代码来源:SerializationTest.java

示例13: shouldSerializeVertexPropertyWithPropertiesAsDetached

import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter; //导入依赖的package包/类
@Test
@LoadGraphWith(LoadGraphWith.GraphData.CREW)
public void shouldSerializeVertexPropertyWithPropertiesAsDetached() throws Exception {
    final GryoIo gryoIo = graph.io(GryoIo.build(GryoVersion.V1_0));
    final GryoWriter gryoWriter = gryoIo.writer().create();
    final GryoReader gryoReader = gryoIo.reader().create();

    final VertexProperty<?> vertexProperty = IteratorUtils.filter(graph.vertices(convertToVertexId("marko")).next().properties("location"), p -> p.value().equals("brussels")).next();
    final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    gryoWriter.writeObject(outputStream, vertexProperty);

    final ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
    final VertexProperty<?> detached = gryoReader.readObject(inputStream, DetachedVertexProperty.class);

    assertNotNull(detached);
    assertEquals(vertexProperty.label(), detached.label());
    assertEquals(vertexProperty.id(), detached.id());
    assertEquals(vertexProperty.value(), detached.value());
    assertEquals(vertexProperty.values("startTime").next(), detached.values("startTime").next());
    assertEquals(vertexProperty.properties("startTime").next().key(), detached.properties("startTime").next().key());
    assertEquals(vertexProperty.values("endTime").next(), detached.values("endTime").next());
    assertEquals(vertexProperty.properties("endTime").next().key(), detached.properties("endTime").next().key());
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:24,代码来源:SerializationTest.java

示例14: shouldSerializeTraversalMetrics

import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter; //导入依赖的package包/类
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeTraversalMetrics() throws Exception {
    final GryoIo gryoIo = graph.io(GryoIo.build(GryoVersion.V1_0));
    final GryoWriter gryoWriter = gryoIo.writer().create();
    final GryoReader gryoReader = gryoIo.reader().create();

    final TraversalMetrics before = g.V().both().profile().next();
    final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    gryoWriter.writeObject(outputStream, before);

    final ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
    final TraversalMetrics after = gryoReader.readObject(inputStream, TraversalMetrics.class);
    assertNotNull(after);
    assertEquals(before.getMetrics().size(), after.getMetrics().size());
    assertEquals(before.getDuration(TimeUnit.MILLISECONDS), after.getDuration(TimeUnit.MILLISECONDS));
    assertEquals(before.getMetrics(0).getCounts(), after.getMetrics().stream().findFirst().get().getCounts());
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:19,代码来源:SerializationTest.java

示例15: shouldSerializeTree

import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter; //导入依赖的package包/类
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldSerializeTree() throws Exception {
    final GryoIo gryoIo = graph.io(GryoIo.build(GryoVersion.V1_0));
    final GryoWriter gryoWriter = gryoIo.writer().create();
    final GryoReader gryoReader = gryoIo.reader().create();

    final Tree before = g.V(convertToVertexId("marko")).out().properties("name").tree().next();
    
    final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    gryoWriter.writeObject(outputStream, before);

    final ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
    final Tree after = gryoReader.readObject(inputStream, Tree.class);
    assertNotNull(after);
    //The following assertions should be sufficent.
    assertThat("Type does not match", after, instanceOf(Tree.class));
    assertEquals("The objects differ", after, before);
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:20,代码来源:SerializationTest.java


注:本文中的org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。