Search in sources :

Example 21 with HugeKeys

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

the class GraphSONSchemaSerializer method writeVertexLabel.

public Map<HugeKeys, Object> writeVertexLabel(VertexLabel vertexLabel) {
    HugeGraph graph = vertexLabel.graph();
    assert graph != null;
    Map<HugeKeys, Object> map = new LinkedHashMap<>();
    map.put(HugeKeys.ID, vertexLabel.id().asLong());
    map.put(HugeKeys.NAME, vertexLabel.name());
    map.put(HugeKeys.ID_STRATEGY, vertexLabel.idStrategy());
    map.put(HugeKeys.PRIMARY_KEYS, graph.mapPkId2Name(vertexLabel.primaryKeys()));
    map.put(HugeKeys.NULLABLE_KEYS, graph.mapPkId2Name(vertexLabel.nullableKeys()));
    map.put(HugeKeys.INDEX_LABELS, graph.mapIlId2Name(vertexLabel.indexLabels()));
    map.put(HugeKeys.PROPERTIES, graph.mapPkId2Name(vertexLabel.properties()));
    map.put(HugeKeys.STATUS, vertexLabel.status());
    map.put(HugeKeys.TTL, vertexLabel.ttl());
    String ttlStartTimeName = vertexLabel.ttlStartTimeName();
    if (ttlStartTimeName != null) {
        map.put(HugeKeys.TTL_START_TIME, ttlStartTimeName);
    }
    map.put(HugeKeys.ENABLE_LABEL_INDEX, vertexLabel.enableLabelIndex());
    map.put(HugeKeys.USER_DATA, vertexLabel.userdata());
    return map;
}
Also used : HugeGraph(com.baidu.hugegraph.HugeGraph) HugeKeys(com.baidu.hugegraph.type.define.HugeKeys) LinkedHashMap(java.util.LinkedHashMap)

Example 22 with HugeKeys

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

the class GraphSONSchemaSerializer method writeEdgeLabel.

public Map<HugeKeys, Object> writeEdgeLabel(EdgeLabel edgeLabel) {
    HugeGraph graph = edgeLabel.graph();
    assert graph != null;
    Map<HugeKeys, Object> map = new LinkedHashMap<>();
    map.put(HugeKeys.ID, edgeLabel.id().asLong());
    map.put(HugeKeys.NAME, edgeLabel.name());
    map.put(HugeKeys.SOURCE_LABEL, edgeLabel.sourceLabelName());
    map.put(HugeKeys.TARGET_LABEL, edgeLabel.targetLabelName());
    map.put(HugeKeys.FREQUENCY, edgeLabel.frequency());
    map.put(HugeKeys.SORT_KEYS, graph.mapPkId2Name(edgeLabel.sortKeys()));
    map.put(HugeKeys.NULLABLE_KEYS, graph.mapPkId2Name(edgeLabel.nullableKeys()));
    map.put(HugeKeys.INDEX_LABELS, graph.mapIlId2Name(edgeLabel.indexLabels()));
    map.put(HugeKeys.PROPERTIES, graph.mapPkId2Name(edgeLabel.properties()));
    map.put(HugeKeys.STATUS, edgeLabel.status());
    map.put(HugeKeys.TTL, edgeLabel.ttl());
    String ttlStartTimeName = edgeLabel.ttlStartTimeName();
    if (ttlStartTimeName != null) {
        map.put(HugeKeys.TTL_START_TIME, ttlStartTimeName);
    }
    map.put(HugeKeys.ENABLE_LABEL_INDEX, edgeLabel.enableLabelIndex());
    map.put(HugeKeys.USER_DATA, edgeLabel.userdata());
    return map;
}
Also used : HugeGraph(com.baidu.hugegraph.HugeGraph) HugeKeys(com.baidu.hugegraph.type.define.HugeKeys) LinkedHashMap(java.util.LinkedHashMap)

Example 23 with HugeKeys

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

the class GraphSONSchemaSerializer method writePropertyKey.

public Map<HugeKeys, Object> writePropertyKey(PropertyKey propertyKey) {
    HugeGraph graph = propertyKey.graph();
    assert graph != null;
    Map<HugeKeys, Object> map = new LinkedHashMap<>();
    map.put(HugeKeys.ID, propertyKey.id().asLong());
    map.put(HugeKeys.NAME, propertyKey.name());
    map.put(HugeKeys.DATA_TYPE, propertyKey.dataType());
    map.put(HugeKeys.CARDINALITY, propertyKey.cardinality());
    map.put(HugeKeys.AGGREGATE_TYPE, propertyKey.aggregateType());
    map.put(HugeKeys.WRITE_TYPE, propertyKey.writeType());
    map.put(HugeKeys.PROPERTIES, graph.mapPkId2Name(propertyKey.properties()));
    map.put(HugeKeys.STATUS, propertyKey.status());
    map.put(HugeKeys.USER_DATA, propertyKey.userdata());
    return map;
}
Also used : HugeGraph(com.baidu.hugegraph.HugeGraph) HugeKeys(com.baidu.hugegraph.type.define.HugeKeys) LinkedHashMap(java.util.LinkedHashMap)

Example 24 with HugeKeys

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

the class TraversalUtil method convContains2Relation.

public static Condition convContains2Relation(HugeGraph graph, HasContainer has) {
    // Convert contains-key or contains-value
    BiPredicate<?, ?> bp = has.getPredicate().getBiPredicate();
    E.checkArgument(bp == Compare.eq, "CONTAINS query with relation " + "'%s' is not supported", bp);
    HugeKeys key = token2HugeKey(has.getKey());
    E.checkNotNull(key, "token key");
    Object value = has.getValue();
    if (keyForContainsKey(has.getKey())) {
        if (value instanceof String) {
            value = graph.propertyKey((String) value).id();
        }
        return Condition.containsKey(key, value);
    } else {
        assert keyForContainsValue(has.getKey());
        return Condition.containsValue(key, value);
    }
}
Also used : HugeKeys(com.baidu.hugegraph.type.define.HugeKeys)

Example 25 with HugeKeys

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

the class MysqlEntryIterator method row2Entry.

private MysqlBackendEntry row2Entry(ResultSet result) throws SQLException {
    HugeType type = this.query.resultType();
    MysqlBackendEntry entry = new MysqlBackendEntry(type);
    ResultSetMetaData metaData = result.getMetaData();
    for (int i = 1; i <= metaData.getColumnCount(); i++) {
        String name = metaData.getColumnLabel(i);
        HugeKeys key = MysqlTable.parseKey(name);
        Object value = result.getObject(i);
        if (value == null) {
            assert key == HugeKeys.EXPIRED_TIME;
            continue;
        }
        entry.column(key, value);
    }
    return entry;
}
Also used : ResultSetMetaData(java.sql.ResultSetMetaData) HugeKeys(com.baidu.hugegraph.type.define.HugeKeys) HugeType(com.baidu.hugegraph.type.HugeType)

Aggregations

HugeKeys (com.baidu.hugegraph.type.define.HugeKeys)32 ArrayList (java.util.ArrayList)9 Map (java.util.Map)7 LinkedHashMap (java.util.LinkedHashMap)5 List (java.util.List)5 HugeGraph (com.baidu.hugegraph.HugeGraph)4 Id (com.baidu.hugegraph.backend.id.Id)4 ImmutableList (com.google.common.collect.ImmutableList)4 ImmutableMap (com.google.common.collect.ImmutableMap)4 BackendException (com.baidu.hugegraph.backend.BackendException)3 Condition (com.baidu.hugegraph.backend.query.Condition)3 SQLException (java.sql.SQLException)3 EdgeId (com.baidu.hugegraph.backend.id.EdgeId)2 ConditionQuery (com.baidu.hugegraph.backend.query.ConditionQuery)2 NotFoundException (com.baidu.hugegraph.exception.NotFoundException)2 Select (com.datastax.driver.core.querybuilder.Select)2 Update (com.datastax.driver.core.querybuilder.Update)2 HugeException (com.baidu.hugegraph.HugeException)1 Aggregate (com.baidu.hugegraph.backend.query.Aggregate)1 Relation (com.baidu.hugegraph.backend.query.Condition.Relation)1