use of com.baidu.hugegraph.structure.schema.IndexLabel in project incubator-hugegraph-toolchain by apache.
the class TaskApiTest method testListByStatus.
@Test
public void testListByStatus() {
IndexLabel personByCity = schema().getIndexLabel("personByCity");
IndexLabel personByAge = schema().getIndexLabel("personByAge");
IndexLabel knowsByDate = schema().getIndexLabel("knowsByDate");
IndexLabel createdByDate = schema().getIndexLabel("createdByDate");
Set<Long> taskIds = new HashSet<>();
taskIds.add(rebuildAPI.rebuild(personByCity));
taskIds.add(rebuildAPI.rebuild(personByAge));
taskIds.add(rebuildAPI.rebuild(knowsByDate));
taskIds.add(rebuildAPI.rebuild(createdByDate));
taskIds.forEach(BaseApiTest::waitUntilTaskCompleted);
List<Task> tasks = taskAPI.list("SUCCESS", -1);
Assert.assertEquals(4, tasks.size());
Set<Long> listedTaskIds = new HashSet<>();
for (Task task : tasks) {
listedTaskIds.add(task.id());
}
Assert.assertEquals(taskIds.size(), listedTaskIds.size());
Assert.assertTrue(taskIds.containsAll(listedTaskIds));
tasks = taskAPI.list("SUCCESS", 3);
Assert.assertEquals(3, tasks.size());
Set<Long> listedTaskIds1 = new HashSet<>();
for (Task task : tasks) {
listedTaskIds1.add(task.id());
}
Assert.assertEquals(3, listedTaskIds1.size());
Assert.assertTrue(taskIds.containsAll(listedTaskIds));
}
use of com.baidu.hugegraph.structure.schema.IndexLabel in project incubator-hugegraph-toolchain by apache.
the class TaskApiTest method testListByIds.
@Test
public void testListByIds() {
IndexLabel personByCity = schema().getIndexLabel("personByCity");
IndexLabel personByAge = schema().getIndexLabel("personByAge");
IndexLabel knowsByDate = schema().getIndexLabel("knowsByDate");
IndexLabel createdByDate = schema().getIndexLabel("createdByDate");
List<Long> taskIds = new ArrayList<>();
taskIds.add(rebuildAPI.rebuild(personByCity));
taskIds.add(rebuildAPI.rebuild(personByAge));
taskIds.add(rebuildAPI.rebuild(knowsByDate));
taskIds.add(rebuildAPI.rebuild(createdByDate));
taskIds.forEach(BaseApiTest::waitUntilTaskCompleted);
List<Task> tasks = taskAPI.list(taskIds);
Assert.assertEquals(4, tasks.size());
Set<Long> listedTaskIds = new HashSet<>();
for (Task task : tasks) {
listedTaskIds.add(task.id());
}
Assert.assertEquals(taskIds.size(), listedTaskIds.size());
Assert.assertTrue(taskIds.containsAll(listedTaskIds));
}
use of com.baidu.hugegraph.structure.schema.IndexLabel in project incubator-hugegraph-toolchain by apache.
the class TaskApiTest method testTaskAsMap.
@Test
public void testTaskAsMap() {
IndexLabel personByCity = schema().getIndexLabel("personByCity");
long taskId = rebuildAPI.rebuild(personByCity);
Task task = taskAPI.get(taskId);
Assert.assertNotNull(task);
Assert.assertEquals(taskId, task.id());
waitUntilTaskCompleted(taskId);
task = taskAPI.get(taskId);
Map<String, Object> taskMap = task.asMap();
Assert.assertEquals("rebuild_index", taskMap.get(Task.P.TYPE));
Assert.assertEquals("success", taskMap.get(Task.P.STATUS));
}
use of com.baidu.hugegraph.structure.schema.IndexLabel in project incubator-hugegraph-toolchain by apache.
the class TaskApiTest method testListByStatusAndPage.
@Test
public void testListByStatusAndPage() {
IndexLabel personByCity = schema().getIndexLabel("personByCity");
IndexLabel personByAge = schema().getIndexLabel("personByAge");
IndexLabel knowsByDate = schema().getIndexLabel("knowsByDate");
IndexLabel createdByDate = schema().getIndexLabel("createdByDate");
Set<Long> taskIds = new HashSet<>();
taskIds.add(rebuildAPI.rebuild(personByCity));
taskIds.add(rebuildAPI.rebuild(personByAge));
taskIds.add(rebuildAPI.rebuild(knowsByDate));
taskIds.add(rebuildAPI.rebuild(createdByDate));
taskIds.forEach(BaseApiTest::waitUntilTaskCompleted);
TasksWithPage tasksWithPage = taskAPI.list("SUCCESS", "", 2);
List<Task> tasks = tasksWithPage.tasks();
Assert.assertEquals(2, tasks.size());
Set<Long> listedTaskIds = new HashSet<>();
for (Task task : tasks) {
listedTaskIds.add(task.id());
}
tasksWithPage = taskAPI.list("SUCCESS", tasksWithPage.page(), 2);
List<Task> tasks1 = tasksWithPage.tasks();
Assert.assertEquals(2, tasks1.size());
Assert.assertNull(tasksWithPage.page());
for (Task task : tasks1) {
listedTaskIds.add(task.id());
}
Assert.assertEquals(taskIds.size(), listedTaskIds.size());
Assert.assertTrue(taskIds.containsAll(listedTaskIds));
}
use of com.baidu.hugegraph.structure.schema.IndexLabel in project incubator-hugegraph-toolchain by apache.
the class IndexLabelApiTest method testCreateUniqueIndex.
@Test
public void testCreateUniqueIndex() {
IndexLabel indexLabel = schema().indexLabel("personByCity").onV("person").by("city").unique().create();
Assert.assertEquals("personByCity", indexLabel.name());
Assert.assertEquals(HugeType.VERTEX_LABEL, indexLabel.baseType());
Assert.assertEquals("person", indexLabel.baseValue());
Assert.assertEquals(IndexType.UNIQUE, indexLabel.indexType());
List<String> fields = ImmutableList.of("city");
Assert.assertTrue(fields.size() == indexLabel.indexFields().size());
Assert.assertTrue(fields.containsAll(indexLabel.indexFields()));
}
Aggregations