Search in sources :

Example 6 with Id

use of com.baidu.hugegraph.computer.core.graph.id.Id in project hugegraph-computer by hugegraph.

the class ComputeMessageRecvPartitionTest method checkIdValueListMessages.

private static void checkIdValueListMessages(PeekableIterator<KvEntry> it) throws IOException {
    for (long i = 0L; i < 10L; i++) {
        for (int j = 0; j < 2; j++) {
            Assert.assertTrue(it.hasNext());
            KvEntry currentEntry = it.next();
            Id currentId = ReceiverUtil.readId(currentEntry.key());
            Id expectId = BytesId.of(i);
            Assert.assertEquals(expectId, currentId);
            IdList expectMessage = new IdList();
            expectMessage.add(expectId);
            IdList currentValue = new IdList();
            ReceiverUtil.readValue(currentEntry.value(), currentValue);
            Assert.assertEquals(expectMessage, currentValue);
        }
    }
    Assert.assertFalse(it.hasNext());
}
Also used : KvEntry(com.baidu.hugegraph.computer.core.store.entry.KvEntry) Id(com.baidu.hugegraph.computer.core.graph.id.Id) BytesId(com.baidu.hugegraph.computer.core.graph.id.BytesId) IdList(com.baidu.hugegraph.computer.core.graph.value.IdList)

Example 7 with Id

use of com.baidu.hugegraph.computer.core.graph.id.Id in project hugegraph-computer by hugegraph.

the class ComputeMessageRecvPartitionTest method addTwentyCombineMessageBuffer.

public static void addTwentyCombineMessageBuffer(Consumer<NetworkBuffer> consumer) throws IOException {
    for (long i = 0L; i < 10L; i++) {
        for (int j = 0; j < 2; j++) {
            Id id = BytesId.of(i);
            DoubleValue message = new DoubleValue(i);
            ReceiverUtil.consumeBuffer(ReceiverUtil.writeMessage(id, message), consumer);
        }
    }
}
Also used : DoubleValue(com.baidu.hugegraph.computer.core.graph.value.DoubleValue) Id(com.baidu.hugegraph.computer.core.graph.id.Id) BytesId(com.baidu.hugegraph.computer.core.graph.id.BytesId)

Example 8 with Id

use of com.baidu.hugegraph.computer.core.graph.id.Id in project hugegraph-computer by hugegraph.

the class ComputeMessageRecvPartitionTest method addTwentyDuplicateIdValueListMessageBuffer.

private static void addTwentyDuplicateIdValueListMessageBuffer(Consumer<NetworkBuffer> consumer) throws IOException {
    for (long i = 0L; i < 10L; i++) {
        for (int j = 0; j < 2; j++) {
            Id id = BytesId.of(i);
            IdList message = new IdList();
            message.add(id);
            ReceiverUtil.consumeBuffer(ReceiverUtil.writeMessage(id, message), consumer);
        }
    }
}
Also used : Id(com.baidu.hugegraph.computer.core.graph.id.Id) BytesId(com.baidu.hugegraph.computer.core.graph.id.BytesId) IdList(com.baidu.hugegraph.computer.core.graph.value.IdList)

Example 9 with Id

use of com.baidu.hugegraph.computer.core.graph.id.Id in project hugegraph-computer by hugegraph.

the class VertexMessageRecvPartitionTest method checkPartitionIterator.

public static void checkPartitionIterator(PeekableIterator<KvEntry> it) throws IOException {
    for (long i = 0L; i < 10L; i++) {
        Assert.assertTrue(it.hasNext());
        KvEntry entry = it.next();
        Id id = ReceiverUtil.readId(entry.key());
        Assert.assertEquals(BytesId.of(i), id);
    }
}
Also used : KvEntry(com.baidu.hugegraph.computer.core.store.entry.KvEntry) Id(com.baidu.hugegraph.computer.core.graph.id.Id) BytesId(com.baidu.hugegraph.computer.core.graph.id.BytesId)

Example 10 with Id

use of com.baidu.hugegraph.computer.core.graph.id.Id in project hugegraph-computer by hugegraph.

the class EntryOutputTest method inputFromEntries.

private static BytesInput inputFromEntries(List<Integer> entries, boolean needSort) throws IOException {
    /*
         * All integer data will convert to Id type, so upper layer also
         * needs to use the Id type to make a judgment
         */
    List<Id> data = intListToLongIds(entries);
    BytesOutput output = IOFactory.createBytesOutput(Constants.SMALL_BUF_SIZE);
    EntryOutput entryOutput = new EntryOutputImpl(output, needSort);
    int index = 0;
    KvEntryWriter entry1 = entryOutput.writeEntry(data.get(index++));
    entry1.writeSubKv(data.get(index++), data.get(index++));
    entry1.writeSubKv(data.get(index++), data.get(index++));
    entry1.writeSubKv(data.get(index++), data.get(index++));
    entry1.writeFinish();
    KvEntryWriter entry2 = entryOutput.writeEntry(data.get(index++));
    entry2.writeSubKv(data.get(index++), data.get(index++));
    entry2.writeSubKv(data.get(index++), data.get(index));
    entry2.writeFinish();
    return EntriesUtil.inputFromOutput(output);
}
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)

Aggregations

Id (com.baidu.hugegraph.computer.core.graph.id.Id)74 BytesId (com.baidu.hugegraph.computer.core.graph.id.BytesId)51 Test (org.junit.Test)29 IdList (com.baidu.hugegraph.computer.core.graph.value.IdList)18 Edge (com.baidu.hugegraph.computer.core.graph.edge.Edge)12 DoubleValue (com.baidu.hugegraph.computer.core.graph.value.DoubleValue)12 LongValue (com.baidu.hugegraph.computer.core.graph.value.LongValue)12 Vertex (com.baidu.hugegraph.computer.core.graph.vertex.Vertex)12 ComputerContext (com.baidu.hugegraph.computer.core.common.ComputerContext)11 GraphFactory (com.baidu.hugegraph.computer.core.graph.GraphFactory)10 KvEntry (com.baidu.hugegraph.computer.core.store.entry.KvEntry)9 ConnectionId (com.baidu.hugegraph.computer.core.network.ConnectionId)8 IdListList (com.baidu.hugegraph.computer.core.graph.value.IdListList)7 Properties (com.baidu.hugegraph.computer.core.graph.properties.Properties)6 File (java.io.File)6 Value (com.baidu.hugegraph.computer.core.graph.value.Value)5 BytesInput (com.baidu.hugegraph.computer.core.io.BytesInput)5 Config (com.baidu.hugegraph.computer.core.config.Config)4 BooleanValue (com.baidu.hugegraph.computer.core.graph.value.BooleanValue)4 FloatValue (com.baidu.hugegraph.computer.core.graph.value.FloatValue)4