Skip to content

Commit

Permalink
check releation return
Browse files Browse the repository at this point in the history
Change-Id: I21c8b767784fe68487b334ba4d9cb4ddcc53a306
  • Loading branch information
Linary committed Apr 17, 2019
1 parent 16b4ea3 commit fe48ef4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -412,20 +412,20 @@ public boolean isFlattened() {
return true;
}

public boolean hasDuplicateKeys(Set<HugeKeys> keys) {
public boolean mayHasDupKeys(Set<HugeKeys> keys) {
Map<HugeKeys, Integer> keyCounts = new HashMap<>();
for (Condition condition : this.conditions()) {
E.checkState(condition.isRelation(),
"All conditions should be relations");
if (!condition.isRelation()) {
// Assume may exist duplicate keys when has nested conditions
return true;
}
Relation relation = (Relation) condition;
if (keys.contains(relation.key())) {
int keyCount = keyCounts.getOrDefault(relation.key(), 0);
keyCounts.put((HugeKeys) relation.key(), ++keyCount);
}
}
for (Integer keyCount : keyCounts.values()) {
if (keyCount > 1) {
return true;
if (++keyCount > 1) {
return true;
}
keyCounts.put((HugeKeys) relation.key(), keyCount);
}
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public final class ConditionQueryFlatten {
);

public static List<ConditionQuery> flatten(ConditionQuery query) {
if (query.isFlattened() && !query.hasDuplicateKeys(SPECIAL_KEYS)) {
if (query.isFlattened() && !query.mayHasDupKeys(SPECIAL_KEYS)) {
return Arrays.asList(query);
}

Expand Down

0 comments on commit fe48ef4

Please sign in to comment.