diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/FieldData.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/FieldData.java index 7c5aaeb756d..4ce295f3eb8 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/FieldData.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/field/FieldData.java @@ -34,7 +34,6 @@ import java.io.IOException; * @author kimchy (Shay Banon) */ // General TODOs on FieldData -// TODO Make storing of freqs optional // TODO Optimize the order (both int[] and int[][] when they are sparse, create an Order abstraction) public abstract class FieldData { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/util/lucene/search/AndFilter.java b/modules/elasticsearch/src/main/java/org/elasticsearch/util/lucene/search/AndFilter.java index 66f4862ebc9..2dddf72b2a9 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/util/lucene/search/AndFilter.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/util/lucene/search/AndFilter.java @@ -55,4 +55,25 @@ public class AndFilter extends Filter { } return new AndDocSet(sets); } + + @Override public int hashCode() { + int hash = 7; + hash = 31 * hash + (null == filters ? 0 : filters.hashCode()); + return hash; + } + + @Override public boolean equals(Object obj) { + if (this == obj) + return true; + + if ((obj == null) || (obj.getClass() != this.getClass())) + return false; + + AndFilter other = (AndFilter) obj; + return equalFilters(filters, other.filters); + } + + private boolean equalFilters(List filters1, List filters2) { + return (filters1 == filters2) || ((filters1 != null) && filters1.equals(filters2)); + } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/util/lucene/search/NotFilter.java b/modules/elasticsearch/src/main/java/org/elasticsearch/util/lucene/search/NotFilter.java index 3a16dffd67b..097ba7367ee 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/util/lucene/search/NotFilter.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/util/lucene/search/NotFilter.java @@ -45,4 +45,18 @@ public class NotFilter extends Filter { @Override public DocIdSet getDocIdSet(IndexReader reader) throws IOException { return new NotDocSet(DocSets.convert(reader, filter.getDocIdSet(reader)), reader.maxDoc()); } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + NotFilter notFilter = (NotFilter) o; + return !(filter != null ? !filter.equals(notFilter.filter) : notFilter.filter != null); + } + + @Override + public int hashCode() { + return filter != null ? filter.hashCode() : 0; + } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/util/lucene/search/OrFilter.java b/modules/elasticsearch/src/main/java/org/elasticsearch/util/lucene/search/OrFilter.java index 420d659cdfc..36a29ff3602 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/util/lucene/search/OrFilter.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/util/lucene/search/OrFilter.java @@ -55,4 +55,25 @@ public class OrFilter extends Filter { } return new OrDocSet(sets); } + + @Override public int hashCode() { + int hash = 7; + hash = 31 * hash + (null == filters ? 0 : filters.hashCode()); + return hash; + } + + @Override public boolean equals(Object obj) { + if (this == obj) + return true; + + if ((obj == null) || (obj.getClass() != this.getClass())) + return false; + + OrFilter other = (OrFilter) obj; + return equalFilters(filters, other.filters); + } + + private boolean equalFilters(List filters1, List filters2) { + return (filters1 == filters2) || ((filters1 != null) && filters1.equals(filters2)); + } } \ No newline at end of file