Search in sources :

Example 1 with WriteType

use of com.baidu.hugegraph.type.define.WriteType in project incubator-hugegraph by apache.

the class TableSerializer method readPropertyKey.

@Override
public PropertyKey readPropertyKey(HugeGraph graph, BackendEntry backendEntry) {
    if (backendEntry == null) {
        return null;
    }
    TableBackendEntry entry = this.convertEntry(backendEntry);
    Number id = schemaColumn(entry, HugeKeys.ID);
    String name = schemaColumn(entry, HugeKeys.NAME);
    DataType dataType = schemaEnum(entry, HugeKeys.DATA_TYPE, DataType.class);
    Cardinality cardinality = schemaEnum(entry, HugeKeys.CARDINALITY, Cardinality.class);
    AggregateType aggregateType = schemaEnum(entry, HugeKeys.AGGREGATE_TYPE, AggregateType.class);
    WriteType writeType = schemaEnumOrDefault(entry, HugeKeys.WRITE_TYPE, WriteType.class, WriteType.OLTP);
    Object properties = schemaColumn(entry, HugeKeys.PROPERTIES);
    SchemaStatus status = schemaEnum(entry, HugeKeys.STATUS, SchemaStatus.class);
    PropertyKey propertyKey = new PropertyKey(graph, this.toId(id), name);
    propertyKey.dataType(dataType);
    propertyKey.cardinality(cardinality);
    propertyKey.aggregateType(aggregateType);
    propertyKey.writeType(writeType);
    propertyKey.properties(this.toIdArray(properties));
    propertyKey.status(status);
    this.readUserdata(propertyKey, entry);
    return propertyKey;
}
Also used : Cardinality(com.baidu.hugegraph.type.define.Cardinality) WriteType(com.baidu.hugegraph.type.define.WriteType) DataType(com.baidu.hugegraph.type.define.DataType) AggregateType(com.baidu.hugegraph.type.define.AggregateType) SchemaStatus(com.baidu.hugegraph.type.define.SchemaStatus) PropertyKey(com.baidu.hugegraph.schema.PropertyKey)

Example 2 with WriteType

use of com.baidu.hugegraph.type.define.WriteType in project incubator-hugegraph by apache.

the class TextSerializer method readPropertyKey.

@Override
public PropertyKey readPropertyKey(HugeGraph graph, BackendEntry backendEntry) {
    if (backendEntry == null) {
        return null;
    }
    TextBackendEntry entry = this.convertEntry(backendEntry);
    Id id = readId(entry.id());
    String name = JsonUtil.fromJson(entry.column(HugeKeys.NAME), String.class);
    String dataType = entry.column(HugeKeys.DATA_TYPE);
    String cardinality = entry.column(HugeKeys.CARDINALITY);
    String aggregateType = entry.column(HugeKeys.AGGREGATE_TYPE);
    String writeType = entry.column(HugeKeys.WRITE_TYPE);
    String properties = entry.column(HugeKeys.PROPERTIES);
    String status = entry.column(HugeKeys.STATUS);
    PropertyKey propertyKey = new PropertyKey(graph, id, name);
    propertyKey.dataType(JsonUtil.fromJson(dataType, DataType.class));
    propertyKey.cardinality(JsonUtil.fromJson(cardinality, Cardinality.class));
    propertyKey.aggregateType(JsonUtil.fromJson(aggregateType, AggregateType.class));
    propertyKey.writeType(JsonUtil.fromJson(writeType, WriteType.class));
    propertyKey.properties(readIds(properties));
    readUserdata(propertyKey, entry);
    propertyKey.status(JsonUtil.fromJson(status, SchemaStatus.class));
    return propertyKey;
}
Also used : Cardinality(com.baidu.hugegraph.type.define.Cardinality) WriteType(com.baidu.hugegraph.type.define.WriteType) DataType(com.baidu.hugegraph.type.define.DataType) Id(com.baidu.hugegraph.backend.id.Id) EdgeId(com.baidu.hugegraph.backend.id.EdgeId) AggregateType(com.baidu.hugegraph.type.define.AggregateType) SchemaStatus(com.baidu.hugegraph.type.define.SchemaStatus) PropertyKey(com.baidu.hugegraph.schema.PropertyKey)

Example 3 with WriteType

use of com.baidu.hugegraph.type.define.WriteType in project incubator-hugegraph by apache.

the class SchemaTransaction method createIndexLabelForOlapPk.

public void createIndexLabelForOlapPk(PropertyKey propertyKey) {
    WriteType writeType = propertyKey.writeType();
    if (writeType == WriteType.OLTP || writeType == WriteType.OLAP_COMMON) {
        return;
    }
    String indexName = VertexLabel.OLAP_VL.name() + "_by_" + propertyKey.name();
    IndexLabel.Builder builder = this.graph().schema().indexLabel(indexName).onV(VertexLabel.OLAP_VL.name()).by(propertyKey.name());
    if (propertyKey.writeType() == WriteType.OLAP_SECONDARY) {
        builder.secondary();
    } else {
        assert propertyKey.writeType() == WriteType.OLAP_RANGE;
        builder.range();
    }
    this.graph().addIndexLabel(VertexLabel.OLAP_VL, builder.build());
}
Also used : WriteType(com.baidu.hugegraph.type.define.WriteType) IndexLabel(com.baidu.hugegraph.schema.IndexLabel)

Aggregations

WriteType (com.baidu.hugegraph.type.define.WriteType)3 PropertyKey (com.baidu.hugegraph.schema.PropertyKey)2 AggregateType (com.baidu.hugegraph.type.define.AggregateType)2 Cardinality (com.baidu.hugegraph.type.define.Cardinality)2 DataType (com.baidu.hugegraph.type.define.DataType)2 SchemaStatus (com.baidu.hugegraph.type.define.SchemaStatus)2 EdgeId (com.baidu.hugegraph.backend.id.EdgeId)1 Id (com.baidu.hugegraph.backend.id.Id)1 IndexLabel (com.baidu.hugegraph.schema.IndexLabel)1