use of com.baidu.hugegraph.structure.schema.PropertyKey in project incubator-hugegraph-toolchain by apache.
the class PropertyKeyApiTest method testClearOlapPropertyKey.
@Test
public void testClearOlapPropertyKey() {
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());
propertyKeyWithTask = propertyKeyAPI.clear(pagerank);
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());
pagerank = propertyKeyAPI.get("pagerank");
Assert.assertEquals("pagerank", pagerank.name());
Assert.assertEquals(WriteType.OLAP_RANGE, pagerank.writeType());
Assert.assertEquals(DataType.DOUBLE, pagerank.dataType());
}
use of com.baidu.hugegraph.structure.schema.PropertyKey in project incubator-hugegraph-toolchain by apache.
the class PropertyKeyApiTest method testCreateWithAggregateType.
@Test
public void testCreateWithAggregateType() {
PropertyKey propertyKey = schema().propertyKey("name").asText().valueSingle().build();
PropertyKey.PropertyKeyWithTask propertyKeyWithTask;
propertyKeyWithTask = propertyKeyAPI.create(propertyKey);
Assert.assertEquals(0L, propertyKeyWithTask.taskId());
propertyKey = propertyKeyWithTask.propertyKey();
Assert.assertEquals("name", propertyKey.name());
Assert.assertEquals(DataType.TEXT, propertyKey.dataType());
Assert.assertEquals(Cardinality.SINGLE, propertyKey.cardinality());
Assert.assertEquals(AggregateType.NONE, propertyKey.aggregateType());
Assert.assertTrue(propertyKey.aggregateType().isNone());
Assert.assertFalse(propertyKey.aggregateType().isNumber());
Assert.assertTrue(propertyKey.aggregateType().isIndexable());
propertyKey = schema().propertyKey("no").asText().valueSingle().calcOld().build();
propertyKeyWithTask = propertyKeyAPI.create(propertyKey);
Assert.assertEquals(0L, propertyKeyWithTask.taskId());
propertyKey = propertyKeyWithTask.propertyKey();
Assert.assertEquals("no", propertyKey.name());
Assert.assertEquals(DataType.TEXT, propertyKey.dataType());
Assert.assertEquals(Cardinality.SINGLE, propertyKey.cardinality());
Assert.assertEquals(AggregateType.OLD, propertyKey.aggregateType());
Assert.assertTrue(propertyKey.aggregateType().isOld());
Assert.assertTrue(propertyKey.aggregateType().isIndexable());
Assert.assertFalse(propertyKey.aggregateType().isNumber());
propertyKey = schema().propertyKey("max").asInt().valueSingle().calcMax().build();
propertyKeyWithTask = propertyKeyAPI.create(propertyKey);
Assert.assertEquals(0L, propertyKeyWithTask.taskId());
propertyKey = propertyKeyWithTask.propertyKey();
Assert.assertEquals("max", propertyKey.name());
Assert.assertEquals(DataType.INT, propertyKey.dataType());
Assert.assertEquals(Cardinality.SINGLE, propertyKey.cardinality());
Assert.assertEquals(AggregateType.MAX, propertyKey.aggregateType());
Assert.assertTrue(propertyKey.aggregateType().isMax());
Assert.assertTrue(propertyKey.aggregateType().isIndexable());
Assert.assertTrue(propertyKey.aggregateType().isNumber());
propertyKey = schema().propertyKey("min").asInt().valueSingle().calcMin().build();
propertyKeyWithTask = propertyKeyAPI.create(propertyKey);
Assert.assertEquals(0L, propertyKeyWithTask.taskId());
propertyKey = propertyKeyWithTask.propertyKey();
Assert.assertEquals("min", propertyKey.name());
Assert.assertEquals(DataType.INT, propertyKey.dataType());
Assert.assertEquals(Cardinality.SINGLE, propertyKey.cardinality());
Assert.assertEquals(AggregateType.MIN, propertyKey.aggregateType());
Assert.assertTrue(propertyKey.aggregateType().isMin());
Assert.assertTrue(propertyKey.aggregateType().isIndexable());
Assert.assertTrue(propertyKey.aggregateType().isNumber());
propertyKey = schema().propertyKey("sum").asInt().valueSingle().calcSum().build();
propertyKeyWithTask = propertyKeyAPI.create(propertyKey);
Assert.assertEquals(0L, propertyKeyWithTask.taskId());
propertyKey = propertyKeyWithTask.propertyKey();
Assert.assertEquals("sum", propertyKey.name());
Assert.assertEquals(DataType.INT, propertyKey.dataType());
Assert.assertEquals(Cardinality.SINGLE, propertyKey.cardinality());
Assert.assertEquals(AggregateType.SUM, propertyKey.aggregateType());
Assert.assertTrue(propertyKey.aggregateType().isSum());
Assert.assertFalse(propertyKey.aggregateType().isIndexable());
Assert.assertTrue(propertyKey.aggregateType().isNumber());
propertyKey = schema().propertyKey("total").asInt().valueSingle().aggregateType(AggregateType.SUM).build();
propertyKeyWithTask = propertyKeyAPI.create(propertyKey);
Assert.assertEquals(0L, propertyKeyWithTask.taskId());
propertyKey = propertyKeyWithTask.propertyKey();
Assert.assertEquals("total", propertyKey.name());
Assert.assertEquals(DataType.INT, propertyKey.dataType());
Assert.assertEquals(Cardinality.SINGLE, propertyKey.cardinality());
Assert.assertEquals(AggregateType.SUM, propertyKey.aggregateType());
Assert.assertTrue(propertyKey.aggregateType().isSum());
Assert.assertFalse(propertyKey.aggregateType().isIndexable());
Assert.assertTrue(propertyKey.aggregateType().isNumber());
propertyKey = schema().propertyKey("nameV46").asText().valueSingle().build();
PropertyKey.PropertyKeyV46 pk = propertyKey.switchV46();
Assert.assertEquals("nameV46", pk.name());
Assert.assertEquals(DataType.TEXT, pk.dataType());
Assert.assertEquals(Cardinality.SINGLE, pk.cardinality());
propertyKey = schema().propertyKey("nameV58").asText().valueSingle().calcOld().build();
PropertyKey.PropertyKeyV58 pk1 = propertyKey.switchV58();
Assert.assertEquals("nameV58", pk1.name());
Assert.assertEquals(DataType.TEXT, pk1.dataType());
Assert.assertEquals(Cardinality.SINGLE, pk1.cardinality());
Assert.assertEquals(AggregateType.OLD, pk1.aggregateType());
}
use of com.baidu.hugegraph.structure.schema.PropertyKey in project incubator-hugegraph-toolchain by apache.
the class PropertyKeyApiTest method testListByNames.
@Test
public void testListByNames() {
PropertyKey name = schema().propertyKey("name").asText().build();
PropertyKey.PropertyKeyWithTask propertyKeyWithTask;
propertyKeyWithTask = propertyKeyAPI.create(name);
Assert.assertEquals(0L, propertyKeyWithTask.taskId());
name = propertyKeyWithTask.propertyKey();
PropertyKey age = schema().propertyKey("age").asInt().build();
propertyKeyWithTask = propertyKeyAPI.create(age);
Assert.assertEquals(0L, propertyKeyWithTask.taskId());
age = propertyKeyWithTask.propertyKey();
List<PropertyKey> propertyKeys;
propertyKeys = propertyKeyAPI.list(ImmutableList.of("name"));
Assert.assertEquals(1, propertyKeys.size());
assertContains(propertyKeys, name);
propertyKeys = propertyKeyAPI.list(ImmutableList.of("age"));
Assert.assertEquals(1, propertyKeys.size());
assertContains(propertyKeys, age);
propertyKeys = propertyKeyAPI.list(ImmutableList.of("name", "age"));
Assert.assertEquals(2, propertyKeys.size());
assertContains(propertyKeys, name);
assertContains(propertyKeys, age);
}
use of com.baidu.hugegraph.structure.schema.PropertyKey in project incubator-hugegraph-toolchain by apache.
the class PropertyKeyApiTest method testCreate.
@Test
public void testCreate() {
PropertyKey propertyKey = schema().propertyKey("name").asText().valueSingle().build();
PropertyKey.PropertyKeyWithTask propertyKeyWithTask;
propertyKeyWithTask = propertyKeyAPI.create(propertyKey);
Assert.assertEquals(0L, propertyKeyWithTask.taskId());
propertyKey = propertyKeyWithTask.propertyKey();
Assert.assertEquals("name", propertyKey.name());
Assert.assertEquals(DataType.TEXT, propertyKey.dataType());
Assert.assertEquals(Cardinality.SINGLE, propertyKey.cardinality());
}
use of com.baidu.hugegraph.structure.schema.PropertyKey in project incubator-hugegraph-toolchain by apache.
the class PropertyKeyApiTest method testCreateWithCardinality.
@Test
public void testCreateWithCardinality() {
PropertyKey propertyKey = schema().propertyKey("name").asText().cardinality(Cardinality.SET).build();
PropertyKey.PropertyKeyWithTask propertyKeyWithTask;
propertyKeyWithTask = propertyKeyAPI.create(propertyKey);
Assert.assertEquals(0L, propertyKeyWithTask.taskId());
propertyKey = propertyKeyWithTask.propertyKey();
Assert.assertEquals("name", propertyKey.name());
Assert.assertEquals(DataType.TEXT, propertyKey.dataType());
Assert.assertEquals(Cardinality.SET, propertyKey.cardinality());
}
Aggregations