public Set<Object> userpropValues(Id field) { Set<Object> values = new HashSet<>(); for (Relation r : this.userpropRelations()) { if (r.key().equals(field)) { values.add(r.serialValue()); } } return values; }
protected StringBuilder relation2Sql(Condition.Relation relation) { String key = relation.serialKey().toString(); Object value = relation.serialValue();
/** * This method is only used for secondary index scenario, * its relation must be EQ * @param fields the user property fields * @return the corresponding user property serial values of fields */ public String userpropValuesString(List<Id> fields) { List<Object> values = new ArrayList<>(fields.size()); for (Id field : fields) { boolean got = false; for (Relation r : this.userpropRelations()) { if (r.key().equals(field) && !r.isSysprop()) { E.checkState(r.relation == RelationType.EQ, "Method userpropValues(List<String>) only " + "used for secondary index, " + "relation must be EQ, but got %s", r.relation()); values.add(r.serialValue()); got = true; } } if (!got) { throw new BackendException( "No such userprop named '%s' in the query '%s'", field, this); } } return SplicingIdGenerator.concatValues(values); }
protected StringBuilder relation2Sql(Condition.Relation relation) { String key = relation.serialKey().toString(); Object value = relation.serialValue();
protected Clause relation2Cql(Relation relation) { String key = relation.serialKey().toString(); Object value = relation.serialValue();
"Not support querying edge by %s", conditions); Condition.Relation relation = (Condition.Relation) cond; String label = (String) relation.serialValue();
@Override protected Query writeQueryCondition(Query query) { ConditionQuery result = (ConditionQuery) query; // No user-prop when serialize assert result.allSysprop(); for (Condition.Relation r : result.relations()) { // Serialize key if (query.resultType().isSchema()) { r.serialKey(((HugeKeys) r.key()).string()); } else { r.serialKey(formatSyspropName((HugeKeys) r.key())); } if (r.value() instanceof Id) { // Serialize id value r.serialValue(writeId((Id) r.value())); } else { // Serialize other type value r.serialValue(JsonUtil.toJson(r.value())); } if (r.relation() == Condition.RelationType.CONTAINS_KEY) { // Serialize has-key String key = (String) r.serialValue(); r.serialValue(formatPropertyName(key)); } } return result; }
private static boolean matchCondition(BackendEntry item, Condition c) { // TODO: Compatible with BackendEntry TextBackendEntry entry = (TextBackendEntry) item; // Not supported by memory if (!(c instanceof Condition.Relation)) { throw new BackendException("Unsupported condition: " + c); } Condition.Relation r = (Condition.Relation) c; String key = r.serialKey().toString(); // TODO: deal with others Relation like: <, >=, ... if (r.relation() == Condition.RelationType.CONTAINS_KEY) { return entry.contains(r.serialValue().toString()); } else if (r.relation() == Condition.RelationType.CONTAINS) { return entry.containsValue(r.serialValue().toString()); } else if (r.relation() == Condition.RelationType.EQ) { return entry.contains(key, r.serialValue().toString()); } else if (entry.contains(key)) { return r.test(entry.column(key)); } return false; } }
@Override protected Id writeQueryEdgeCondition(Query query) { ConditionQuery result = (ConditionQuery) query; for (Condition.Relation r : result.relations()) { Object value = r.value(); if (value instanceof Id) { if (r.key() == HugeKeys.OWNER_VERTEX || r.key() == HugeKeys.OTHER_VERTEX) { // Serialize vertex id r.serialValue(IdUtil.writeString((Id) value)); } else { // Serialize label id r.serialValue(((Id) value).asObject()); } } else if (value instanceof Directions) { r.serialValue(((Directions) value).code()); } } return null; }
@Override protected Query writeQueryCondition(Query query) { if (query.resultType().isGraph()) { ConditionQuery result = (ConditionQuery) query; // No user-prop when serialize assert result.allSysprop(); for (Condition.Relation r : result.relations()) { if (r.relation() == Condition.RelationType.CONTAINS) { r.serialValue(JsonUtil.toJson(r.value())); } } } return query; }
r.serialValue(pk.serialValue(r.value())); HugeKeys.SORT_VALUES, r.relation(), r.serialValue()); condition = condition.replace(r, sys); query.query(condition);
protected Clause relation2Cql(Relation relation) { String key = relation.serialKey().toString(); Object value = relation.serialValue();
E.checkState(relation.key().equals(HugeKeys.LABEL), "Not support querying edge by %s", conditions); String label = (String) relation.serialValue();
@Override protected Query writeQueryCondition(Query query) { ConditionQuery result = (ConditionQuery) query; // No user-prop when serialize assert result.allSysprop(); for (Condition.Relation r : result.relations()) { // Serialize key if (query.resultType().isSchema()) { r.serialKey(((HugeKeys) r.key()).string()); } else { r.serialKey(formatSyspropName((HugeKeys) r.key())); } if (r.value() instanceof Id) { // Serialize id value r.serialValue(writeId((Id) r.value())); } else { // Serialize other type value r.serialValue(JsonUtil.toJson(r.value())); } if (r.relation() == Condition.RelationType.CONTAINS_KEY) { // Serialize has-key String key = (String) r.serialValue(); r.serialValue(formatPropertyName(key)); } } return result; }
private static boolean matchCondition(BackendEntry item, Condition c) { // TODO: Compatible with BackendEntry TextBackendEntry entry = (TextBackendEntry) item; // Not supported by memory if (!(c instanceof Condition.Relation)) { throw new BackendException("Unsupported condition: " + c); } Condition.Relation r = (Condition.Relation) c; String key = r.serialKey().toString(); // TODO: deal with others Relation like: <, >=, ... if (r.relation() == Condition.RelationType.CONTAINS_KEY) { return entry.contains(r.serialValue().toString()); } else if (r.relation() == Condition.RelationType.CONTAINS) { return entry.containsValue(r.serialValue().toString()); } else if (r.relation() == Condition.RelationType.EQ) { return entry.contains(key, r.serialValue().toString()); } else if (entry.contains(key)) { return r.test(entry.column(key)); } return false; } }
@Override protected Query writeQueryEdgeCondition(Query query) { ConditionQuery result = (ConditionQuery) query; for (Condition.Relation r : result.relations()) { Object value = r.value(); if (value instanceof Id) { if (r.key() == HugeKeys.OWNER_VERTEX || r.key() == HugeKeys.OTHER_VERTEX) { // Serialize vertex id r.serialValue(IdUtil.writeString((Id) value)); } else { // Serialize label id r.serialValue(((Id) value).asObject()); } } else if (value instanceof Directions) { r.serialValue(((Directions) value).code()); } } return null; }
@Override protected Query writeQueryCondition(Query query) { if (query.resultType().isGraph()) { ConditionQuery result = (ConditionQuery) query; // No user-prop when serialize assert result.allSysprop(); for (Condition.Relation r : result.relations()) { if (r.relation() == Condition.RelationType.CONTAINS) { r.serialValue(JsonUtil.toJson(r.value())); } } } return query; }