Search in sources :

Example 1 with EntryInput

use of com.baidu.hugegraph.computer.core.store.entry.EntryInput in project hugegraph-computer by hugegraph.

the class WriteBuffersTest method wrapForRead.

@Test
public void wrapForRead() throws IOException {
    GraphFactory graphFactory = context().graphFactory();
    WriteBuffers buffers = new WriteBuffers(context(), 10, 20);
    Vertex vertex = graphFactory.createVertex(BytesId.of(1L), new DoubleValue(0.5d));
    buffers.writeVertex(vertex);
    buffers.prepareSorting();
    try (RandomAccessInput input = buffers.wrapForRead()) {
        EntryInput entryInput = new EntryInputImpl(input);
        StreamGraphInput graphInput = new StreamGraphInput(context(), entryInput);
        vertex.value(null);
        Assert.assertEquals(vertex, graphInput.readVertex());
    }
}
Also used : RandomAccessInput(com.baidu.hugegraph.computer.core.io.RandomAccessInput) Vertex(com.baidu.hugegraph.computer.core.graph.vertex.Vertex) GraphFactory(com.baidu.hugegraph.computer.core.graph.GraphFactory) EntryInputImpl(com.baidu.hugegraph.computer.core.store.entry.EntryInputImpl) DoubleValue(com.baidu.hugegraph.computer.core.graph.value.DoubleValue) EntryInput(com.baidu.hugegraph.computer.core.store.entry.EntryInput) StreamGraphInput(com.baidu.hugegraph.computer.core.io.StreamGraphInput) Test(org.junit.Test)

Aggregations

GraphFactory (com.baidu.hugegraph.computer.core.graph.GraphFactory)1 DoubleValue (com.baidu.hugegraph.computer.core.graph.value.DoubleValue)1 Vertex (com.baidu.hugegraph.computer.core.graph.vertex.Vertex)1 RandomAccessInput (com.baidu.hugegraph.computer.core.io.RandomAccessInput)1 StreamGraphInput (com.baidu.hugegraph.computer.core.io.StreamGraphInput)1 EntryInput (com.baidu.hugegraph.computer.core.store.entry.EntryInput)1 EntryInputImpl (com.baidu.hugegraph.computer.core.store.entry.EntryInputImpl)1 Test (org.junit.Test)1