Search in sources :

Example 16 with PropertyKey

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

the class OlapPropertyKeyCreateJob method execute.

@Override
public Object execute() {
    SchemaTransaction schemaTx = this.params().schemaTransaction();
    PropertyKey propertyKey = schemaTx.getPropertyKey(this.schemaId());
    // Create olap index label schema
    schemaTx.createIndexLabelForOlapPk(propertyKey);
    // Create olap data table
    this.params().graphTransaction().createOlapPk(propertyKey.id());
    return null;
}
Also used : SchemaTransaction(com.baidu.hugegraph.backend.tx.SchemaTransaction) PropertyKey(com.baidu.hugegraph.schema.PropertyKey)

Example 17 with PropertyKey

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

the class EdgeLabelBuilder method append.

@Override
public EdgeLabel append() {
    EdgeLabel edgeLabel = this.edgeLabelOrNull(this.name);
    if (edgeLabel == null) {
        throw new NotFoundException("Can't update edge label '%s' " + "since it doesn't exist", this.name);
    }
    // These methods will check params and fill to member variables
    this.checkStableVars();
    this.checkProperties(Action.APPEND);
    this.checkNullableKeys(Action.APPEND);
    Userdata.check(this.userdata, Action.APPEND);
    for (String key : this.properties) {
        PropertyKey propertyKey = this.graph().propertyKey(key);
        edgeLabel.property(propertyKey.id());
    }
    for (String key : this.nullableKeys) {
        PropertyKey propertyKey = this.graph().propertyKey(key);
        edgeLabel.nullableKey(propertyKey.id());
    }
    edgeLabel.userdata(this.userdata);
    this.graph().addEdgeLabel(edgeLabel);
    return edgeLabel;
}
Also used : EdgeLabel(com.baidu.hugegraph.schema.EdgeLabel) NotFoundException(com.baidu.hugegraph.exception.NotFoundException) PropertyKey(com.baidu.hugegraph.schema.PropertyKey)

Example 18 with PropertyKey

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

the class VertexCoreTest method testQueryFilterByPropName.

@Test
public void testQueryFilterByPropName() {
    HugeGraph graph = graph();
    Assume.assumeTrue("Not support CONTAINS_KEY query", storeFeatures().supportsQueryWithContainsKey());
    init10Vertices();
    VertexLabel language = graph.vertexLabel("language");
    PropertyKey dynamic = graph.propertyKey("dynamic");
    // Query vertex by condition (does contain the property name?)
    ConditionQuery q = new ConditionQuery(HugeType.VERTEX);
    q.eq(HugeKeys.LABEL, language.id());
    q.key(HugeKeys.PROPERTIES, dynamic.id());
    List<Vertex> vertices = ImmutableList.copyOf(graph.vertices(q));
    Assert.assertEquals(1, vertices.size());
    assertContains(vertices, T.label, "language", "name", "python", "dynamic", true);
    // Query vertex by condition (does contain the property name?)
    q = new ConditionQuery(HugeType.VERTEX);
    q.key(HugeKeys.PROPERTIES, dynamic.id());
    vertices = ImmutableList.copyOf(graph.vertices(q));
    Assert.assertEquals(1, vertices.size());
    assertContains(vertices, T.label, "language", "name", "python", "dynamic", true);
}
Also used : FakeVertex(com.baidu.hugegraph.testutil.FakeObjects.FakeVertex) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) HugeGraph(com.baidu.hugegraph.HugeGraph) ConditionQuery(com.baidu.hugegraph.backend.query.ConditionQuery) VertexLabel(com.baidu.hugegraph.schema.VertexLabel) PropertyKey(com.baidu.hugegraph.schema.PropertyKey) Test(org.junit.Test)

Example 19 with PropertyKey

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

the class HugeGraphAuthProxy method removePropertyKey.

@Override
public Id removePropertyKey(Id key) {
    PropertyKey pkey = this.hugegraph.propertyKey(key);
    verifySchemaPermission(HugePermission.DELETE, pkey);
    return this.hugegraph.removePropertyKey(key);
}
Also used : PropertyKey(com.baidu.hugegraph.schema.PropertyKey)

Example 20 with PropertyKey

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

the class CassandraSerializer method writeProperty.

@Override
protected Object writeProperty(PropertyKey propertyKey, Object value) {
    BytesBuffer buffer = BytesBuffer.allocate(BytesBuffer.BUF_PROPERTY);
    if (propertyKey == null) {
        /*
             * Since we can't know the type of the property value in some
             * scenarios so need to construct a fake property key to
             * serialize to reuse code.
             */
        propertyKey = new PropertyKey(null, IdGenerator.of(0L), "fake");
        propertyKey.dataType(DataType.fromClass(value.getClass()));
    }
    buffer.writeProperty(propertyKey, value);
    buffer.forReadWritten();
    return buffer.asByteBuffer();
}
Also used : BytesBuffer(com.baidu.hugegraph.backend.serializer.BytesBuffer) PropertyKey(com.baidu.hugegraph.schema.PropertyKey)

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