use of com.baidu.hugegraph.computer.core.graph.id.Id 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.id.Id in project hugegraph-computer by hugegraph.
the class MapValue method write.
protected void write(RandomAccessOutput out, boolean writeElemType) throws IOException {
out.writeInt(this.map.size());
if (writeElemType) {
out.writeByte(this.elemType.code());
}
for (Map.Entry<Id, T> entry : this.map.entrySet()) {
Id id = entry.getKey();
T value = entry.getValue();
id.write(out);
value.write(out);
}
}
use of com.baidu.hugegraph.computer.core.graph.id.Id in project hugegraph-computer by hugegraph.
the class StoreTestUtil method idFromPointer.
public static Id idFromPointer(Pointer pointer) throws IOException {
BytesInput input = IOFactory.createBytesInput(pointer.bytes());
Id id = new BytesId();
id.read(input);
return id;
}
use of com.baidu.hugegraph.computer.core.graph.id.Id in project hugegraph-computer by hugegraph.
the class EdgeMessageRecvPartitionTest method checkTenEdgesWithCombinedProperties.
private static void checkTenEdgesWithCombinedProperties(Iterator<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);
EntryIterator subKvIt = EntriesUtil.subKvIterFromEntry(entry);
for (long j = i + 1; j < i + 3; j++) {
Assert.assertTrue(subKvIt.hasNext());
KvEntry subKv = subKvIt.next();
Id targetId = ReceiverUtil.readId(subKv.key());
Assert.assertEquals(BytesId.of(j), targetId);
Properties properties = graphFactory().createProperties();
ReceiverUtil.readValue(subKv.value(), properties);
Assert.assertEquals(2, properties.size());
LongValue v1 = properties.get("p1");
Assert.assertEquals(new LongValue(i), v1);
LongValue v2 = properties.get("p2");
Assert.assertEquals(new LongValue(2L * i), v2);
}
}
Assert.assertFalse(it.hasNext());
}
use of com.baidu.hugegraph.computer.core.graph.id.Id in project hugegraph-computer by hugegraph.
the class EdgeMessageRecvPartitionTest method checkTenEdges.
public static void checkTenEdges(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);
EntryIterator subKvIt = EntriesUtil.subKvIterFromEntry(entry);
for (long j = i + 1; j < i + 3; j++) {
Assert.assertTrue(subKvIt.hasNext());
KvEntry subKv = subKvIt.next();
Id targetId = ReceiverUtil.readId(subKv.key());
Assert.assertEquals(BytesId.of(j), targetId);
Properties properties = graphFactory().createProperties();
ReceiverUtil.readValue(subKv.value(), properties);
Assert.assertEquals(1, properties.size());
LongValue v1 = properties.get("p1");
Assert.assertEquals(new LongValue(i), v1);
}
}
Assert.assertFalse(it.hasNext());
}
Aggregations