Skip to content

Commit

Permalink
Properly cache parent/child queries in the case they are wrapped in a…
Browse files Browse the repository at this point in the history
… compound filter.

Closes #2971
  • Loading branch information
martijnvg committed May 2, 2013
1 parent 3d89c16 commit 5fd2ba7
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,36 @@ private ChildrenQuery(ChildrenQuery unProcessedQuery, Query rewrittenChildQuery)
this.uidToCount = unProcessedQuery.uidToCount;
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || obj.getClass() != this.getClass()) {
return false;
}

HasChildFilter that = (HasChildFilter) obj;
if (!originalChildQuery.equals(that.childQuery)) {
return false;
}
if (!childType.equals(that.childType)) {
return false;
}
if (!parentType.equals(that.parentType)) {
return false;
}
return true;
}

@Override
public int hashCode() {
int result = originalChildQuery.hashCode();
result = 31 * result + parentType.hashCode();
result = 31 * result + childType.hashCode();
return result;
}

@Override
public String toString(String field) {
StringBuilder sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,32 @@ public void contextClear() {
uidToScore = null;
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || obj.getClass() != this.getClass()) {
return false;
}

HasParentFilter that = (HasParentFilter) obj;
if (!originalParentQuery.equals(that.parentQuery)) {
return false;
}
if (!parentType.equals(that.parentType)) {
return false;
}
return true;
}

@Override
public int hashCode() {
int result = originalParentQuery.hashCode();
result = 31 * result + parentType.hashCode();
return result;
}

@Override
public String toString(String field) {
StringBuilder sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,36 @@ public Weight createWeight(IndexSearcher searcher) throws IOException {
return new ParentWeight(searcher, rewrittenChildQuery.createWeight(searcher));
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || obj.getClass() != this.getClass()) {
return false;
}

HasChildFilter that = (HasChildFilter) obj;
if (!originalChildQuery.equals(that.childQuery)) {
return false;
}
if (!childType.equals(that.childType)) {
return false;
}
if (!parentType.equals(that.parentType)) {
return false;
}
return true;
}

@Override
public int hashCode() {
int result = originalChildQuery.hashCode();
result = 31 * result + parentType.hashCode();
result = 31 * result + childType.hashCode();
return result;
}

public String toString(String field) {
StringBuilder sb = new StringBuilder();
sb.append("score_child[").append(childType).append("/").append(parentType).append("](").append(originalChildQuery.toString(field)).append(')');
Expand Down

0 comments on commit 5fd2ba7

Please sign in to comment.