Search in sources :

Example 6 with DataType

use of com.baidu.hugegraph.type.define.DataType 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 7 with DataType

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

the class IndexLabelBuilder method allStringIndex.

private boolean allStringIndex(List<?> fields) {
    for (Object field : fields) {
        PropertyKey pk = field instanceof Id ? this.graph().propertyKey((Id) field) : this.graph().propertyKey((String) field);
        DataType dataType = pk.dataType();
        if (dataType.isNumber() || dataType.isDate()) {
            return false;
        }
    }
    return true;
}
Also used : DataType(com.baidu.hugegraph.type.define.DataType) Id(com.baidu.hugegraph.backend.id.Id) PropertyKey(com.baidu.hugegraph.schema.PropertyKey)

Aggregations

DataType (com.baidu.hugegraph.type.define.DataType)7 PropertyKey (com.baidu.hugegraph.schema.PropertyKey)6 Id (com.baidu.hugegraph.backend.id.Id)4 AggregateType (com.baidu.hugegraph.type.define.AggregateType)2 Cardinality (com.baidu.hugegraph.type.define.Cardinality)2 SchemaStatus (com.baidu.hugegraph.type.define.SchemaStatus)2 WriteType (com.baidu.hugegraph.type.define.WriteType)2 EdgeId (com.baidu.hugegraph.backend.id.EdgeId)1 BytesBuffer (com.baidu.hugegraph.backend.serializer.BytesBuffer)1 IndexLabel (com.baidu.hugegraph.schema.IndexLabel)1 IdSet (com.baidu.hugegraph.util.collection.IdSet)1