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());
}
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);
}
}
}
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);
}
}
}
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);
}
}
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);
}
Aggregations