Search in sources :

Example 36 with SchemaManager

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

Example 37 with SchemaManager

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

Example 38 with SchemaManager

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

Example 39 with SchemaManager

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

Example 40 with SchemaManager

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

Aggregations

SchemaManager (com.baidu.hugegraph.driver.SchemaManager)61 Test (org.junit.Test)39 Vertex (com.baidu.hugegraph.structure.graph.Vertex)18 Date (java.util.Date)14 GraphManager (com.baidu.hugegraph.driver.GraphManager)11 IndexLabel (com.baidu.hugegraph.structure.schema.IndexLabel)11 EdgeLabel (com.baidu.hugegraph.structure.schema.EdgeLabel)9 HugeClient (com.baidu.hugegraph.driver.HugeClient)8 BeforeClass (org.junit.BeforeClass)8 PropertyKey (com.baidu.hugegraph.structure.schema.PropertyKey)7 VertexLabel (com.baidu.hugegraph.structure.schema.VertexLabel)6 Edge (com.baidu.hugegraph.structure.graph.Edge)4 ArrayList (java.util.ArrayList)3 PropertyIndex (com.baidu.hugegraph.entity.schema.PropertyIndex)2 Task (com.baidu.hugegraph.structure.Task)2 Result (com.baidu.hugegraph.structure.gremlin.Result)2 ResultSet (com.baidu.hugegraph.structure.gremlin.ResultSet)2 BaseClientTest (com.baidu.hugegraph.BaseClientTest)1 GremlinManager (com.baidu.hugegraph.driver.GremlinManager)1 LoadOptions (com.baidu.hugegraph.loader.executor.LoadOptions)1