use of com.baidu.hugegraph.structure.schema.IndexLabel in project incubator-hugegraph-toolchain by apache.
the class IndexLabelTest method testIndexLabelV56.
@Test
public void testIndexLabelV56() {
IndexLabel.Builder builder = new IndexLabel.BuilderImpl("personByAge", null);
IndexLabel indexLabel = builder.onV("person").secondary().by("age").build();
IndexLabel.IndexLabelV56 indexLabelV56 = indexLabel.switchV56();
String json = "{\"id\":0,\"name\":\"personByAge\"," + "\"check_exist\":true,\"user_data\":{}," + "\"base_type\":\"VERTEX_LABEL\",\"base_value\":\"person\"," + "\"index_type\":\"SECONDARY\",\"fields\":[\"age\"]}";
Assert.assertEquals(json, JsonUtil.toJson(indexLabelV56));
Assert.assertEquals(HugeType.INDEX_LABEL.string(), indexLabelV56.type());
Assert.assertThrows(NotSupportException.class, () -> {
indexLabelV56.rebuild();
});
}
use of com.baidu.hugegraph.structure.schema.IndexLabel 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.structure.schema.IndexLabel 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.structure.schema.IndexLabel 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.structure.schema.IndexLabel 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());
}
Aggregations