You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2012/11/07 03:40:27 UTC
svn commit: r1406422 - in /lucene/dev/branches/branch_4x: ./ lucene/
lucene/core/ lucene/core/src/java/org/apache/lucene/search/similarities/
lucene/core/src/test/org/apache/lucene/index/
lucene/core/src/test/org/apache/lucene/search/ lucene/core/src/t...
Author: rmuir
Date: Wed Nov 7 02:40:26 2012
New Revision: 1406422
URL: http://svn.apache.org/viewvc?rev=1406422&view=rev
Log:
LUCENE-4543: bring back TFIDFSimilarity.lengthNorm
Modified:
lucene/dev/branches/branch_4x/ (props changed)
lucene/dev/branches/branch_4x/lucene/ (props changed)
lucene/dev/branches/branch_4x/lucene/CHANGES.txt (contents, props changed)
lucene/dev/branches/branch_4x/lucene/core/ (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/similarities/DefaultSimilarity.java
lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/similarities/TFIDFSimilarity.java
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestMaxTermFrequency.java
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestNorms.java
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestOmitTf.java
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestUniqueTermCount.java
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestSimilarity.java
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestSimilarityProvider.java
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java
lucene/dev/branches/branch_4x/lucene/misc/ (props changed)
lucene/dev/branches/branch_4x/lucene/misc/src/java/org/apache/lucene/misc/SweetSpotSimilarity.java
Modified: lucene/dev/branches/branch_4x/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/CHANGES.txt?rev=1406422&r1=1406421&r2=1406422&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/lucene/CHANGES.txt Wed Nov 7 02:40:26 2012
@@ -16,6 +16,11 @@ Changes in backwards compatibility polic
floating point value. Scorer now extends DocsEnum so it has attributes().
(Robert Muir)
+* LUCENE-4543: TFIDFSimilarity's index-time computeNorm is now final to
+ match the fact that its query-time norm usage requires a FIXED_8 encoding.
+ Override lengthNorm and/or encode/decodeNormValue to change the specifics,
+ like Lucene 3.x. (Robert Muir)
+
New Features
* LUCENE-4226: New experimental StoredFieldsFormat (in lucene/codecs) that
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/similarities/DefaultSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/similarities/DefaultSimilarity.java?rev=1406422&r1=1406421&r2=1406422&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/similarities/DefaultSimilarity.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/similarities/DefaultSimilarity.java Wed Nov 7 02:40:26 2012
@@ -46,13 +46,13 @@ public class DefaultSimilarity extends T
*
* @lucene.experimental */
@Override
- public void computeNorm(FieldInvertState state, Norm norm) {
+ public float lengthNorm(FieldInvertState state) {
final int numTerms;
if (discountOverlaps)
numTerms = state.getLength() - state.getNumOverlap();
else
numTerms = state.getLength();
- norm.setByte(encodeNormValue(state.getBoost() * ((float) (1.0 / Math.sqrt(numTerms)))));
+ return state.getBoost() * ((float) (1.0 / Math.sqrt(numTerms)));
}
/** Implemented as <code>sqrt(freq)</code>. */
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/similarities/TFIDFSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/similarities/TFIDFSimilarity.java?rev=1406422&r1=1406421&r2=1406422&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/similarities/TFIDFSimilarity.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/similarities/TFIDFSimilarity.java Wed Nov 7 02:40:26 2012
@@ -22,6 +22,8 @@ import java.io.IOException;
import org.apache.lucene.index.AtomicReaderContext;
import org.apache.lucene.index.DocValues;
+import org.apache.lucene.index.FieldInvertState;
+import org.apache.lucene.index.Norm;
import org.apache.lucene.search.CollectionStatistics;
import org.apache.lucene.search.Explanation;
import org.apache.lucene.search.IndexSearcher;
@@ -668,6 +670,23 @@ public abstract class TFIDFSimilarity ex
*/
public abstract float idf(long docFreq, long numDocs);
+ /**
+ * Compute an index-time normalization value for this field instance.
+ * <p>
+ * This value will be stored in a single byte lossy representation by
+ * {@link #encodeNormValue(float)}.
+ *
+ * @param state statistics of the current field (such as length, boost, etc)
+ * @return an index-time normalization value
+ */
+ public abstract float lengthNorm(FieldInvertState state);
+
+ @Override
+ public final void computeNorm(FieldInvertState state, Norm norm) {
+ float normValue = lengthNorm(state);
+ norm.setByte(encodeNormValue(normValue));
+ }
+
/** Cache of decoded bytes. */
private static final float[] NORM_TABLE = new float[256];
Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java?rev=1406422&r1=1406421&r2=1406422&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java Wed Nov 7 02:40:26 2012
@@ -25,9 +25,14 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.DocValues.Source;
import org.apache.lucene.index.DocValues.Type;
+import org.apache.lucene.search.CollectionStatistics;
+import org.apache.lucene.search.TermStatistics;
import org.apache.lucene.search.similarities.DefaultSimilarity;
import org.apache.lucene.search.similarities.PerFieldSimilarityWrapper;
import org.apache.lucene.search.similarities.Similarity;
+import org.apache.lucene.search.similarities.Similarity.ExactSimScorer;
+import org.apache.lucene.search.similarities.Similarity.SimWeight;
+import org.apache.lucene.search.similarities.Similarity.SloppySimScorer;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
@@ -194,16 +199,31 @@ public class TestCustomNorms extends Luc
}
}
- public static class FloatEncodingBoostSimilarity extends DefaultSimilarity {
+ public static class FloatEncodingBoostSimilarity extends Similarity {
@Override
public void computeNorm(FieldInvertState state, Norm norm) {
float boost = state.getBoost();
norm.setFloat(boost);
}
+
+ @Override
+ public SimWeight computeWeight(float queryBoost, CollectionStatistics collectionStats, TermStatistics... termStats) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ExactSimScorer exactSimScorer(SimWeight weight, AtomicReaderContext context) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public SloppySimScorer sloppySimScorer(SimWeight weight, AtomicReaderContext context) throws IOException {
+ throw new UnsupportedOperationException();
+ }
}
- public static class RandomTypeSimilarity extends DefaultSimilarity {
+ public static class RandomTypeSimilarity extends Similarity {
private final Random random;
@@ -239,29 +259,50 @@ public class TestCustomNorms extends Luc
}
}
- }
-
- class IllegalCustomEncodingSimilarity extends DefaultSimilarity {
-
- public boolean useByte = false;
+
@Override
- public byte encodeNormValue(float f) {
- return (byte) f;
+ public SimWeight computeWeight(float queryBoost, CollectionStatistics collectionStats, TermStatistics... termStats) {
+ throw new UnsupportedOperationException();
}
-
+
@Override
- public float decodeNormValue(byte b) {
- return (float) b;
+ public ExactSimScorer exactSimScorer(SimWeight weight, AtomicReaderContext context) throws IOException {
+ throw new UnsupportedOperationException();
}
@Override
+ public SloppySimScorer sloppySimScorer(SimWeight weight, AtomicReaderContext context) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ class IllegalCustomEncodingSimilarity extends Similarity {
+
+ public boolean useByte = false;
+
+ @Override
public void computeNorm(FieldInvertState state, Norm norm) {
if (useByte) {
- norm.setByte(encodeNormValue((float) state.getLength()));
+ norm.setByte((byte)state.getLength());
} else {
norm.setFloat((float)state.getLength());
}
}
+
+ @Override
+ public SimWeight computeWeight(float queryBoost, CollectionStatistics collectionStats, TermStatistics... termStats) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ExactSimScorer exactSimScorer(SimWeight weight, AtomicReaderContext context) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public SloppySimScorer sloppySimScorer(SimWeight weight, AtomicReaderContext context) throws IOException {
+ throw new UnsupportedOperationException();
+ }
}
}
Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestMaxTermFrequency.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestMaxTermFrequency.java?rev=1406422&r1=1406421&r2=1406422&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestMaxTermFrequency.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestMaxTermFrequency.java Wed Nov 7 02:40:26 2012
@@ -109,8 +109,8 @@ public class TestMaxTermFrequency extend
}
@Override
- public void computeNorm(FieldInvertState state, Norm norm) {
- norm.setByte(encodeNormValue((float) state.getMaxTermFrequency()));
+ public float lengthNorm(FieldInvertState state) {
+ return state.getMaxTermFrequency();
}
}
}
Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestNorms.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestNorms.java?rev=1406422&r1=1406421&r2=1406422&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestNorms.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestNorms.java Wed Nov 7 02:40:26 2012
@@ -26,6 +26,8 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.DocValues.Source;
import org.apache.lucene.index.DocValues.Type;
+import org.apache.lucene.search.CollectionStatistics;
+import org.apache.lucene.search.TermStatistics;
import org.apache.lucene.search.similarities.DefaultSimilarity;
import org.apache.lucene.search.similarities.PerFieldSimilarityWrapper;
import org.apache.lucene.search.similarities.Similarity;
@@ -57,8 +59,8 @@ public class TestNorms extends LuceneTes
}
@Override
- public void computeNorm(FieldInvertState state, Norm norm) {
- norm.setByte(encodeNormValue((float) state.getLength()));
+ public float lengthNorm(FieldInvertState state) {
+ return state.getLength();
}
}
@@ -232,7 +234,7 @@ public class TestNorms extends LuceneTes
}
- public static class ByteEncodingBoostSimilarity extends DefaultSimilarity {
+ public static class ByteEncodingBoostSimilarity extends Similarity {
private boolean writeNorms;
@@ -247,5 +249,20 @@ public class TestNorms extends LuceneTes
norm.setByte((byte) (0xFF & boost));
}
}
+
+ @Override
+ public SimWeight computeWeight(float queryBoost, CollectionStatistics collectionStats, TermStatistics... termStats) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ExactSimScorer exactSimScorer(SimWeight weight, AtomicReaderContext context) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public SloppySimScorer sloppySimScorer(SimWeight weight, AtomicReaderContext context) throws IOException {
+ throw new UnsupportedOperationException();
+ }
}
}
Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestOmitTf.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestOmitTf.java?rev=1406422&r1=1406421&r2=1406422&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestOmitTf.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestOmitTf.java Wed Nov 7 02:40:26 2012
@@ -39,7 +39,7 @@ public class TestOmitTf extends LuceneTe
public static class SimpleSimilarity extends TFIDFSimilarity {
public float queryNorm(float sumOfSquaredWeights) { return 1.0f; }
public float coord(int overlap, int maxOverlap) { return 1.0f; }
- @Override public void computeNorm(FieldInvertState state, Norm norm) { norm.setByte(encodeNormValue(state.getBoost())); }
+ @Override public float lengthNorm(FieldInvertState state) { return state.getBoost(); }
@Override public float tf(float freq) { return freq; }
@Override public float sloppyFreq(int distance) { return 2.0f; }
@Override public float idf(long docFreq, long numDocs) { return 1.0f; }
Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestUniqueTermCount.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestUniqueTermCount.java?rev=1406422&r1=1406421&r2=1406422&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestUniqueTermCount.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestUniqueTermCount.java Wed Nov 7 02:40:26 2012
@@ -17,6 +17,7 @@ package org.apache.lucene.index;
* limitations under the License.
*/
+import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
@@ -24,7 +25,10 @@ import org.apache.lucene.analysis.MockAn
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+import org.apache.lucene.search.CollectionStatistics;
+import org.apache.lucene.search.TermStatistics;
import org.apache.lucene.search.similarities.DefaultSimilarity;
+import org.apache.lucene.search.similarities.Similarity;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util._TestUtil;
@@ -91,11 +95,26 @@ public class TestUniqueTermCount extends
/**
* Simple similarity that encodes maxTermFrequency directly as a byte
*/
- class TestSimilarity extends DefaultSimilarity {
+ class TestSimilarity extends Similarity {
@Override
public void computeNorm(FieldInvertState state, Norm norm) {
norm.setByte((byte) state.getUniqueTermCount());
}
+
+ @Override
+ public SimWeight computeWeight(float queryBoost, CollectionStatistics collectionStats, TermStatistics... termStats) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ExactSimScorer exactSimScorer(SimWeight weight, AtomicReaderContext context) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public SloppySimScorer sloppySimScorer(SimWeight weight, AtomicReaderContext context) throws IOException {
+ throw new UnsupportedOperationException();
+ }
}
}
Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java?rev=1406422&r1=1406421&r2=1406422&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java Wed Nov 7 02:40:26 2012
@@ -68,9 +68,9 @@ public class TestDisjunctionMaxQuery ext
}
@Override
- public void computeNorm(FieldInvertState state, Norm norm) {
+ public float lengthNorm(FieldInvertState state) {
// Disable length norm
- norm.setByte(encodeNormValue(state.getBoost()));
+ return state.getBoost();
}
@Override
Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestSimilarity.java?rev=1406422&r1=1406421&r2=1406422&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestSimilarity.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestSimilarity.java Wed Nov 7 02:40:26 2012
@@ -42,7 +42,7 @@ public class TestSimilarity extends Luce
public static class SimpleSimilarity extends DefaultSimilarity {
public float queryNorm(float sumOfSquaredWeights) { return 1.0f; }
public float coord(int overlap, int maxOverlap) { return 1.0f; }
- @Override public void computeNorm(FieldInvertState state, Norm norm) { norm.setByte(encodeNormValue(state.getBoost())); }
+ @Override public float lengthNorm(FieldInvertState state) { return state.getBoost(); }
@Override public float tf(float freq) { return freq; }
@Override public float sloppyFreq(int distance) { return 2.0f; }
@Override public float idf(long docFreq, long numDocs) { return 1.0f; }
Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestSimilarityProvider.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestSimilarityProvider.java?rev=1406422&r1=1406421&r2=1406422&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestSimilarityProvider.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestSimilarityProvider.java Wed Nov 7 02:40:26 2012
@@ -115,8 +115,8 @@ public class TestSimilarityProvider exte
}
@Override
- public void computeNorm(FieldInvertState state, Norm norm) {
- norm.setByte(encodeNormValue(1f));
+ public float lengthNorm(FieldInvertState state) {
+ return 1f;
}
@Override
@@ -151,8 +151,8 @@ public class TestSimilarityProvider exte
}
@Override
- public void computeNorm(FieldInvertState state, Norm norm) {
- norm.setByte(encodeNormValue(10f));
+ public float lengthNorm(FieldInvertState state) {
+ return 10f;
}
@Override
Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java?rev=1406422&r1=1406421&r2=1406422&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java Wed Nov 7 02:40:26 2012
@@ -324,8 +324,8 @@ public class TestPayloadNearQuery extend
//Make everything else 1 so we see the effect of the payload
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@Override
- public void computeNorm(FieldInvertState state, Norm norm) {
- norm.setByte(encodeNormValue(state.getBoost()));
+ public float lengthNorm(FieldInvertState state) {
+ return state.getBoost();
}
@Override
Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java?rev=1406422&r1=1406421&r2=1406422&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadTermQuery.java Wed Nov 7 02:40:26 2012
@@ -314,8 +314,8 @@ public class TestPayloadTermQuery extend
//Make everything else 1 so we see the effect of the payload
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@Override
- public void computeNorm(FieldInvertState state, Norm norm) {
- norm.setByte(encodeNormValue(state.getBoost()));
+ public float lengthNorm(FieldInvertState state) {
+ return state.getBoost();
}
@Override
Modified: lucene/dev/branches/branch_4x/lucene/misc/src/java/org/apache/lucene/misc/SweetSpotSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/misc/src/java/org/apache/lucene/misc/SweetSpotSimilarity.java?rev=1406422&r1=1406421&r2=1406422&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/misc/src/java/org/apache/lucene/misc/SweetSpotSimilarity.java (original)
+++ lucene/dev/branches/branch_4x/lucene/misc/src/java/org/apache/lucene/misc/SweetSpotSimilarity.java Wed Nov 7 02:40:26 2012
@@ -108,7 +108,7 @@ public class SweetSpotSimilarity extends
* discountOverlaps is true by default or true for this
* specific field. */
@Override
- public void computeNorm(FieldInvertState state, Norm norm) {
+ public float lengthNorm(FieldInvertState state) {
final int numTokens;
if (discountOverlaps)
@@ -116,7 +116,7 @@ public class SweetSpotSimilarity extends
else
numTokens = state.getLength();
- norm.setByte(encodeNormValue(state.getBoost() * computeLengthNorm(numTokens)));
+ return state.getBoost() * computeLengthNorm(numTokens);
}
/**