Search in sources :

Example 41 with IndexLabel

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();
    });
}
Also used : IndexLabel(com.baidu.hugegraph.structure.schema.IndexLabel) Test(org.junit.Test)

Example 42 with IndexLabel

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);
}
Also used : IndexLabel(com.baidu.hugegraph.structure.schema.IndexLabel) SchemaManager(com.baidu.hugegraph.driver.SchemaManager) Test(org.junit.Test)

Example 43 with IndexLabel

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());
}
Also used : IndexLabel(com.baidu.hugegraph.structure.schema.IndexLabel) SchemaManager(com.baidu.hugegraph.driver.SchemaManager) Test(org.junit.Test)

Example 44 with IndexLabel

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);
}
Also used : IndexLabel(com.baidu.hugegraph.structure.schema.IndexLabel) SchemaManager(com.baidu.hugegraph.driver.SchemaManager) Test(org.junit.Test)

Example 45 with IndexLabel

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());
}
Also used : IndexLabel(com.baidu.hugegraph.structure.schema.IndexLabel) SchemaManager(com.baidu.hugegraph.driver.SchemaManager) Test(org.junit.Test)

Aggregations

IndexLabel (com.baidu.hugegraph.structure.schema.IndexLabel)56 Test (org.junit.Test)34 HugeClient (com.baidu.hugegraph.driver.HugeClient)14 SchemaManager (com.baidu.hugegraph.driver.SchemaManager)11 ArrayList (java.util.ArrayList)10 ServerException (com.baidu.hugegraph.exception.ServerException)9 ExternalException (com.baidu.hugegraph.exception.ExternalException)8 Task (com.baidu.hugegraph.structure.Task)7 VertexLabel (com.baidu.hugegraph.structure.schema.VertexLabel)7 PropertyIndex (com.baidu.hugegraph.entity.schema.PropertyIndex)6 EdgeLabel (com.baidu.hugegraph.structure.schema.EdgeLabel)6 Date (java.util.Date)6 RestResult (com.baidu.hugegraph.rest.RestResult)4 HashSet (java.util.HashSet)4 SchemaType (com.baidu.hugegraph.entity.schema.SchemaType)2 PropertyKey (com.baidu.hugegraph.structure.schema.PropertyKey)2 TasksWithPage (com.baidu.hugegraph.api.task.TasksWithPage)1 Constant (com.baidu.hugegraph.common.Constant)1 ConflictDetail (com.baidu.hugegraph.entity.schema.ConflictDetail)1 ConflictStatus (com.baidu.hugegraph.entity.schema.ConflictStatus)1