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());
}
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");
});
}
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());
}
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");
});
}
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);
}
Aggregations