LUCENE-7685: Remove equals/rewrite hacks from block join queries.

This commit is contained in:
Adrien Grand 2017-02-16 09:37:59 +01:00
parent f0e59ea849
commit c2f061d7cb
3 changed files with 10 additions and 40 deletions

View File

@ -126,6 +126,10 @@ Bug Fixes
* LUCENE-7692: PatternReplaceCharFilterFactory now implements MultiTermAware.
(Adrien Grand)
* LUCENE-7685: ToParentBlockJoinQuery and ToChildBlockJoinQuery now use the
rewritten child query in their equals and hashCode implementations.
(Adrien Grand)
Improvements
* LUCENE-7055: Added Weight#scorerSupplier, which allows to estimate the cost

View File

@ -52,13 +52,6 @@ public class ToChildBlockJoinQuery extends Query {
private final BitSetProducer parentsFilter;
private final Query parentQuery;
// If we are rewritten, this is the original parentQuery we
// were passed; we use this for .equals() and
// .hashCode(). This makes rewritten query equal the
// original, so that user does not have to .rewrite() their
// query before searching:
private final Query origParentQuery;
/**
* Create a ToChildBlockJoinQuery.
*
@ -67,14 +60,6 @@ public class ToChildBlockJoinQuery extends Query {
*/
public ToChildBlockJoinQuery(Query parentQuery, BitSetProducer parentsFilter) {
super();
this.origParentQuery = parentQuery;
this.parentQuery = parentQuery;
this.parentsFilter = parentsFilter;
}
private ToChildBlockJoinQuery(Query origParentQuery, Query parentQuery, BitSetProducer parentsFilter) {
super();
this.origParentQuery = origParentQuery;
this.parentQuery = parentQuery;
this.parentsFilter = parentsFilter;
}
@ -312,9 +297,7 @@ public class ToChildBlockJoinQuery extends Query {
public Query rewrite(IndexReader reader) throws IOException {
final Query parentRewrite = parentQuery.rewrite(reader);
if (parentRewrite != parentQuery) {
return new ToChildBlockJoinQuery(parentQuery,
parentRewrite,
parentsFilter);
return new ToChildBlockJoinQuery(parentRewrite, parentsFilter);
} else {
return super.rewrite(reader);
}
@ -332,7 +315,7 @@ public class ToChildBlockJoinQuery extends Query {
}
private boolean equalsTo(ToChildBlockJoinQuery other) {
return origParentQuery.equals(other.origParentQuery) &&
return parentQuery.equals(other.parentQuery) &&
parentsFilter.equals(other.parentsFilter);
}
@ -340,7 +323,7 @@ public class ToChildBlockJoinQuery extends Query {
public int hashCode() {
final int prime = 31;
int hash = classHash();
hash = prime * hash + origParentQuery.hashCode();
hash = prime * hash + parentQuery.hashCode();
hash = prime * hash + parentsFilter.hashCode();
return hash;
}

View File

@ -67,13 +67,6 @@ public class ToParentBlockJoinQuery extends Query {
private final BitSetProducer parentsFilter;
private final Query childQuery;
// If we are rewritten, this is the original childQuery we
// were passed; we use this for .equals() and
// .hashCode(). This makes rewritten query equal the
// original, so that user does not have to .rewrite() their
// query before searching:
private final Query origChildQuery;
private final ScoreMode scoreMode;
/** Create a ToParentBlockJoinQuery.
@ -85,15 +78,6 @@ public class ToParentBlockJoinQuery extends Query {
**/
public ToParentBlockJoinQuery(Query childQuery, BitSetProducer parentsFilter, ScoreMode scoreMode) {
super();
this.origChildQuery = childQuery;
this.childQuery = childQuery;
this.parentsFilter = parentsFilter;
this.scoreMode = scoreMode;
}
private ToParentBlockJoinQuery(Query origChildQuery, Query childQuery, BitSetProducer parentsFilter, ScoreMode scoreMode) {
super();
this.origChildQuery = origChildQuery;
this.childQuery = childQuery;
this.parentsFilter = parentsFilter;
this.scoreMode = scoreMode;
@ -377,8 +361,7 @@ public class ToParentBlockJoinQuery extends Query {
public Query rewrite(IndexReader reader) throws IOException {
final Query childRewrite = childQuery.rewrite(reader);
if (childRewrite != childQuery) {
return new ToParentBlockJoinQuery(origChildQuery,
childRewrite,
return new ToParentBlockJoinQuery(childRewrite,
parentsFilter,
scoreMode);
} else {
@ -398,7 +381,7 @@ public class ToParentBlockJoinQuery extends Query {
}
private boolean equalsTo(ToParentBlockJoinQuery other) {
return origChildQuery.equals(other.origChildQuery) &&
return childQuery.equals(other.childQuery) &&
parentsFilter.equals(other.parentsFilter) &&
scoreMode == other.scoreMode;
}
@ -407,7 +390,7 @@ public class ToParentBlockJoinQuery extends Query {
public int hashCode() {
final int prime = 31;
int hash = classHash();
hash = prime * hash + origChildQuery.hashCode();
hash = prime * hash + childQuery.hashCode();
hash = prime * hash + scoreMode.hashCode();
hash = prime * hash + parentsFilter.hashCode();
return hash;