From 9dad6f32466b50d04a402d155325d62aa6f44e14 Mon Sep 17 00:00:00 2001 From: Mark Robert Miller Date: Fri, 21 Aug 2009 15:12:41 +0000 Subject: [PATCH] LUCENE-1830: hashCode + equals for BoostNearQuery and PayloadFunction git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@806591 13f79535-47bb-0310-9956-ffa450edef68 --- .../search/payloads/BoostingNearQuery.java | 33 ++++++++++++++++++- .../search/payloads/PayloadFunction.java | 9 +++-- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/java/org/apache/lucene/search/payloads/BoostingNearQuery.java b/src/java/org/apache/lucene/search/payloads/BoostingNearQuery.java index cac31e8b9d5..faa05a25a16 100644 --- a/src/java/org/apache/lucene/search/payloads/BoostingNearQuery.java +++ b/src/java/org/apache/lucene/search/payloads/BoostingNearQuery.java @@ -86,7 +86,7 @@ public class BoostingNearQuery extends SpanNearQuery implements PayloadQuery { public class BoostingSpanScorer extends SpanScorer { Spans spans; - Spans[] subSpans = null; + protected float payloadScore; private int payloadsSeen; Similarity similarity = getSimilarity(); @@ -161,6 +161,37 @@ public class BoostingNearQuery extends SpanNearQuery implements PayloadQuery { return result; } } + + //@Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((fieldName == null) ? 0 : fieldName.hashCode()); + result = prime * result + ((function == null) ? 0 : function.hashCode()); + return result; + } + + //@Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + BoostingNearQuery other = (BoostingNearQuery) obj; + if (fieldName == null) { + if (other.fieldName != null) + return false; + } else if (!fieldName.equals(other.fieldName)) + return false; + if (function == null) { + if (other.function != null) + return false; + } else if (!function.equals(other.function)) + return false; + return true; + } } diff --git a/src/java/org/apache/lucene/search/payloads/PayloadFunction.java b/src/java/org/apache/lucene/search/payloads/PayloadFunction.java index 51ae6d5cf55..153458b2da9 100644 --- a/src/java/org/apache/lucene/search/payloads/PayloadFunction.java +++ b/src/java/org/apache/lucene/search/payloads/PayloadFunction.java @@ -16,8 +16,6 @@ package org.apache.lucene.search.payloads; * limitations under the License. */ -import org.apache.lucene.index.Term; - import java.io.Serializable; @@ -33,9 +31,6 @@ import java.io.Serializable; **/ public abstract class PayloadFunction implements Serializable { - - - /** * Calculate the score up to this point for this doc and field * @param docId The current doc @@ -60,5 +55,9 @@ public abstract class PayloadFunction implements Serializable { * @return The final score for the payloads */ public abstract float docScore(int docId, String field, int numPayloadsSeen, float payloadScore); + + public abstract int hashCode(); + + public abstract boolean equals(Object o); }