Search in sources :

Example 31 with PropertyKey

use of com.baidu.hugegraph.structure.schema.PropertyKey in project incubator-hugegraph-toolchain by apache.

the class PropertyKeyApiTest method testAddOlapPropertyKey.

@Test
public void testAddOlapPropertyKey() {
    PropertyKey pagerank = schema().propertyKey("pagerank").asDouble().writeType(WriteType.OLAP_RANGE).build();
    PropertyKey.PropertyKeyWithTask propertyKeyWithTask;
    propertyKeyWithTask = propertyKeyAPI.create(pagerank);
    long taskId = propertyKeyWithTask.taskId();
    Assert.assertNotEquals(0L, taskId);
    waitUntilTaskCompleted(taskId);
    pagerank = propertyKeyWithTask.propertyKey();
    Assert.assertEquals("pagerank", pagerank.name());
    Assert.assertEquals(WriteType.OLAP_RANGE, pagerank.writeType());
    Assert.assertEquals(DataType.DOUBLE, pagerank.dataType());
    PropertyKey wcc = schema().propertyKey("wcc").asText().writeType(WriteType.OLAP_SECONDARY).build();
    propertyKeyWithTask = propertyKeyAPI.create(wcc);
    taskId = propertyKeyWithTask.taskId();
    Assert.assertNotEquals(0L, taskId);
    waitUntilTaskCompleted(taskId);
    wcc = propertyKeyWithTask.propertyKey();
    Assert.assertEquals("wcc", wcc.name());
    Assert.assertEquals(WriteType.OLAP_SECONDARY, wcc.writeType());
    Assert.assertEquals(DataType.TEXT, wcc.dataType());
    PropertyKey none = schema().propertyKey("none").asText().writeType(WriteType.OLAP_COMMON).build();
    propertyKeyWithTask = propertyKeyAPI.create(none);
    taskId = propertyKeyWithTask.taskId();
    Assert.assertNotEquals(0L, taskId);
    waitUntilTaskCompleted(taskId);
    none = propertyKeyWithTask.propertyKey();
    Assert.assertEquals("none", none.name());
    Assert.assertEquals(WriteType.OLAP_COMMON, none.writeType());
    Assert.assertEquals(DataType.TEXT, none.dataType());
}
Also used : PropertyKey(com.baidu.hugegraph.structure.schema.PropertyKey) Test(org.junit.Test)

Example 32 with PropertyKey

use of com.baidu.hugegraph.structure.schema.PropertyKey in project incubator-hugegraph-toolchain by apache.

the class PropertyKeyApiTest method testDeleteOlapPropertyKey.

@Test
public void testDeleteOlapPropertyKey() {
    PropertyKey pagerank = schema().propertyKey("pagerank").asDouble().writeType(WriteType.OLAP_RANGE).build();
    PropertyKey.PropertyKeyWithTask propertyKeyWithTask;
    propertyKeyWithTask = propertyKeyAPI.create(pagerank);
    long taskId = propertyKeyWithTask.taskId();
    Assert.assertNotEquals(0L, taskId);
    waitUntilTaskCompleted(taskId);
    pagerank = propertyKeyWithTask.propertyKey();
    Assert.assertEquals("pagerank", pagerank.name());
    Assert.assertEquals(WriteType.OLAP_RANGE, pagerank.writeType());
    Assert.assertEquals(DataType.DOUBLE, pagerank.dataType());
    taskId = propertyKeyAPI.delete(pagerank.name());
    Assert.assertNotEquals(0L, taskId);
    waitUntilTaskCompleted(taskId);
    pagerank = propertyKeyWithTask.propertyKey();
    Assert.assertEquals("pagerank", pagerank.name());
    Assert.assertEquals(WriteType.OLAP_RANGE, pagerank.writeType());
    Assert.assertEquals(DataType.DOUBLE, pagerank.dataType());
    Utils.assertResponseError(404, () -> {
        propertyKeyAPI.get("pagerank");
    });
}
Also used : PropertyKey(com.baidu.hugegraph.structure.schema.PropertyKey) Test(org.junit.Test)

Example 33 with PropertyKey

use of com.baidu.hugegraph.structure.schema.PropertyKey in project incubator-hugegraph-toolchain by apache.

the class PropertyKeyApiTest method testGet.

@Test
public void testGet() {
    PropertyKey propertyKey1 = schema().propertyKey("name").asText().valueSingle().build();
    PropertyKey.PropertyKeyWithTask propertyKeyWithTask;
    propertyKeyWithTask = propertyKeyAPI.create(propertyKey1);
    Assert.assertEquals(0L, propertyKeyWithTask.taskId());
    propertyKey1 = propertyKeyWithTask.propertyKey();
    PropertyKey propertyKey2 = propertyKeyAPI.get("name");
    Assert.assertEquals(propertyKey1.name(), propertyKey2.name());
    Assert.assertEquals(propertyKey1.dataType(), propertyKey2.dataType());
    Assert.assertEquals(propertyKey1.cardinality(), propertyKey2.cardinality());
}
Also used : PropertyKey(com.baidu.hugegraph.structure.schema.PropertyKey) Test(org.junit.Test)

Example 34 with PropertyKey

use of com.baidu.hugegraph.structure.schema.PropertyKey in project incubator-hugegraph-toolchain by apache.

the class PropertyKeyApiTest method testDelete.

@Test
public void testDelete() {
    PropertyKey propertyKey = schema().propertyKey("name").asText().valueSingle().build();
    propertyKeyAPI.create(propertyKey);
    propertyKeyAPI.delete("name");
    Utils.assertResponseError(404, () -> {
        propertyKeyAPI.get("name");
    });
}
Also used : PropertyKey(com.baidu.hugegraph.structure.schema.PropertyKey) Test(org.junit.Test)

Example 35 with PropertyKey

use of com.baidu.hugegraph.structure.schema.PropertyKey in project incubator-hugegraph-toolchain by apache.

the class PropertyKeyApiTest method testList.

@Test
public void testList() {
    PropertyKey propertyKey1 = schema().propertyKey("name").asText().valueSingle().build();
    PropertyKey.PropertyKeyWithTask propertyKeyWithTask;
    propertyKeyWithTask = propertyKeyAPI.create(propertyKey1);
    Assert.assertEquals(0L, propertyKeyWithTask.taskId());
    propertyKey1 = propertyKeyWithTask.propertyKey();
    PropertyKey propertyKey2 = schema().propertyKey("age").asInt().valueSingle().build();
    propertyKeyWithTask = propertyKeyAPI.create(propertyKey2);
    Assert.assertEquals(0L, propertyKeyWithTask.taskId());
    propertyKey2 = propertyKeyWithTask.propertyKey();
    List<PropertyKey> propertyKeys = propertyKeyAPI.list();
    Assert.assertEquals(2, propertyKeys.size());
    assertContains(propertyKeys, propertyKey1);
    assertContains(propertyKeys, propertyKey2);
}
Also used : PropertyKey(com.baidu.hugegraph.structure.schema.PropertyKey) Test(org.junit.Test)

Aggregations

PropertyKey (com.baidu.hugegraph.structure.schema.PropertyKey)40 Test (org.junit.Test)27 SchemaManager (com.baidu.hugegraph.driver.SchemaManager)7 HugeClient (com.baidu.hugegraph.driver.HugeClient)6 RestResult (com.baidu.hugegraph.rest.RestResult)6 ExternalException (com.baidu.hugegraph.exception.ExternalException)4 Date (java.util.Date)4 ServerException (com.baidu.hugegraph.exception.ServerException)3 PropertyKeyEntity (com.baidu.hugegraph.entity.schema.PropertyKeyEntity)2 Vertex (com.baidu.hugegraph.structure.graph.Vertex)2 IndexLabel (com.baidu.hugegraph.structure.schema.IndexLabel)2 VertexLabel (com.baidu.hugegraph.structure.schema.VertexLabel)2 GremlinRequest (com.baidu.hugegraph.api.gremlin.GremlinRequest)1 NotSupportException (com.baidu.hugegraph.exception.NotSupportException)1 InputSource (com.baidu.hugegraph.loader.source.InputSource)1 FileSource (com.baidu.hugegraph.loader.source.file.FileSource)1 ListFormat (com.baidu.hugegraph.loader.source.file.ListFormat)1 Edge (com.baidu.hugegraph.structure.graph.Edge)1 ResultSet (com.baidu.hugegraph.structure.gremlin.ResultSet)1 EdgeLabel (com.baidu.hugegraph.structure.schema.EdgeLabel)1