You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by to...@apache.org on 2017/09/29 13:35:01 UTC

[1/2] lucene-solr:master: LUCENE-7981 - CTB should check that CR is not null

Repository: lucene-solr
Updated Branches:
  refs/heads/master f1bb91478 -> 97f246b4b


LUCENE-7981 - CTB should check that CR is not null


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

Branch: refs/heads/master
Commit: 97f246b4ba3f77f87751a374c587a2c84d3406ab
Parents: f9f6d3a
Author: Tommaso Teofili <to...@apache.org>
Authored: Fri Sep 29 15:34:43 2017 +0200
Committer: Tommaso Teofili <to...@apache.org>
Committed: Fri Sep 29 15:34:52 2017 +0200

----------------------------------------------------------------------
 .../org/apache/lucene/classification/ClassificationTestBase.java    | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/97f246b4/lucene/classification/src/test/org/apache/lucene/classification/ClassificationTestBase.java
----------------------------------------------------------------------
diff --git a/lucene/classification/src/test/org/apache/lucene/classification/ClassificationTestBase.java b/lucene/classification/src/test/org/apache/lucene/classification/ClassificationTestBase.java
index 6c8f7fd..b3220b0 100644
--- a/lucene/classification/src/test/org/apache/lucene/classification/ClassificationTestBase.java
+++ b/lucene/classification/src/test/org/apache/lucene/classification/ClassificationTestBase.java
@@ -88,6 +88,7 @@ public abstract class ClassificationTestBase<T> extends LuceneTestCase {
 
   protected ClassificationResult<T> checkCorrectClassification(Classifier<T> classifier, String inputDoc, T expectedResult) throws Exception {
     ClassificationResult<T> classificationResult = classifier.assignClass(inputDoc);
+    assertNotNull(classificationResult);
     T assignedClass = classificationResult.getAssignedClass();
     assertNotNull(assignedClass);
     assertEquals("got an assigned class of " + assignedClass, expectedResult instanceof BytesRef ? ((BytesRef) expectedResult).utf8ToString() : expectedResult, assignedClass instanceof BytesRef ? ((BytesRef) assignedClass).utf8ToString() : assignedClass);


[2/2] lucene-solr:master: no Jira - minor generics / code constructs fixes in MLT

Posted by to...@apache.org.
no Jira - minor generics / code constructs fixes in MLT


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

Branch: refs/heads/master
Commit: f9f6d3a3ac43be3a8bd09a5ff131f99e4b5df145
Parents: f1bb914
Author: Tommaso Teofili <to...@apache.org>
Authored: Fri Sep 29 15:32:27 2017 +0200
Committer: Tommaso Teofili <to...@apache.org>
Committed: Fri Sep 29 15:34:52 2017 +0200

----------------------------------------------------------------------
 .../org/apache/lucene/queries/mlt/MoreLikeThis.java | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/f9f6d3a3/lucene/queries/src/java/org/apache/lucene/queries/mlt/MoreLikeThis.java
----------------------------------------------------------------------
diff --git a/lucene/queries/src/java/org/apache/lucene/queries/mlt/MoreLikeThis.java b/lucene/queries/src/java/org/apache/lucene/queries/mlt/MoreLikeThis.java
index ea02af3..9afa687 100644
--- a/lucene/queries/src/java/org/apache/lucene/queries/mlt/MoreLikeThis.java
+++ b/lucene/queries/src/java/org/apache/lucene/queries/mlt/MoreLikeThis.java
@@ -782,11 +782,7 @@ public final class MoreLikeThis {
    * @param vector List of terms and their frequencies for a doc/field
    */
   private void addTermFrequencies(Map<String, Map<String, Int>> field2termFreqMap, Terms vector, String fieldName) throws IOException {
-    Map<String, Int> termFreqMap = field2termFreqMap.get(fieldName);
-    if (termFreqMap == null) {
-      termFreqMap = new HashMap<>();
-      field2termFreqMap.put(fieldName, termFreqMap);
-    }
+    Map<String, Int> termFreqMap = field2termFreqMap.computeIfAbsent(fieldName, k -> new HashMap<>());
     final TermsEnum termsEnum = vector.iterator();
     final CharsRefBuilder spare = new CharsRefBuilder();
     BytesRef text;
@@ -823,11 +819,7 @@ public final class MoreLikeThis {
       throw new UnsupportedOperationException("To use MoreLikeThis without " +
           "term vectors, you must provide an Analyzer");
     }
-    Map<String, Int> termFreqMap = perFieldTermFrequencies.get(fieldName);
-    if (termFreqMap == null) {
-      termFreqMap = new HashMap<>();
-      perFieldTermFrequencies.put(fieldName, termFreqMap);
-    }
+    Map<String, Int> termFreqMap = perFieldTermFrequencies.computeIfAbsent(fieldName, k -> new HashMap<>());
     try (TokenStream ts = analyzer.tokenStream(fieldName, r)) {
       int tokenCount = 0;
       // for every token
@@ -906,7 +898,7 @@ public final class MoreLikeThis {
    * @see #retrieveInterestingTerms(java.io.Reader, String)
    */
   public String[] retrieveInterestingTerms(int docNum) throws IOException {
-    ArrayList<Object> al = new ArrayList<>(maxQueryTerms);
+    ArrayList<String> al = new ArrayList<>(maxQueryTerms);
     PriorityQueue<ScoreTerm> pq = retrieveTerms(docNum);
     ScoreTerm scoreTerm;
     int lim = maxQueryTerms; // have to be careful, retrieveTerms returns all words but that's probably not useful to our caller...
@@ -929,7 +921,7 @@ public final class MoreLikeThis {
    * @see #setMaxQueryTerms
    */
   public String[] retrieveInterestingTerms(Reader r, String fieldName) throws IOException {
-    ArrayList<Object> al = new ArrayList<>(maxQueryTerms);
+    ArrayList<String> al = new ArrayList<>(maxQueryTerms);
     PriorityQueue<ScoreTerm> pq = retrieveTerms(r, fieldName);
     ScoreTerm scoreTerm;
     int lim = maxQueryTerms; // have to be careful, retrieveTerms returns all words but that's probably not useful to our caller...