use of com.baidu.hugegraph.driver.SchemaManager in project incubator-hugegraph-toolchain by apache.
the class IndexLabelTest method testListByNames.
@Test
public void testListByNames() {
SchemaManager schema = schema();
schema.vertexLabel("player").properties("name", "age").create();
IndexLabel playerByName = schema.indexLabel("playerByName").onV("player").by("name").secondary().create();
IndexLabel playerByAge = schema.indexLabel("playerByAge").onV("player").by("age").range().create();
List<IndexLabel> indexLabels;
indexLabels = schema.getIndexLabels(ImmutableList.of("playerByName"));
Assert.assertEquals(1, indexLabels.size());
assertContains(indexLabels, playerByName);
indexLabels = schema.getIndexLabels(ImmutableList.of("playerByAge"));
Assert.assertEquals(1, indexLabels.size());
assertContains(indexLabels, playerByAge);
indexLabels = schema.getIndexLabels(ImmutableList.of("playerByName", "playerByAge"));
Assert.assertEquals(2, indexLabels.size());
assertContains(indexLabels, playerByName);
assertContains(indexLabels, playerByAge);
}
use of com.baidu.hugegraph.driver.SchemaManager in project incubator-hugegraph-toolchain by apache.
the class IndexLabelTest method testSetCheckExist.
@Test
public void testSetCheckExist() {
SchemaManager schema = schema();
schema.vertexLabel("player").properties("name", "age").create();
IndexLabel playerByName = schema.indexLabel("playerByName").onV("player").by("name").secondary().create();
Assert.assertTrue(playerByName.checkExist());
playerByName.checkExist(false);
Assert.assertFalse(playerByName.checkExist());
}
use of com.baidu.hugegraph.driver.SchemaManager in project incubator-hugegraph-toolchain by apache.
the class IndexLabelTest method testRemoveIndexLabelSync.
@Test
public void testRemoveIndexLabelSync() {
SchemaManager schema = schema();
schema.vertexLabel("player").properties("name", "age").create();
IndexLabel playerByName = schema.indexLabel("playerByName").on(true, "player").secondary().by("name").create();
Assert.assertNotNull(playerByName);
// Remove index label sync
schema.removeIndexLabel("playerByName");
playerByName = schema.indexLabel("playerByName").onV("player").by("name").secondary().create();
Assert.assertNotNull(playerByName);
// Remove index label sync with timeout
schema.removeIndexLabel("playerByName", 10);
}
use of com.baidu.hugegraph.driver.SchemaManager in project incubator-hugegraph-toolchain by apache.
the class IndexLabelTest method testResetVertexLabelId.
@Test
public void testResetVertexLabelId() {
SchemaManager schema = schema();
schema.vertexLabel("player").properties("name", "age").create();
IndexLabel playerByName = schema.indexLabel("playerByName").onV("player").by("name").secondary().create();
Assert.assertTrue(playerByName.id() > 0);
playerByName.resetId();
Assert.assertEquals(0L, playerByName.id());
}
use of com.baidu.hugegraph.driver.SchemaManager in project incubator-hugegraph-toolchain by apache.
the class PropertyKeyTest method testOlapPropertyKey.
@Test
public void testOlapPropertyKey() {
SchemaManager schema = schema();
PropertyKey pagerank = schema.propertyKey("pagerank").asDouble().writeType(WriteType.OLAP_RANGE).build();
schema.addPropertyKey(pagerank);
schema.getPropertyKey(pagerank.name());
schema.clearPropertyKey(pagerank);
schema.removePropertyKey(pagerank.name());
Utils.assertResponseError(404, () -> {
schema.getPropertyKey(pagerank.name());
});
long task = schema.addPropertyKeyAsync(pagerank);
waitUntilTaskCompleted(task);
schema.getPropertyKey(pagerank.name());
task = schema.clearPropertyKeyAsync(pagerank);
waitUntilTaskCompleted(task);
task = schema.removePropertyKeyAsync(pagerank.name());
waitUntilTaskCompleted(task);
Utils.assertResponseError(404, () -> {
schema.getPropertyKey(pagerank.name());
});
}
Aggregations