use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class HugeVariables method createVariableQuery.
private ConditionQuery createVariableQuery(String name) {
ConditionQuery query = new ConditionQuery(HugeType.VERTEX);
VertexLabel vl = this.variableVertexLabel();
query.eq(HugeKeys.LABEL, vl.id());
if (name != null) {
PropertyKey pkey = this.params.graph().propertyKey(Hidden.hide(VARIABLE_KEY));
query.query(Condition.eq(pkey.id(), name));
}
query.showHidden(true);
return query;
}
use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class HugeVariables method createPropertyKey.
private void createPropertyKey(String name, DataType dataType, Cardinality cardinality) {
SchemaManager schema = this.params.graph().schema();
PropertyKey propertyKey = schema.propertyKey(name).dataType(dataType).cardinality(cardinality).build();
this.params.schemaTransaction().addPropertyKey(propertyKey);
}
use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class SchemaCoreTest method assertContainsPk.
protected void assertContainsPk(Collection<Id> ids, String... keys) {
for (String key : keys) {
PropertyKey pkey = graph().propertyKey(key);
Assert.assertTrue(ids.contains(pkey.id()));
}
}
use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class PropertyKeyCoreTest method testRemoveOlapPropertyKey.
@Test
public void testRemoveOlapPropertyKey() {
Assume.assumeTrue("Not support olap properties", storeFeatures().supportsOlapProperties());
SchemaManager schema = graph().schema();
PropertyKey olap = schema.propertyKey("olap").asText().valueSingle().writeType(WriteType.OLAP_COMMON).ifNotExist().create();
Assert.assertEquals("olap", olap.name());
Assert.assertEquals(DataType.TEXT, olap.dataType());
Assert.assertEquals(Cardinality.SINGLE, olap.cardinality());
Assert.assertEquals(WriteType.OLAP_COMMON, olap.writeType());
schema.propertyKey("olap").remove();
Assert.assertThrows(NotFoundException.class, () -> {
schema.getPropertyKey("olap");
});
PropertyKey pagerank = schema.propertyKey("pagerank").asDouble().valueSingle().writeType(WriteType.OLAP_RANGE).ifNotExist().create();
Assert.assertEquals("pagerank", pagerank.name());
Assert.assertEquals(DataType.DOUBLE, pagerank.dataType());
Assert.assertEquals(Cardinality.SINGLE, pagerank.cardinality());
Assert.assertEquals(WriteType.OLAP_RANGE, pagerank.writeType());
schema.propertyKey("pagerank").remove();
Assert.assertThrows(NotFoundException.class, () -> {
schema.getPropertyKey("pagerank");
});
PropertyKey wcc = schema.propertyKey("wcc").asText().valueSingle().writeType(WriteType.OLAP_SECONDARY).ifNotExist().create();
Assert.assertEquals("wcc", wcc.name());
Assert.assertEquals(DataType.TEXT, wcc.dataType());
Assert.assertEquals(Cardinality.SINGLE, wcc.cardinality());
Assert.assertEquals(WriteType.OLAP_SECONDARY, wcc.writeType());
schema.propertyKey("wcc").remove();
Assert.assertThrows(NotFoundException.class, () -> {
schema.getPropertyKey("wcc");
});
}
use of com.baidu.hugegraph.schema.PropertyKey in project incubator-hugegraph by apache.
the class PropertyKeyCoreTest method testAddOlapPropertyKey.
@Test
public void testAddOlapPropertyKey() {
Assume.assumeTrue("Not support olap properties", storeFeatures().supportsOlapProperties());
SchemaManager schema = graph().schema();
PropertyKey olap = schema.propertyKey("olap").asText().valueSingle().writeType(WriteType.OLAP_COMMON).ifNotExist().create();
Assert.assertEquals("olap", olap.name());
Assert.assertEquals(DataType.TEXT, olap.dataType());
Assert.assertEquals(Cardinality.SINGLE, olap.cardinality());
Assert.assertEquals(WriteType.OLAP_COMMON, olap.writeType());
PropertyKey pagerank = schema.propertyKey("pagerank").asDouble().valueSingle().writeType(WriteType.OLAP_RANGE).ifNotExist().create();
Assert.assertEquals("pagerank", pagerank.name());
Assert.assertEquals(DataType.DOUBLE, pagerank.dataType());
Assert.assertEquals(Cardinality.SINGLE, pagerank.cardinality());
Assert.assertEquals(WriteType.OLAP_RANGE, pagerank.writeType());
PropertyKey wcc = schema.propertyKey("wcc").asText().valueSingle().writeType(WriteType.OLAP_SECONDARY).ifNotExist().create();
Assert.assertEquals("wcc", wcc.name());
Assert.assertEquals(DataType.TEXT, wcc.dataType());
Assert.assertEquals(Cardinality.SINGLE, wcc.cardinality());
Assert.assertEquals(WriteType.OLAP_SECONDARY, wcc.writeType());
}
Aggregations