Search in sources :

Example 6 with EntryOutput

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

the class EdgesInputTest method writeVertex.

private static byte[] writeVertex(Vertex vertex) throws IOException {
    BytesOutput bytesOutput = IOFactory.createBytesOutput(Constants.SMALL_BUF_SIZE);
    EntryOutput entryOutput = new EntryOutputImpl(bytesOutput);
    GraphComputeOutput output = new StreamGraphOutput(context(), entryOutput);
    output.writeVertex(vertex);
    return bytesOutput.toByteArray();
}
Also used : EntryOutput(com.baidu.hugegraph.computer.core.store.entry.EntryOutput) EntryOutputImpl(com.baidu.hugegraph.computer.core.store.entry.EntryOutputImpl) BytesOutput(com.baidu.hugegraph.computer.core.io.BytesOutput) StreamGraphOutput(com.baidu.hugegraph.computer.core.io.StreamGraphOutput) GraphComputeOutput(com.baidu.hugegraph.computer.core.io.GraphComputeOutput)

Example 7 with EntryOutput

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

the class ComputeManagerTest method writeVertex.

private static byte[] writeVertex(Vertex vertex) throws IOException {
    BytesOutput bytesOutput = IOFactory.createBytesOutput(Constants.SMALL_BUF_SIZE);
    EntryOutput entryOutput = new EntryOutputImpl(bytesOutput);
    GraphComputeOutput output = new StreamGraphOutput(context(), entryOutput);
    output.writeVertex(vertex);
    return bytesOutput.toByteArray();
}
Also used : EntryOutput(com.baidu.hugegraph.computer.core.store.entry.EntryOutput) EntryOutputImpl(com.baidu.hugegraph.computer.core.store.entry.EntryOutputImpl) BytesOutput(com.baidu.hugegraph.computer.core.io.BytesOutput) StreamGraphOutput(com.baidu.hugegraph.computer.core.io.StreamGraphOutput) GraphComputeOutput(com.baidu.hugegraph.computer.core.io.GraphComputeOutput)

Example 8 with EntryOutput

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

the class ReceiverUtil method writeMessage.

public static byte[] writeMessage(Id id, Writable message) throws IOException {
    BytesOutput bytesOutput = IOFactory.createBytesOutput(Constants.SMALL_BUF_SIZE);
    EntryOutput entryOutput = new EntryOutputImpl(bytesOutput);
    entryOutput.writeEntry(out -> {
        id.write(out);
    }, message);
    return bytesOutput.toByteArray();
}
Also used : EntryOutput(com.baidu.hugegraph.computer.core.store.entry.EntryOutput) EntryOutputImpl(com.baidu.hugegraph.computer.core.store.entry.EntryOutputImpl) BytesOutput(com.baidu.hugegraph.computer.core.io.BytesOutput)

Example 9 with EntryOutput

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

the class EdgeMessageRecvPartitionTest method writeEdges.

private static byte[] writeEdges(Vertex vertex) throws IOException {
    BytesOutput bytesOutput = IOFactory.createBytesOutput(Constants.SMALL_BUF_SIZE);
    EntryOutput entryOutput = new EntryOutputImpl(bytesOutput);
    Id id = vertex.id();
    KvEntryWriter subKvWriter = entryOutput.writeEntry(out -> {
        id.write(out);
    });
    for (Edge edge : vertex.edges()) {
        Id targetId = edge.targetId();
        subKvWriter.writeSubKv(out -> {
            targetId.write(out);
        }, out -> {
            edge.properties().write(out);
        });
    }
    subKvWriter.writeFinish();
    return bytesOutput.toByteArray();
}
Also used : EntryOutput(com.baidu.hugegraph.computer.core.store.entry.EntryOutput) EntryOutputImpl(com.baidu.hugegraph.computer.core.store.entry.EntryOutputImpl) BytesOutput(com.baidu.hugegraph.computer.core.io.BytesOutput) KvEntryWriter(com.baidu.hugegraph.computer.core.store.entry.KvEntryWriter) Id(com.baidu.hugegraph.computer.core.graph.id.Id) BytesId(com.baidu.hugegraph.computer.core.graph.id.BytesId) Edge(com.baidu.hugegraph.computer.core.graph.edge.Edge)

Example 10 with EntryOutput

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

the class VertexMessageRecvPartitionTest method writeVertex.

private static byte[] writeVertex(Vertex vertex) throws IOException {
    BytesOutput bytesOutput = IOFactory.createBytesOutput(Constants.SMALL_BUF_SIZE);
    EntryOutput entryOutput = new EntryOutputImpl(bytesOutput);
    entryOutput.writeEntry(out -> {
        vertex.id().write(out);
    }, out -> {
        out.writeUTF(vertex.label());
        vertex.properties().write(out);
    });
    return bytesOutput.toByteArray();
}
Also used : EntryOutput(com.baidu.hugegraph.computer.core.store.entry.EntryOutput) EntryOutputImpl(com.baidu.hugegraph.computer.core.store.entry.EntryOutputImpl) BytesOutput(com.baidu.hugegraph.computer.core.io.BytesOutput)

Aggregations

EntryOutput (com.baidu.hugegraph.computer.core.store.entry.EntryOutput)12 EntryOutputImpl (com.baidu.hugegraph.computer.core.store.entry.EntryOutputImpl)12 BytesOutput (com.baidu.hugegraph.computer.core.io.BytesOutput)11 GraphComputeOutput (com.baidu.hugegraph.computer.core.io.GraphComputeOutput)4 StreamGraphOutput (com.baidu.hugegraph.computer.core.io.StreamGraphOutput)4 KvEntryWriter (com.baidu.hugegraph.computer.core.store.entry.KvEntryWriter)4 BytesId (com.baidu.hugegraph.computer.core.graph.id.BytesId)3 Id (com.baidu.hugegraph.computer.core.graph.id.Id)3 BytesInput (com.baidu.hugegraph.computer.core.io.BytesInput)3 Test (org.junit.Test)3 KvEntry (com.baidu.hugegraph.computer.core.store.entry.KvEntry)2 ComputerException (com.baidu.hugegraph.computer.core.common.exception.ComputerException)1 Edge (com.baidu.hugegraph.computer.core.graph.edge.Edge)1 Writable (com.baidu.hugegraph.computer.core.io.Writable)1 KvEntriesInput (com.baidu.hugegraph.computer.core.store.buffer.KvEntriesInput)1 SubKvEntriesInput (com.baidu.hugegraph.computer.core.store.buffer.SubKvEntriesInput)1