use of com.baidu.hugegraph.computer.core.graph.id.Id 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()));
}
}
}
}
use of com.baidu.hugegraph.computer.core.graph.id.Id in project hugegraph-computer by hugegraph.
the class BuiltinGraphFactoryTest method testCreateUuidId.
@Test
public void testCreateUuidId() {
UUID uuid = UUID.randomUUID();
GraphFactory graphFactory = graphFactory();
Id id = graphFactory.createId(uuid);
Assert.assertEquals(IdType.UUID, id.idType());
Assert.assertEquals(BytesId.of(uuid), id);
}
use of com.baidu.hugegraph.computer.core.graph.id.Id in project hugegraph-computer by hugegraph.
the class BuiltinGraphFactoryTest method testCreateUtf8Id.
@Test
public void testCreateUtf8Id() {
String value = "John";
GraphFactory graphFactory = graphFactory();
Id id = graphFactory.createId(value);
Assert.assertEquals(IdType.UTF8, id.idType());
Assert.assertEquals(BytesId.of(value), id);
}
use of com.baidu.hugegraph.computer.core.graph.id.Id in project hugegraph-computer by hugegraph.
the class HashPartitionerTest method test1Worker1Partition.
@Test
public void test1Worker1Partition() {
Config config = UnitTestBase.updateWithRequiredOptions(ComputerOptions.JOB_WORKERS_COUNT, "1", ComputerOptions.JOB_PARTITIONS_COUNT, "1");
Partitioner partitioner = config.createObject(ComputerOptions.WORKER_PARTITIONER);
partitioner.init(config);
Id vertexId1 = BytesId.of(1L);
Id vertexId2 = BytesId.of(2L);
Id vertexId3 = BytesId.of(-1L);
Id vertexId4 = BytesId.of(-100L);
Id vertexId5 = BytesId.of(Long.MIN_VALUE);
Id vertexId6 = BytesId.of(Long.MAX_VALUE);
int partition1 = partitioner.partitionId(vertexId1);
int partition2 = partitioner.partitionId(vertexId2);
int partition3 = partitioner.partitionId(vertexId3);
int partition4 = partitioner.partitionId(vertexId4);
int partition5 = partitioner.partitionId(vertexId5);
int partition6 = partitioner.partitionId(vertexId6);
Assert.assertEquals(0, partition1);
Assert.assertEquals(0, partition2);
Assert.assertEquals(0, partition3);
Assert.assertEquals(0, partition4);
Assert.assertEquals(0, partition5);
Assert.assertEquals(0, partition6);
int workerId1 = partitioner.workerId(partition1);
int workerId2 = partitioner.workerId(partition2);
int workerId3 = partitioner.workerId(partition3);
int workerId4 = partitioner.workerId(partition4);
int workerId5 = partitioner.workerId(partition5);
int workerId6 = partitioner.workerId(partition6);
Assert.assertEquals(1, workerId1);
Assert.assertEquals(1, workerId2);
Assert.assertEquals(1, workerId3);
Assert.assertEquals(1, workerId4);
Assert.assertEquals(1, workerId5);
Assert.assertEquals(1, workerId6);
}
use of com.baidu.hugegraph.computer.core.graph.id.Id in project hugegraph-computer by hugegraph.
the class HashPartitionerTest method test1Worker2Partition.
@Test
public void test1Worker2Partition() {
Config config = UnitTestBase.updateWithRequiredOptions(ComputerOptions.JOB_WORKERS_COUNT, "1", ComputerOptions.JOB_PARTITIONS_COUNT, "2");
Partitioner partitioner = config.createObject(ComputerOptions.WORKER_PARTITIONER);
partitioner.init(config);
Id vertexId1 = BytesId.of(1L);
Id vertexId2 = BytesId.of(2L);
Id vertexId3 = BytesId.of(-1L);
Id vertexId4 = BytesId.of(-100L);
Id vertexId5 = BytesId.of(Long.MIN_VALUE);
Id vertexId6 = BytesId.of(Long.MAX_VALUE);
int partition1 = partitioner.partitionId(vertexId1);
int partition2 = partitioner.partitionId(vertexId2);
int partition3 = partitioner.partitionId(vertexId3);
int partition4 = partitioner.partitionId(vertexId4);
int partition5 = partitioner.partitionId(vertexId5);
int partition6 = partitioner.partitionId(vertexId6);
Assert.assertTrue(partition1 < 2);
Assert.assertTrue(partition2 < 2);
Assert.assertTrue(partition3 < 2);
Assert.assertTrue(partition4 < 2);
Assert.assertTrue(partition5 < 2);
Assert.assertTrue(partition6 < 2);
int workerId1 = partitioner.workerId(partition1);
int workerId2 = partitioner.workerId(partition2);
int workerId3 = partitioner.workerId(partition3);
int workerId4 = partitioner.workerId(partition4);
int workerId5 = partitioner.workerId(partition5);
int workerId6 = partitioner.workerId(partition6);
Assert.assertEquals(1, workerId1);
Assert.assertEquals(1, workerId2);
Assert.assertEquals(1, workerId3);
Assert.assertEquals(1, workerId4);
Assert.assertEquals(1, workerId5);
Assert.assertEquals(1, workerId6);
}
Aggregations