Search in sources :

Example 81 with PropertyKey

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;
}
Also used : ConditionQuery(com.baidu.hugegraph.backend.query.ConditionQuery) VertexLabel(com.baidu.hugegraph.schema.VertexLabel) PropertyKey(com.baidu.hugegraph.schema.PropertyKey)

Example 82 with PropertyKey

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

Example 83 with 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()));
    }
}
Also used : PropertyKey(com.baidu.hugegraph.schema.PropertyKey)

Example 84 with PropertyKey

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

Example 85 with PropertyKey

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

Aggregations

PropertyKey (com.baidu.hugegraph.schema.PropertyKey)94 Id (com.baidu.hugegraph.backend.id.Id)31 Test (org.junit.Test)24 VertexLabel (com.baidu.hugegraph.schema.VertexLabel)20 SchemaManager (com.baidu.hugegraph.schema.SchemaManager)15 HugeGraph (com.baidu.hugegraph.HugeGraph)13 EdgeLabel (com.baidu.hugegraph.schema.EdgeLabel)11 EdgeId (com.baidu.hugegraph.backend.id.EdgeId)9 HugeVertex (com.baidu.hugegraph.structure.HugeVertex)9 BaseUnitTest (com.baidu.hugegraph.unit.BaseUnitTest)9 ConditionQuery (com.baidu.hugegraph.backend.query.ConditionQuery)7 FakeObjects (com.baidu.hugegraph.unit.FakeObjects)7 Watched (com.baidu.hugegraph.perf.PerfUtil.Watched)6 HugeEdge (com.baidu.hugegraph.structure.HugeEdge)6 DataType (com.baidu.hugegraph.type.define.DataType)6 Map (java.util.Map)6 IndexLabel (com.baidu.hugegraph.schema.IndexLabel)5 Timed (com.codahale.metrics.annotation.Timed)5 RolesAllowed (jakarta.annotation.security.RolesAllowed)5 Collection (java.util.Collection)5