use of com.baidu.hugegraph.type.define.HugeKeys in project incubator-hugegraph by apache.
the class TraversalUtil method convIn2Relation.
public static Condition convIn2Relation(HugeGraph graph, HugeType type, HasContainer has) {
BiPredicate<?, ?> bp = has.getPredicate().getBiPredicate();
assert bp instanceof Contains;
Collection<?> values = (Collection<?>) has.getValue();
String originKey = has.getKey();
if (values.size() > 1) {
E.checkArgument(!originKey.equals(T.key.getAccessor()) && !originKey.equals(T.value.getAccessor()), "Not support hasKey() or hasValue() with " + "multiple values");
}
HugeKeys hugeKey = token2HugeKey(originKey);
List<?> valueList;
if (hugeKey != null) {
valueList = convSysListValueIfNeeded(graph, type, hugeKey, values);
switch((Contains) bp) {
case within:
return Condition.in(hugeKey, valueList);
case without:
return Condition.nin(hugeKey, valueList);
default:
throw newUnsupportedPredicate(has.getPredicate());
}
} else {
valueList = new ArrayList<>(values);
String key = has.getKey();
PropertyKey pkey = graph.propertyKey(key);
switch((Contains) bp) {
case within:
return Condition.in(pkey.id(), valueList);
case without:
return Condition.nin(pkey.id(), valueList);
default:
throw newUnsupportedPredicate(has.getPredicate());
}
}
}
use of com.baidu.hugegraph.type.define.HugeKeys in project incubator-hugegraph by apache.
the class GraphTransaction method verifyEdgesConditionQuery.
private static void verifyEdgesConditionQuery(ConditionQuery query) {
assert query.resultType().isEdge();
int total = query.conditionsSize();
if (total == 1) {
/*
* Supported query:
* 1.query just by edge label
* 2.query just by PROPERTIES (like containsKey,containsValue)
* 3.query with scan
*/
if (query.containsCondition(HugeKeys.LABEL) || query.containsCondition(HugeKeys.PROPERTIES) || query.containsScanRelation()) {
return;
}
}
int matched = 0;
for (HugeKeys key : EdgeId.KEYS) {
Object value = query.condition(key);
if (value == null) {
break;
}
matched++;
}
int count = matched;
if (query.containsCondition(HugeKeys.PROPERTIES)) {
matched++;
if (count < 3 && query.containsCondition(HugeKeys.LABEL)) {
matched++;
}
}
if (matched != total) {
throw new HugeException("Not supported querying edges by %s, expect %s", query.conditions(), EdgeId.KEYS[count]);
}
}
use of com.baidu.hugegraph.type.define.HugeKeys in project incubator-hugegraph by apache.
the class GraphSONSchemaSerializer method writeIndexLabel.
public Map<HugeKeys, Object> writeIndexLabel(IndexLabel indexLabel) {
HugeGraph graph = indexLabel.graph();
assert graph != null;
Map<HugeKeys, Object> map = new LinkedHashMap<>();
map.put(HugeKeys.ID, indexLabel.id().asLong());
map.put(HugeKeys.NAME, indexLabel.name());
map.put(HugeKeys.BASE_TYPE, indexLabel.baseType());
if (indexLabel.baseType() == HugeType.VERTEX_LABEL) {
map.put(HugeKeys.BASE_VALUE, graph.vertexLabel(indexLabel.baseValue()).name());
} else {
assert indexLabel.baseType() == HugeType.EDGE_LABEL;
map.put(HugeKeys.BASE_VALUE, graph.edgeLabel(indexLabel.baseValue()).name());
}
map.put(HugeKeys.INDEX_TYPE, indexLabel.indexType());
map.put(HugeKeys.FIELDS, graph.mapPkId2Name(indexLabel.indexFields()));
map.put(HugeKeys.STATUS, indexLabel.status());
map.put(HugeKeys.USER_DATA, indexLabel.userdata());
return map;
}
use of com.baidu.hugegraph.type.define.HugeKeys in project incubator-hugegraph by apache.
the class HugeGryoModule method readEntry.
@SuppressWarnings("unused")
private static Map<HugeKeys, Object> readEntry(Kryo kryo, Input input) {
int columnSize = input.readInt();
Map<HugeKeys, Object> map = new LinkedHashMap<>();
for (int i = 0; i < columnSize; i++) {
HugeKeys key = kryo.readObject(input, HugeKeys.class);
Object val = kryo.readClassAndObject(input);
map.put(key, val);
}
return map;
}
use of com.baidu.hugegraph.type.define.HugeKeys in project incubator-hugegraph by apache.
the class CassandraTable method row2Entry.
protected static CassandraBackendEntry row2Entry(HugeType type, Row row) {
CassandraBackendEntry entry = new CassandraBackendEntry(type);
List<Definition> cols = row.getColumnDefinitions().asList();
for (Definition col : cols) {
String name = col.getName();
HugeKeys key = CassandraTable.parseKey(name);
Object value = row.getObject(name);
if (value == null) {
assert key == HugeKeys.EXPIRED_TIME;
continue;
}
entry.column(key, value);
}
return entry;
}
Aggregations