uschindler commented on code in PR #13328:
URL: https://github.com/apache/lucene/pull/13328#discussion_r1588461460


##########
lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/GeneratingSuggester.java:
##########
@@ -447,14 +446,8 @@ private static int commonCharacterPositionScore(String s1, 
String s2) {
     return commonScore;
   }
 
-  private static class Weighted<T extends Comparable<T>> implements 
Comparable<Weighted<T>> {
-    final T word;
-    final int score;
-
-    Weighted(T word, int score) {
-      this.word = word;
-      this.score = score;
-    }
+  private record Weighted<T extends Comparable<T>>(T word, int score)
+      implements Comparable<Weighted<T>> {
 
     @Override
     public boolean equals(Object o) {

Review Comment:
   needs to be removed, too



##########
lucene/analysis/common/src/java/org/apache/lucene/analysis/synonym/word2vec/TermAndBoost.java:
##########
@@ -18,14 +18,13 @@
 
 import org.apache.lucene.util.BytesRef;
 
-/** Wraps a term and boost */
-public class TermAndBoost {
-  /** the term */
-  public final BytesRef term;
-
-  /** the boost */
-  public final float boost;
-
+/**
+ * Wraps a term and boost
+ *
+ * @param term the term
+ * @param boost the boost
+ */
+public record TermAndBoost(BytesRef term, float boost) {
   /** Creates a new TermAndBoost */
   public TermAndBoost(BytesRef term, float boost) {

Review Comment:
   this can be converted to the generic ctor without parameters:
   
   ```java
   public TermAndBoost {
     term = BytesRef.deepCopyOf(term);
   }
   ```



##########
lucene/core/src/java/org/apache/lucene/document/NearestNeighbor.java:
##########
@@ -34,20 +34,16 @@
 /** KNN search on top of 2D lat/lon indexed points. */
 class NearestNeighbor {
 
-  static class Cell implements Comparable<Cell> {
-    final int readerIndex;
-    final byte[] minPacked;
-    final byte[] maxPacked;
-    final PointTree index;
-
-    /**
-     * The closest distance from a point in this cell to the query point, 
computed as a sort key
-     * through {@link SloppyMath#haversinSortKey}. Note that this is an 
approximation to the closest
-     * distance, and there could be a point in the cell that is closer.
-     */
-    final double distanceSortKey;
-
-    public Cell(
+  /**
+   * @param distanceSortKey The closest distance from a point in this cell to 
the query point,
+   *     computed as a sort key through {@link SloppyMath#haversinSortKey}. 
Note that this is an
+   *     approximation to the closest distance, and there could be a point in 
the cell that is
+   *     closer.
+   */
+  record Cell(
+      PointTree index, int readerIndex, byte[] minPacked, byte[] maxPacked, 
double distanceSortKey)
+      implements Comparable<Cell> {
+    Cell(

Review Comment:
   remove that ctor and replace by default ctor and only copy minPacked and 
maxPacked (see above).



##########
lucene/codecs/src/java/org/apache/lucene/codecs/blocktreeords/FSTOrdsOutputs.java:
##########
@@ -68,16 +63,6 @@ public int hashCode() {
       hash = (int) (hash ^ endOrd);
       return hash;
     }
-

Review Comment:
   remove hashCode, too ^^



##########
lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/GeneratingSuggester.java:
##########
@@ -465,11 +458,6 @@ public boolean equals(Object o) {
       return score == that.score && word.equals(that.word);
     }
 
-    @Override
-    public int hashCode() {
-      return Objects.hash(word, score);
-    }
-
     @Override

Review Comment:
   let's keep that one, as the toString output is different from default



##########
lucene/codecs/src/java/org/apache/lucene/codecs/blocktreeords/OrdsBlockTreeTermsWriter.java:
##########
@@ -139,18 +139,17 @@ public final class OrdsBlockTreeTermsWriter extends 
FieldsConsumer {
   final PostingsWriterBase postingsWriter;
   final FieldInfos fieldInfos;
 
-  private static class FieldMetaData {
-    public final FieldInfo fieldInfo;
-    public final Output rootCode;
-    public final long numTerms;
-    public final long indexStartFP;
-    public final long sumTotalTermFreq;
-    public final long sumDocFreq;
-    public final int docCount;
-    public final BytesRef minTerm;
-    public final BytesRef maxTerm;
-
-    public FieldMetaData(
+  private record FieldMetaData(

Review Comment:
   make this the default ctor (see above and remove the field assignments), 
just keep asserts or other checks



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to