You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2022/06/27 05:04:34 UTC

[lucene] branch branch_9x updated: Fix typos and minor refactoring to FacetConfig (#982) (#985)

This is an automated email from the ASF dual-hosted git repository.

shaie pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/branch_9x by this push:
     new 6d3ab787163 Fix typos and minor refactoring to FacetConfig (#982) (#985)
6d3ab787163 is described below

commit 6d3ab787163f537ed8d1ebe9f17d8c1151ff8e73
Author: Shai Erera <se...@gmail.com>
AuthorDate: Mon Jun 27 08:04:28 2022 +0300

    Fix typos and minor refactoring to FacetConfig (#982) (#985)
---
 .../java/org/apache/lucene/search/Scorable.java    |  4 ++--
 .../apache/lucene/search/TopFieldCollector.java    |  2 +-
 .../java/org/apache/lucene/facet/FacetsConfig.java | 24 +++++++---------------
 3 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/lucene/core/src/java/org/apache/lucene/search/Scorable.java b/lucene/core/src/java/org/apache/lucene/search/Scorable.java
index 801dcc873d2..075d8be079c 100644
--- a/lucene/core/src/java/org/apache/lucene/search/Scorable.java
+++ b/lucene/core/src/java/org/apache/lucene/search/Scorable.java
@@ -66,7 +66,7 @@ public abstract class Scorable {
   }
 
   /**
-   * A child Scorer and its relationship to its parent. the meaning of the relationship depends upon
+   * A child Scorer and its relationship to its parent. The meaning of the relationship depends upon
    * the parent query.
    *
    * @lucene.experimental
@@ -80,7 +80,7 @@ public abstract class Scorable {
     /**
      * Creates a new ChildScorer node with the specified relationship.
      *
-     * <p>The relationship can be any be any string that makes sense to the parent Scorer.
+     * <p>The relationship can be any string that makes sense to the parent Scorer.
      */
     public ChildScorable(Scorable child, String relationship) {
       this.child = child;
diff --git a/lucene/core/src/java/org/apache/lucene/search/TopFieldCollector.java b/lucene/core/src/java/org/apache/lucene/search/TopFieldCollector.java
index 2ecb5e08694..02e5bae87ce 100644
--- a/lucene/core/src/java/org/apache/lucene/search/TopFieldCollector.java
+++ b/lucene/core/src/java/org/apache/lucene/search/TopFieldCollector.java
@@ -91,7 +91,7 @@ public abstract class TopFieldCollector extends TopDocsCollector<Entry> {
     boolean thresholdCheck(int doc) throws IOException {
       if (collectedAllCompetitiveHits || reverseMul * comparator.compareBottom(doc) <= 0) {
         // since docs are visited in doc Id order, if compare is 0, it means
-        // this document is largest than anything else in the queue, and
+        // this document is larger than anything else in the queue, and
         // therefore not competitive.
         if (searchSortPartOfIndexSort) {
           if (hitsThresholdChecker.isThresholdReached()) {
diff --git a/lucene/facet/src/java/org/apache/lucene/facet/FacetsConfig.java b/lucene/facet/src/java/org/apache/lucene/facet/FacetsConfig.java
index 603044a5df8..00256b398b7 100644
--- a/lucene/facet/src/java/org/apache/lucene/facet/FacetsConfig.java
+++ b/lucene/facet/src/java/org/apache/lucene/facet/FacetsConfig.java
@@ -276,11 +276,7 @@ public class FacetsConfig {
           checkSeen(seenDims, facetField.dim);
         }
         String indexFieldName = dimConfig.indexFieldName;
-        List<FacetField> fields = byField.get(indexFieldName);
-        if (fields == null) {
-          fields = new ArrayList<>();
-          byField.put(indexFieldName, fields);
-        }
+        List<FacetField> fields = byField.computeIfAbsent(indexFieldName, k -> new ArrayList<>());
         fields.add(facetField);
       }
 
@@ -291,11 +287,8 @@ public class FacetsConfig {
           checkSeen(seenDims, facetField.dim);
         }
         String indexFieldName = dimConfig.indexFieldName;
-        List<SortedSetDocValuesFacetField> fields = dvByField.get(indexFieldName);
-        if (fields == null) {
-          fields = new ArrayList<>();
-          dvByField.put(indexFieldName, fields);
-        }
+        List<SortedSetDocValuesFacetField> fields =
+            dvByField.computeIfAbsent(indexFieldName, k -> new ArrayList<>());
         fields.add(facetField);
       }
 
@@ -315,11 +308,8 @@ public class FacetsConfig {
         }
 
         String indexFieldName = dimConfig.indexFieldName;
-        List<AssociationFacetField> fields = assocByField.get(indexFieldName);
-        if (fields == null) {
-          fields = new ArrayList<>();
-          assocByField.put(indexFieldName, fields);
-        }
+        List<AssociationFacetField> fields =
+            assocByField.computeIfAbsent(indexFieldName, k -> new ArrayList<>());
         fields.add(facetField);
 
         // Best effort: detect mis-matched types in same
@@ -338,7 +328,7 @@ public class FacetsConfig {
           assocDimTypes.put(indexFieldName, type);
         } else if (!curType.equals(type)) {
           throw new IllegalArgumentException(
-              "mixing incompatible types of AssocationFacetField ("
+              "mixing incompatible types of AssociationFacetField ("
                   + curType
                   + " and "
                   + type
@@ -693,6 +683,6 @@ public class FacetsConfig {
     }
     parts.add(new String(buffer, 0, upto));
     assert !lastEscape;
-    return parts.toArray(new String[parts.size()]);
+    return parts.toArray(new String[0]);
   }
 }