use of com.baidu.hugegraph.computer.core.graph.id.Id in project hugegraph-computer by hugegraph.
the class HashPartitionerTest method test1Worker3Partition.
@Test
public void test1Worker3Partition() {
Config config = UnitTestBase.updateWithRequiredOptions(ComputerOptions.JOB_WORKERS_COUNT, "1", ComputerOptions.JOB_PARTITIONS_COUNT, "3");
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 < 3);
Assert.assertTrue(partition2 < 3);
Assert.assertTrue(partition3 < 3);
Assert.assertTrue(partition4 < 3);
Assert.assertTrue(partition5 < 3);
Assert.assertTrue(partition6 < 3);
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 IdListListTest method testReadWrite.
@Test
public void testReadWrite() throws IOException {
Id longId1 = BytesId.of(100L);
Id longId2 = BytesId.of(200L);
IdList listValue = new IdList();
listValue.add(longId1);
listValue.add(longId2);
IdListList oldValue = new IdListList();
oldValue.add(listValue);
assertValueEqualAfterWriteAndRead(oldValue);
}
use of com.baidu.hugegraph.computer.core.graph.id.Id in project hugegraph-computer by hugegraph.
the class IdListListTest method test.
@Test
public void test() {
Id longId1 = BytesId.of(100L);
Id longId2 = BytesId.of(200L);
IdList listValue1 = new IdList();
IdList listValue2 = new IdList();
IdListList listListValue1 = new IdListList();
IdListList listListValue2 = new IdListList();
listValue1.add(longId1);
listValue2.add(longId2);
listListValue1.add(listValue1);
listListValue2.add(listValue1);
Assert.assertEquals(ValueType.ID_LIST_LIST, listListValue1.valueType());
Assert.assertEquals(ValueType.ID_LIST, listListValue1.elemType());
Assert.assertTrue(ListUtils.isEqualList(Lists.newArrayList(listValue1), listListValue1.values()));
Assert.assertEquals(listListValue1, listListValue2);
listValue2.add(longId2);
listListValue2.add(listValue2);
Assert.assertTrue(ListUtils.isEqualList(Lists.newArrayList(listValue1, listValue2), listListValue2.values()));
Assert.assertNotEquals(listListValue1, listListValue2);
Assert.assertEquals(ListUtils.hashCodeForList(Lists.newArrayList(listValue1)), listListValue1.hashCode());
}
use of com.baidu.hugegraph.computer.core.graph.id.Id in project hugegraph-computer by hugegraph.
the class IdValueListTest method testCompare.
@Test
public void testCompare() {
Id longId1 = BytesId.of(100L);
Id longId2 = BytesId.of(200L);
IdList value1 = new IdList();
value1.add(longId1);
IdList value2 = new IdList();
value2.add(longId1);
IdList value3 = new IdList();
value3.add(longId1);
value3.add(longId2);
Assert.assertEquals(0, value1.compareTo(value2));
Assert.assertLt(0, value1.compareTo(value3));
Assert.assertGt(0, value3.compareTo(value1));
}
use of com.baidu.hugegraph.computer.core.graph.id.Id in project hugegraph-computer by hugegraph.
the class IdValueListTest method testReadWrite.
@Test
public void testReadWrite() throws IOException {
Id longId1 = BytesId.of(100L);
Id longId2 = BytesId.of(200L);
IdList oldValue = new IdList();
oldValue.add(longId1);
oldValue.add(longId2);
assertValueEqualAfterWriteAndRead(oldValue);
}
Aggregations