use of com.baidu.hugegraph.computer.core.graph.value.IdList in project hugegraph-computer by hugegraph.
the class ComputeManagerTest method addMessages.
private static void addMessages(Consumer<ManagedBuffer> consumer) throws IOException {
for (long i = 0L; i < 200L; i++) {
int count = RANDOM.nextInt(5);
for (int j = 0; j < count; 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.value.IdList 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.value.IdList 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.value.IdList in project hugegraph-computer by hugegraph.
the class MessageInputTest method expectedMessages.
private static Map<Id, List<IdList>> expectedMessages() {
Random random = new Random(1);
Map<Id, List<IdList>> globalMessages = new HashMap<>();
for (long i = 0L; i < 200L; i++) {
int count = random.nextInt(5);
for (int j = 0; j < count; j++) {
Id id = BytesId.of(random.nextInt(200));
IdList message = new IdList();
message.add(id);
List<IdList> messages = globalMessages.computeIfAbsent(id, nid -> new ArrayList<>());
messages.add(message);
}
}
return globalMessages;
}
use of com.baidu.hugegraph.computer.core.graph.value.IdList in project hugegraph-computer by hugegraph.
the class MessageInputTest method checkMessages.
private void checkMessages(Map<Id, List<IdList>> expectedMessages, MessageInput<IdList> input) throws IOException {
for (long i = 0L; i < 200L; i++) {
List<IdList> messages = expectedMessages.get(BytesId.of(i));
Id id = BytesId.of(i);
ReusablePointer idPointer = EdgesInputTest.idToReusablePointer(id);
Iterator<IdList> mit = input.iterator(idPointer);
if (messages == null) {
Assert.assertFalse(mit.hasNext());
} else {
for (int j = 0; j < messages.size(); j++) {
Assert.assertTrue(mit.hasNext());
Assert.assertTrue(messages.contains(mit.next()));
}
}
}
}
Aggregations