lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@apache.org
Subject [02/13] lucene-solr:jira/solr-11702: LUCENE-8116: Remove unnecessary IOException.
Date Mon, 15 Jan 2018 02:21:20 GMT
LUCENE-8116: Remove unnecessary IOException.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/75d50b44
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/75d50b44
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/75d50b44

Branch: refs/heads/jira/solr-11702
Commit: 75d50b4492d0494605aec824a5877b3653d9fdc1
Parents: 4d9a418
Author: Adrien Grand <jpountz@gmail.com>
Authored: Thu Jan 11 11:42:03 2018 +0100
Committer: Adrien Grand <jpountz@gmail.com>
Committed: Thu Jan 11 11:49:36 2018 +0100

----------------------------------------------------------------------
 .../org/apache/lucene/search/similarities/BM25Similarity.java | 7 +++----
 .../apache/lucene/search/similarities/BooleanSimilarity.java  | 6 ++----
 .../apache/lucene/search/similarities/MultiSimilarity.java    | 5 ++---
 .../org/apache/lucene/search/similarities/Similarity.java     | 5 ++---
 .../org/apache/lucene/search/similarities/SimilarityBase.java | 7 +++----
 .../apache/lucene/search/similarities/TFIDFSimilarity.java    | 7 +++----
 .../test/org/apache/lucene/index/TestMaxTermFrequency.java    | 3 +--
 .../apache/lucene/search/TestBooleanQueryVisitSubscorers.java | 2 +-
 .../test/org/apache/lucene/search/TestSimilarityProvider.java | 6 ++----
 .../src/test/org/apache/lucene/search/TestSubScorerFreqs.java | 2 +-
 .../lucene/search/similarities/AssertingSimilarity.java       | 6 ++----
 11 files changed, 22 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/75d50b44/lucene/core/src/java/org/apache/lucene/search/similarities/BM25Similarity.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/search/similarities/BM25Similarity.java
b/lucene/core/src/java/org/apache/lucene/search/similarities/BM25Similarity.java
index bd20bf9..19ab0d2 100644
--- a/lucene/core/src/java/org/apache/lucene/search/similarities/BM25Similarity.java
+++ b/lucene/core/src/java/org/apache/lucene/search/similarities/BM25Similarity.java
@@ -17,7 +17,6 @@
 package org.apache.lucene.search.similarities;
 
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -214,13 +213,13 @@ public class BM25Similarity extends Similarity {
     }
 
     @Override
-    public float score(float freq, long encodedNorm) throws IOException {
+    public float score(float freq, long encodedNorm) {
       double norm = cache[((byte) encodedNorm) & 0xFF];
       return weight * (float) (freq / (freq + norm));
     }
 
     @Override
-    public Explanation explain(Explanation freq, long encodedNorm) throws IOException {
+    public Explanation explain(Explanation freq, long encodedNorm) {
       List<Explanation> subs = new ArrayList<>(explainConstantFactors());
       Explanation tfExpl = explainTF(freq, encodedNorm);
       subs.add(tfExpl);
@@ -228,7 +227,7 @@ public class BM25Similarity extends Similarity {
           "score(freq="+freq.getValue()+"), product of:", subs);
     }
     
-    private Explanation explainTF(Explanation freq, long norm) throws IOException {
+    private Explanation explainTF(Explanation freq, long norm) {
       List<Explanation> subs = new ArrayList<>();
       subs.add(freq);
       subs.add(Explanation.match(k1, "k1, term saturation parameter"));

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/75d50b44/lucene/core/src/java/org/apache/lucene/search/similarities/BooleanSimilarity.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/search/similarities/BooleanSimilarity.java
b/lucene/core/src/java/org/apache/lucene/search/similarities/BooleanSimilarity.java
index 6f7d26b..3c9206d 100644
--- a/lucene/core/src/java/org/apache/lucene/search/similarities/BooleanSimilarity.java
+++ b/lucene/core/src/java/org/apache/lucene/search/similarities/BooleanSimilarity.java
@@ -16,8 +16,6 @@
  */
 package org.apache.lucene.search.similarities;
 
-import java.io.IOException;
-
 import org.apache.lucene.index.FieldInvertState;
 import org.apache.lucene.search.CollectionStatistics;
 import org.apache.lucene.search.Explanation;
@@ -59,12 +57,12 @@ public class BooleanSimilarity extends Similarity {
     }
 
     @Override
-    public float score(float freq, long norm) throws IOException {
+    public float score(float freq, long norm) {
       return boost;
     }
 
     @Override
-    public Explanation explain(Explanation freq, long norm) throws IOException {
+    public Explanation explain(Explanation freq, long norm) {
       Explanation queryBoostExpl = Explanation.match(boost, "boost, query boost");
       return Explanation.match(
           queryBoostExpl.getValue(),

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/75d50b44/lucene/core/src/java/org/apache/lucene/search/similarities/MultiSimilarity.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/search/similarities/MultiSimilarity.java
b/lucene/core/src/java/org/apache/lucene/search/similarities/MultiSimilarity.java
index de2ea7f..e558c6e 100644
--- a/lucene/core/src/java/org/apache/lucene/search/similarities/MultiSimilarity.java
+++ b/lucene/core/src/java/org/apache/lucene/search/similarities/MultiSimilarity.java
@@ -17,7 +17,6 @@
 package org.apache.lucene.search.similarities;
 
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -65,7 +64,7 @@ public class MultiSimilarity extends Similarity {
     }
     
     @Override
-    public float score(float freq, long norm) throws IOException {
+    public float score(float freq, long norm) {
       float sum = 0.0f;
       for (SimScorer subScorer : subScorers) {
         sum += subScorer.score(freq, norm);
@@ -74,7 +73,7 @@ public class MultiSimilarity extends Similarity {
     }
 
     @Override
-    public Explanation explain(Explanation freq, long norm) throws IOException {
+    public Explanation explain(Explanation freq, long norm) {
       List<Explanation> subs = new ArrayList<>();
       for (SimScorer subScorer : subScorers) {
         subs.add(subScorer.explain(freq, norm));

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/75d50b44/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java b/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java
index 7479fff..f296c02 100644
--- a/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java
+++ b/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java
@@ -17,7 +17,6 @@
 package org.apache.lucene.search.similarities;
 
 
-import java.io.IOException;
 import java.util.Collections;
 import java.util.Objects;
 
@@ -180,7 +179,7 @@ public abstract class Similarity {
      * @param norm encoded normalization factor or {@code 1} if norms are disabled
      * @return document's score
      */
-    public abstract float score(float freq, long norm) throws IOException;
+    public abstract float score(float freq, long norm);
 
     /**
      * Explain the score for a single document
@@ -188,7 +187,7 @@ public abstract class Similarity {
      * @param norm encoded normalization factor, as returned by {@link Similarity#computeNorm},
or {@code 1} if norms are disabled
      * @return document's score
      */
-    public Explanation explain(Explanation freq, long norm) throws IOException {
+    public Explanation explain(Explanation freq, long norm) {
       return Explanation.match(
           score(freq.getValue().floatValue(), norm),
           "score(freq=" + freq.getValue() +"), with freq of:",

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/75d50b44/lucene/core/src/java/org/apache/lucene/search/similarities/SimilarityBase.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/search/similarities/SimilarityBase.java
b/lucene/core/src/java/org/apache/lucene/search/similarities/SimilarityBase.java
index f9dd636..1aefaed 100644
--- a/lucene/core/src/java/org/apache/lucene/search/similarities/SimilarityBase.java
+++ b/lucene/core/src/java/org/apache/lucene/search/similarities/SimilarityBase.java
@@ -17,7 +17,6 @@
 package org.apache.lucene.search.similarities;
 
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -217,17 +216,17 @@ public abstract class SimilarityBase extends Similarity {
       this.stats = stats;
     }
 
-    double getLengthValue(long norm) throws IOException {
+    double getLengthValue(long norm) {
       return LENGTH_TABLE[Byte.toUnsignedInt((byte) norm)];
     }
     
     @Override
-    public float score(float freq, long norm) throws IOException {
+    public float score(float freq, long norm) {
       return (float) SimilarityBase.this.score(stats, freq, getLengthValue(norm));
     }
 
     @Override
-    public Explanation explain(Explanation freq, long norm) throws IOException {
+    public Explanation explain(Explanation freq, long norm) {
       return SimilarityBase.this.explain(stats, freq, getLengthValue(norm));
     }
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/75d50b44/lucene/core/src/java/org/apache/lucene/search/similarities/TFIDFSimilarity.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/search/similarities/TFIDFSimilarity.java
b/lucene/core/src/java/org/apache/lucene/search/similarities/TFIDFSimilarity.java
index 9e4b5bf..d3224ab 100644
--- a/lucene/core/src/java/org/apache/lucene/search/similarities/TFIDFSimilarity.java
+++ b/lucene/core/src/java/org/apache/lucene/search/similarities/TFIDFSimilarity.java
@@ -17,7 +17,6 @@
 package org.apache.lucene.search.similarities;
 
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -543,18 +542,18 @@ public abstract class TFIDFSimilarity extends Similarity {
     }
 
     @Override
-    public float score(float freq, long norm) throws IOException {
+    public float score(float freq, long norm) {
       final float raw = tf(freq) * queryWeight; // compute tf(f)*weight
       float normValue = normTable[(int) (norm & 0xFF)];
       return raw * normValue;  // normalize for field
     }
 
     @Override
-    public Explanation explain(Explanation freq, long norm) throws IOException {
+    public Explanation explain(Explanation freq, long norm) {
       return explainScore(freq, norm, normTable);
     }
 
-    private Explanation explainScore(Explanation freq, long encodedNorm, float[] normTable)
throws IOException {
+    private Explanation explainScore(Explanation freq, long encodedNorm, float[] normTable)
{
       List<Explanation> subs = new ArrayList<Explanation>();
       if (boost != 1F) {
         subs.add(Explanation.match(boost, "boost"));

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/75d50b44/lucene/core/src/test/org/apache/lucene/index/TestMaxTermFrequency.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestMaxTermFrequency.java b/lucene/core/src/test/org/apache/lucene/index/TestMaxTermFrequency.java
index 7cc39b3..216dc21 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestMaxTermFrequency.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestMaxTermFrequency.java
@@ -17,7 +17,6 @@
 package org.apache.lucene.index;
 
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -113,7 +112,7 @@ public class TestMaxTermFrequency extends LuceneTestCase {
       return new SimScorer(collectionStats.field()) {
 
         @Override
-        public float score(float freq, long norm) throws IOException {
+        public float score(float freq, long norm) {
           return 0;
         }
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/75d50b44/lucene/core/src/test/org/apache/lucene/search/TestBooleanQueryVisitSubscorers.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestBooleanQueryVisitSubscorers.java
b/lucene/core/src/test/org/apache/lucene/search/TestBooleanQueryVisitSubscorers.java
index 0d7f4e6..de061a2 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestBooleanQueryVisitSubscorers.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestBooleanQueryVisitSubscorers.java
@@ -331,7 +331,7 @@ public class TestBooleanQueryVisitSubscorers extends LuceneTestCase {
     public SimScorer scorer(float boost, CollectionStatistics collectionStats, TermStatistics...
termStats) {
       return new SimScorer(collectionStats.field()) {
         @Override
-        public float score(float freq, long norm) throws IOException {
+        public float score(float freq, long norm) {
           return freq;
         }
       };

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/75d50b44/lucene/core/src/test/org/apache/lucene/search/TestSimilarityProvider.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestSimilarityProvider.java b/lucene/core/src/test/org/apache/lucene/search/TestSimilarityProvider.java
index f99a674..f360bed 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestSimilarityProvider.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestSimilarityProvider.java
@@ -17,8 +17,6 @@
 package org.apache.lucene.search;
 
 
-import java.io.IOException;
-
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
@@ -116,7 +114,7 @@ public class TestSimilarityProvider extends LuceneTestCase {
       return new SimScorer(collectionStats.field()) {
 
         @Override
-        public float score(float freq, long norm) throws IOException {
+        public float score(float freq, long norm) {
           return 1;
         }
       };
@@ -135,7 +133,7 @@ public class TestSimilarityProvider extends LuceneTestCase {
     public SimScorer scorer(float boost, CollectionStatistics collectionStats, TermStatistics...
termStats) {
       return new SimScorer(collectionStats.field()) {
         @Override
-        public float score(float freq, long norm) throws IOException {
+        public float score(float freq, long norm) {
           return 10;
         }
       };

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/75d50b44/lucene/core/src/test/org/apache/lucene/search/TestSubScorerFreqs.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestSubScorerFreqs.java b/lucene/core/src/test/org/apache/lucene/search/TestSubScorerFreqs.java
index c3bfcb3..f45e304 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestSubScorerFreqs.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestSubScorerFreqs.java
@@ -233,7 +233,7 @@ public class TestSubScorerFreqs extends LuceneTestCase {
     public SimScorer scorer(float boost, CollectionStatistics collectionStats, TermStatistics...
termStats) {
       return new SimScorer(collectionStats.field()) {
         @Override
-        public float score(float freq, long norm) throws IOException {
+        public float score(float freq, long norm) {
           return freq;
         }
       };

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/75d50b44/lucene/test-framework/src/java/org/apache/lucene/search/similarities/AssertingSimilarity.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/java/org/apache/lucene/search/similarities/AssertingSimilarity.java
b/lucene/test-framework/src/java/org/apache/lucene/search/similarities/AssertingSimilarity.java
index bedfe73..0eaf738 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/search/similarities/AssertingSimilarity.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/search/similarities/AssertingSimilarity.java
@@ -16,8 +16,6 @@
  */
 package org.apache.lucene.search.similarities;
 
-import java.io.IOException;
-
 import org.apache.lucene.index.FieldInvertState;
 import org.apache.lucene.search.CollectionStatistics;
 import org.apache.lucene.search.Explanation;
@@ -73,7 +71,7 @@ public class AssertingSimilarity extends Similarity {
     }
 
     @Override
-    public float score(float freq, long norm) throws IOException {
+    public float score(float freq, long norm) {
       // freq in bounds
       assert Float.isFinite(freq);
       assert freq > 0;
@@ -86,7 +84,7 @@ public class AssertingSimilarity extends Similarity {
     }
 
     @Override
-    public Explanation explain(Explanation freq, long norm) throws IOException {
+    public Explanation explain(Explanation freq, long norm) {
       // freq in bounds 
       assert freq != null;
       assert Float.isFinite(freq.getValue().floatValue());


Mime
View raw message