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 04:34:27 UTC
[lucene] branch main updated: Fix typos and minor refactoring to FacetConfig (#982)
This is an automated email from the ASF dual-hosted git repository.
shaie pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/main by this push:
new 9338909373a Fix typos and minor refactoring to FacetConfig (#982)
9338909373a is described below
commit 9338909373af3cae1eb3fb2cdb7672d005691967
Author: Shai Erera <se...@gmail.com>
AuthorDate: Mon Jun 27 07:34:21 2022 +0300
Fix typos and minor refactoring to FacetConfig (#982)
---
.../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 d92cf3d02cf..da52c049627 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
@@ -632,6 +622,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]);
}
}