Skip to content

Commit

Permalink
tiny fix
Browse files Browse the repository at this point in the history
Change-Id: I70290333e221be87fda4cb332fc9e8e234271e4d
  • Loading branch information
javeme committed Oct 26, 2021
1 parent 38aae46 commit bd83132
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public BatchConditionQuery(HugeType resultType) {

public void mergeToIN(ConditionQuery query, HugeKeys key) {
Object value = query.condition(key);

if (this.in == null) {
assert !this.containsRelation(RelationType.IN);
this.resetConditions(new LinkedHashSet<>(query.conditions()));
Expand All @@ -52,7 +51,7 @@ public void mergeToIN(ConditionQuery query, HugeKeys key) {
} else {
E.checkArgument(this.in.key().equals(key),
"Invalid key '%s'", key);
E.checkArgument(keysEquals(query),
E.checkArgument(this.sameQueryExceptKeyIN(query),
"Can't merge query with different keys");

@SuppressWarnings("unchecked")
Expand All @@ -61,24 +60,17 @@ public void mergeToIN(ConditionQuery query, HugeKeys key) {
}
}

protected boolean keysEquals(ConditionQuery query) {
protected boolean sameQueryExceptKeyIN(ConditionQuery query) {
List<Condition.Relation> relations = query.relations();
if (relations.size() != this.relations().size()) {
return false;
}
List<Object> keys = new ArrayList<>(relations.size());
for (Condition.Relation r : this.relations()) {
keys.add(r.key());
}

for (Condition.Relation r : this.relations()) {
if (r.relation() == RelationType.IN) {
continue;
}
Object key = r.key();
if (!keys.contains(key)) {
return false;
}
if (!this.condition(key).equals(query.condition(key))) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private static Condition convIn2Or(Relation relation, boolean supportIn) {
E.checkArgument(values.size() <= Query.QUERY_BATCH,
"Too many conditions(%s) each query", values.size());

// Keep IN condition if supported and necessary
// Keep IN condition if IN query is supported and necessary
if (supportIn && relation.isSysprop() && values.size() > 1 &&
(key == HugeKeys.OWNER_VERTEX || key == HugeKeys.ID)) {
// TODO: Should not rely on HugeKeys here, improve key judgment
Expand Down

0 comments on commit bd83132

Please sign in to comment.