use of com.baidu.hugegraph.driver.SchemaManager in project incubator-hugegraph-toolchain by apache.
the class IndexLabelTest method testAddIndexLabelAsync.
@Test
public void testAddIndexLabelAsync() {
SchemaManager schema = schema();
schema.vertexLabel("player").properties("name", "age").create();
IndexLabel playerByName = schema.indexLabel("playerByName").onV("player").by("name").secondary().build();
long task = schema.addIndexLabelAsync(playerByName);
waitUntilTaskCompleted(task);
playerByName = schema.getIndexLabel(playerByName.name());
Assert.assertNotNull(playerByName);
}
use of com.baidu.hugegraph.driver.SchemaManager in project incubator-hugegraph-toolchain by apache.
the class IndexLabelTest method testEliminateIndexLabelWithUserData.
@Test
public void testEliminateIndexLabelWithUserData() {
SchemaManager schema = schema();
BaseFuncTest.initVertexLabel();
IndexLabel personByCity = schema.indexLabel("personByCity").onV("person").by("city").secondary().userdata("type", "secondary").userdata("icon", "picture").ifNotExist().create();
Assert.assertEquals(3, personByCity.userdata().size());
Assert.assertEquals("secondary", personByCity.userdata().get("type"));
Assert.assertEquals("picture", personByCity.userdata().get("icon"));
String time = (String) personByCity.userdata().get("~create_time");
Date createTime = DateUtil.parse(time);
Assert.assertTrue(createTime.before(DateUtil.now()));
personByCity = schema.indexLabel("personByCity").userdata("type", "secondary").eliminate();
Assert.assertEquals(2, personByCity.userdata().size());
Assert.assertEquals("picture", personByCity.userdata().get("icon"));
time = (String) personByCity.userdata().get("~create_time");
Assert.assertEquals(createTime, DateUtil.parse(time));
}
use of com.baidu.hugegraph.driver.SchemaManager in project incubator-hugegraph-toolchain by apache.
the class IndexLabelTest method testAddIndexLabelWithUserData.
@Test
public void testAddIndexLabelWithUserData() {
SchemaManager schema = schema();
BaseFuncTest.initVertexLabel();
IndexLabel personByCity = schema.indexLabel("personByCity").onV("person").by("city").secondary().userdata("type", "secondary").ifNotExist().create();
Assert.assertEquals(2, personByCity.userdata().size());
Assert.assertEquals("secondary", personByCity.userdata().get("type"));
String time = (String) personByCity.userdata().get("~create_time");
Date createTime = DateUtil.parse(time);
Assert.assertTrue(createTime.before(DateUtil.now()));
IndexLabel personByAge = schema.indexLabel("personByAge").onV("person").by("age").range().userdata("type", "secondary").userdata("type", "range").ifNotExist().create();
Assert.assertEquals(2, personByAge.userdata().size());
Assert.assertEquals("range", personByAge.userdata().get("type"));
time = (String) personByAge.userdata().get("~create_time");
createTime = DateUtil.parse(time);
Assert.assertTrue(createTime.before(DateUtil.now()));
}
use of com.baidu.hugegraph.driver.SchemaManager in project incubator-hugegraph-toolchain by apache.
the class IndexLabelTest method testRemoveIndexLabelAsync.
@Test
public void testRemoveIndexLabelAsync() {
SchemaManager schema = schema();
schema.vertexLabel("player").properties("name", "age").create();
IndexLabel playerByName = schema.indexLabel("playerByName").onV("player").by("name").secondary().create();
Assert.assertNotNull(playerByName);
// Remove index label async
schema.removeIndexLabelAsync("playerByName");
}
use of com.baidu.hugegraph.driver.SchemaManager in project incubator-hugegraph-toolchain by apache.
the class PropertyKeyTest method testListByNames.
@Test
public void testListByNames() {
SchemaManager schema = schema();
PropertyKey age = schema.propertyKey("age").create();
PropertyKey id = schema.propertyKey("id").create();
List<PropertyKey> propertyKeys;
propertyKeys = schema.getPropertyKeys(ImmutableList.of("age"));
Assert.assertEquals(1, propertyKeys.size());
assertContains(propertyKeys, age);
propertyKeys = schema.getPropertyKeys(ImmutableList.of("id"));
Assert.assertEquals(1, propertyKeys.size());
assertContains(propertyKeys, id);
propertyKeys = schema.getPropertyKeys(ImmutableList.of("age", "id"));
Assert.assertEquals(2, propertyKeys.size());
assertContains(propertyKeys, age);
assertContains(propertyKeys, id);
}
Aggregations