public boolean containsScanCondition() { return this.containsCondition(Condition.RelationType.SCAN); }
protected static boolean isQueryByLabel(Query query) { Set<Condition> conditions = query.conditions(); if (query instanceof ConditionQuery && !conditions.isEmpty()) { ConditionQuery cq = (ConditionQuery) query; Id label = (Id) cq.condition(HugeKeys.LABEL); if (label != null && cq.allSysprop() && conditions.size() == 1 && cq.containsCondition(HugeKeys.LABEL, Condition.RelationType.EQ)) { return true; } } return false; }
@Watched(prefix = "index") @Override public Iterator<BackendEntry> query(Query query) { if (query instanceof ConditionQuery) { ConditionQuery q = (ConditionQuery) query; if (q.allSysprop() && q.conditions().size() == 1 && q.containsCondition(HugeKeys.NAME)) { return this.queryByName(q); } } return super.query(query); }
public Query query(CassandraSessionPool.Session session, Query query) { Set<Condition> conditions = query.conditions(); if (!(query instanceof ConditionQuery) || conditions.isEmpty()) { return query; } ConditionQuery q = ((ConditionQuery) query).copy(); String name = (String) q.condition(HugeKeys.NAME); if (name != null && q.allSysprop() && conditions.size() == 1 && q.containsCondition(HugeKeys.NAME, Condition.RelationType.EQ)) { Set<Integer> ids = queryByNameIndex(session, this.table, name); if (ids.isEmpty()) { // Not found data with the specified label return null; } q.resetConditions(); for (Integer id : ids) { q.query(IdGenerator.of(id)); } } return q; }
/** * Query data from label index table if just want to query by label */ private static Query queryByLabelIndex( CassandraSessionPool.Session session, String table, Query query) { Set<Condition> conditions = query.conditions(); if (!(query instanceof ConditionQuery) || conditions.isEmpty()) { return query; } ConditionQuery q = (ConditionQuery) query; Id label = (Id) q.condition(HugeKeys.LABEL); if (label != null && q.allSysprop() && conditions.size() == 1 && q.containsCondition(HugeKeys.LABEL, Condition.RelationType.EQ)) { Set<String> ids = queryByLabelIndex(session, table, label); if (ids.isEmpty()) { // Not found data with the specified label return null; } q.resetConditions(); for (String id : ids) { /* * NOTE: Do not need to deserialize, because can directly * use the element id to do query from the vertex/edge table */ q.query(IdGenerator.of(id)); } } return query; }
(conds.size() == 1 && !query.containsCondition(HugeKeys.LABEL))) { throw new BackendException("Can't do index query with %s", conds); Set<Id> ids; if (query.allSysprop() && conds.size() == 1 && query.containsCondition(HugeKeys.LABEL)) {
public static void verifyEdgesConditionQuery(ConditionQuery query) { assert query.resultType().isEdge(); int total = query.conditions().size(); if (total == 1) { // Supported: 1.query just by edge label, 2.query with scan if (query.containsCondition(HugeKeys.LABEL) || query.containsScanCondition()) { return; } } int matched = 0; for (HugeKeys key : EdgeId.KEYS) { Object value = query.condition(key); if (value == null) { break; } matched++; } if (matched != total) { throw new BackendException( "Not supported querying edges by %s, expect %s", query.conditions(), EdgeId.KEYS[matched]); } }
public boolean containsScanCondition() { return this.containsCondition(Condition.RelationType.SCAN); }
protected static boolean isQueryByLabel(Query query) { Set<Condition> conditions = query.conditions(); if (query instanceof ConditionQuery && !conditions.isEmpty()) { ConditionQuery cq = (ConditionQuery) query; Id label = (Id) cq.condition(HugeKeys.LABEL); if (label != null && cq.allSysprop() && conditions.size() == 1 && cq.containsCondition(HugeKeys.LABEL, Condition.RelationType.EQ)) { return true; } } return false; }
@Watched(prefix = "index") @Override public Iterator<BackendEntry> query(Query query) { if (query instanceof ConditionQuery) { ConditionQuery q = (ConditionQuery) query; if (q.allSysprop() && q.conditions().size() == 1 && q.containsCondition(HugeKeys.NAME)) { return this.queryByName(q); } } return super.query(query); }
public Query query(CassandraSessionPool.Session session, Query query) { Set<Condition> conditions = query.conditions(); if (!(query instanceof ConditionQuery) || conditions.isEmpty()) { return query; } ConditionQuery q = ((ConditionQuery) query).copy(); String name = (String) q.condition(HugeKeys.NAME); if (name != null && q.allSysprop() && conditions.size() == 1 && q.containsCondition(HugeKeys.NAME, Condition.RelationType.EQ)) { Set<Integer> ids = queryByNameIndex(session, this.table, name); if (ids.isEmpty()) { // Not found data with the specified label return null; } q.resetConditions(); for (Integer id : ids) { q.query(IdGenerator.of(id)); } } return q; }
/** * Query data from label index table if just want to query by label */ private static Query queryByLabelIndex( CassandraSessionPool.Session session, String table, Query query) { Set<Condition> conditions = query.conditions(); if (!(query instanceof ConditionQuery) || conditions.isEmpty()) { return query; } ConditionQuery q = (ConditionQuery) query; Id label = (Id) q.condition(HugeKeys.LABEL); if (label != null && q.allSysprop() && conditions.size() == 1 && q.containsCondition(HugeKeys.LABEL, Condition.RelationType.EQ)) { Set<String> ids = queryByLabelIndex(session, table, label); if (ids.isEmpty()) { // Not found data with the specified label return null; } q.resetConditions(); for (String id : ids) { /* * NOTE: Do not need to deserialize, because can directly * use the element id to do query from the vertex/edge table */ q.query(IdGenerator.of(id)); } } return query; }
(conds.size() == 1 && !query.containsCondition(HugeKeys.LABEL))) { throw new BackendException("Can't do index query with %s", conds); Set<Id> ids; if (query.allSysprop() && conds.size() == 1 && query.containsCondition(HugeKeys.LABEL)) {
public static void verifyEdgesConditionQuery(ConditionQuery query) { assert query.resultType().isEdge(); int total = query.conditions().size(); if (total == 1) { // Supported: 1.query just by edge label, 2.query with scan if (query.containsCondition(HugeKeys.LABEL) || query.containsScanCondition()) { return; } } int matched = 0; for (HugeKeys key : EdgeId.KEYS) { Object value = query.condition(key); if (value == null) { break; } matched++; } if (matched != total) { throw new BackendException( "Not supported querying edges by %s, expect %s", query.conditions(), EdgeId.KEYS[matched]); } }