You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2022/02/14 07:54:47 UTC

[GitHub] [lucene] spike-liu opened a new pull request #678: LUCENE-10398: Add static method for getting Terms from LeafReader

spike-liu opened a new pull request #678:
URL: https://github.com/apache/lucene/pull/678


   https://issues.apache.org/jira/browse/LUCENE-10398


-- 
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-unsubscribe@lucene.apache.org

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



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


[GitHub] [lucene] spike-liu commented on a change in pull request #678: LUCENE-10398: Add static method for getting Terms from LeafReader

Posted by GitBox <gi...@apache.org>.
spike-liu commented on a change in pull request #678:
URL: https://github.com/apache/lucene/pull/678#discussion_r809637709



##########
File path: lucene/core/src/java/org/apache/lucene/document/FeatureQuery.java
##########
@@ -111,12 +111,9 @@ public Explanation explain(LeafReaderContext context, int doc) throws IOExceptio
 
       @Override
       public Scorer scorer(LeafReaderContext context) throws IOException {
-        Terms terms = context.reader().terms(fieldName);
-        if (terms == null) {
-          return null;
-        }
+        Terms terms = Terms.terms(context.reader(), fieldName);
         TermsEnum termsEnum = terms.iterator();
-        if (termsEnum.seekExact(new BytesRef(featureName)) == false) {
+        if (!termsEnum.seekExact(new BytesRef(featureName))) {

Review comment:
       Gotcha.




-- 
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-unsubscribe@lucene.apache.org

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



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


[GitHub] [lucene] spike-liu edited a comment on pull request #678: LUCENE-10398: Add static method for getting Terms from LeafReader

Posted by GitBox <gi...@apache.org>.
spike-liu edited a comment on pull request #678:
URL: https://github.com/apache/lucene/pull/678#issuecomment-1043674843


   > Going ahead and merging this now since there's been no opposition (of course it could always be backed out later if someone did take strong issue with this). Thanks again @spike-liu !
   
   It is my pleasure, Greg.
   
   Really appreciate your note of force pushing changes, which would save me a lot of time.


-- 
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-unsubscribe@lucene.apache.org

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



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


[GitHub] [lucene] gsmiller commented on pull request #678: LUCENE-10398: Add static method for getting Terms from LeafReader

Posted by GitBox <gi...@apache.org>.
gsmiller commented on pull request #678:
URL: https://github.com/apache/lucene/pull/678#issuecomment-1043211273


   Going ahead and merging this now since there's been no opposition (of course it could always be backed out later if someone did take strong issue with this). Thanks again @spike-liu !


-- 
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-unsubscribe@lucene.apache.org

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



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


[GitHub] [lucene] gsmiller commented on a change in pull request #678: LUCENE-10398: Add static method for getting Terms from LeafReader

Posted by GitBox <gi...@apache.org>.
gsmiller commented on a change in pull request #678:
URL: https://github.com/apache/lucene/pull/678#discussion_r807228024



##########
File path: lucene/core/src/java/org/apache/lucene/index/Terms.java
##########
@@ -124,6 +124,69 @@ protected BytesRef nextSeekTerm(BytesRef term) throws IOException {
   /** Zero-length array of {@link Terms}. */
   public static final Terms[] EMPTY_ARRAY = new Terms[0];
 
+  /** An empty {@link Terms} which returns no terms */
+  public static Terms emptyTerms() {

Review comment:
       What about defining this once and exposing it through a static variable much like `TermsEnum.EMPTY` (e.g., `Terms.EMPTY`)? This looks perfectly safe to share/reuse to me, so we can avoid the overhead of instantiating over-and-over.

##########
File path: lucene/core/src/java/org/apache/lucene/document/FeatureQuery.java
##########
@@ -111,12 +111,9 @@ public Explanation explain(LeafReaderContext context, int doc) throws IOExceptio
 
       @Override
       public Scorer scorer(LeafReaderContext context) throws IOException {
-        Terms terms = context.reader().terms(fieldName);
-        if (terms == null) {
-          return null;
-        }
+        Terms terms = Terms.terms(context.reader(), fieldName);
         TermsEnum termsEnum = terms.iterator();
-        if (termsEnum.seekExact(new BytesRef(featureName)) == false) {
+        if (!termsEnum.seekExact(new BytesRef(featureName))) {

Review comment:
       As a best-practice, we prefer using `== false` instead of `!` syntax in this code base. Can you please retain this style? Thanks!

##########
File path: lucene/core/src/java/org/apache/lucene/search/TermInSetQuery.java
##########
@@ -244,8 +244,8 @@ public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float bo
 
       @Override
       public Matches matches(LeafReaderContext context, int doc) throws IOException {
-        Terms terms = context.reader().terms(field);
-        if (terms == null || terms.hasPositions() == false) {
+        Terms terms = Terms.terms(context.reader(), field);
+        if (!terms.hasPositions()) {

Review comment:
       minor: Another place to use `== false` instead of `!` please

##########
File path: lucene/core/src/java/org/apache/lucene/index/Terms.java
##########
@@ -124,6 +124,69 @@ protected BytesRef nextSeekTerm(BytesRef term) throws IOException {
   /** Zero-length array of {@link Terms}. */
   public static final Terms[] EMPTY_ARRAY = new Terms[0];
 
+  /** An empty {@link Terms} which returns no terms */
+  public static Terms emptyTerms() {

Review comment:
       Also, since we don't actually need this outside of the `Terms` class right now, I think I'd also prefer we make access `private`. We can always open up access if a use-case demands it.

##########
File path: lucene/queries/src/java/org/apache/lucene/queries/function/IndexReaderFunctions.java
##########
@@ -212,10 +212,10 @@ private TermFreqDoubleValuesSource(Term term) {
 
     @Override
     public DoubleValues getValues(LeafReaderContext ctx, DoubleValues scores) throws IOException {
-      Terms terms = ctx.reader().terms(term.field());
-      TermsEnum te = terms == null ? null : terms.iterator();
+      Terms terms = Terms.terms(ctx.reader(), term.field());
+      TermsEnum te = terms.iterator();
 
-      if (te == null || te.seekExact(term.bytes()) == false) {
+      if (!te.seekExact(term.bytes())) {

Review comment:
       minor: Just another place to use `== false` instead of `!` please.

##########
File path: lucene/core/src/java/org/apache/lucene/index/Terms.java
##########
@@ -124,6 +124,69 @@ protected BytesRef nextSeekTerm(BytesRef term) throws IOException {
   /** Zero-length array of {@link Terms}. */
   public static final Terms[] EMPTY_ARRAY = new Terms[0];
 
+  /** An empty {@link Terms} which returns no terms */
+  public static Terms emptyTerms() {
+    return new Terms() {
+      @Override
+      public TermsEnum iterator() throws IOException {
+        return TermsEnum.EMPTY;
+      }
+
+      @Override
+      public long size() throws IOException {
+        return 0;
+      }
+
+      @Override
+      public long getSumTotalTermFreq() throws IOException {
+        return 0;
+      }
+
+      @Override
+      public long getSumDocFreq() throws IOException {
+        return 0;
+      }
+
+      @Override
+      public int getDocCount() throws IOException {
+        return 0;
+      }
+
+      @Override
+      public boolean hasFreqs() {
+        return false;
+      }
+
+      @Override
+      public boolean hasOffsets() {
+        return false;
+      }
+
+      @Override
+      public boolean hasPositions() {
+        return false;
+      }
+
+      @Override
+      public boolean hasPayloads() {
+        return false;
+      }
+    };
+  }
+
+  /**
+   * Returns the {@link Terms} index for this field, or {@link #emptyTerms} if it has none.
+   * @return terms instance, or an empty instance if {@code field} does not exist in this reader
+   * @throws IOException if an I/O error occurs.
+   */
+  public static Terms terms(LeafReader reader, String field) throws IOException {

Review comment:
       What about a name like `getTerms`? That's a bit more consistent with how `DocValues` names its static factory methods (e.g., `getNumeric`).
   
   minor: Also, could you move this right under the constructor or to the very bottom so it's not right in the middle of the instance methods? I'd prefer putting it at the top but don't feel super strongly about that.




-- 
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-unsubscribe@lucene.apache.org

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



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


[GitHub] [lucene] gsmiller commented on a change in pull request #678: LUCENE-10398: Add static method for getting Terms from LeafReader

Posted by GitBox <gi...@apache.org>.
gsmiller commented on a change in pull request #678:
URL: https://github.com/apache/lucene/pull/678#discussion_r807375030



##########
File path: lucene/core/src/java/org/apache/lucene/index/Terms.java
##########
@@ -124,6 +124,69 @@ protected BytesRef nextSeekTerm(BytesRef term) throws IOException {
   /** Zero-length array of {@link Terms}. */
   public static final Terms[] EMPTY_ARRAY = new Terms[0];
 
+  /** An empty {@link Terms} which returns no terms */
+  public static Terms emptyTerms() {
+    return new Terms() {
+      @Override
+      public TermsEnum iterator() throws IOException {
+        return TermsEnum.EMPTY;
+      }
+
+      @Override
+      public long size() throws IOException {
+        return 0;
+      }
+
+      @Override
+      public long getSumTotalTermFreq() throws IOException {
+        return 0;
+      }
+
+      @Override
+      public long getSumDocFreq() throws IOException {
+        return 0;
+      }
+
+      @Override
+      public int getDocCount() throws IOException {
+        return 0;
+      }
+
+      @Override
+      public boolean hasFreqs() {
+        return false;
+      }
+
+      @Override
+      public boolean hasOffsets() {
+        return false;
+      }
+
+      @Override
+      public boolean hasPositions() {
+        return false;
+      }
+
+      @Override
+      public boolean hasPayloads() {
+        return false;
+      }
+    };
+  }
+
+  /**
+   * Returns the {@link Terms} index for this field, or {@link #emptyTerms} if it has none.
+   * @return terms instance, or an empty instance if {@code field} does not exist in this reader

Review comment:
       FYI: spotless is complaining about this javadoc formatting (that's why `./gradlew check` is failing). You should be able to run `./gradlew spotlessApply` to fix this automatically.




-- 
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-unsubscribe@lucene.apache.org

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



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


[GitHub] [lucene] gsmiller commented on pull request #678: LUCENE-10398: Add static method for getting Terms from LeafReader

Posted by GitBox <gi...@apache.org>.
gsmiller commented on pull request #678:
URL: https://github.com/apache/lucene/pull/678#issuecomment-1041899789


   Thanks for the quick iteration! This looks good to me now. As I mentioned before, I'm going to wait a couple days before merging in case anyone else wants to chime in with feedback or opposition to adding this functionality, but I'd consider this ready to go from my perspective.
   
   As a side note, in the future, it makes it a little easier to review if you avoid force pushing changes and leave the git commit history in place. That way I can easily look at what's changed since I last reviewed. I know a lot of people are in the habit of squashing commit history to keep it clean, but github makes that super easy to do when actually merging your pull request, so no need to do that on your side. Just a future note.
   
   Thanks again!


-- 
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-unsubscribe@lucene.apache.org

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



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


[GitHub] [lucene] spike-liu commented on a change in pull request #678: LUCENE-10398: Add static method for getting Terms from LeafReader

Posted by GitBox <gi...@apache.org>.
spike-liu commented on a change in pull request #678:
URL: https://github.com/apache/lucene/pull/678#discussion_r807560361



##########
File path: lucene/core/src/java/org/apache/lucene/index/Terms.java
##########
@@ -124,6 +124,69 @@ protected BytesRef nextSeekTerm(BytesRef term) throws IOException {
   /** Zero-length array of {@link Terms}. */
   public static final Terms[] EMPTY_ARRAY = new Terms[0];
 
+  /** An empty {@link Terms} which returns no terms */
+  public static Terms emptyTerms() {

Review comment:
       Thanks for your review, Greg. Fixed.




-- 
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-unsubscribe@lucene.apache.org

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



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


[GitHub] [lucene] spike-liu commented on pull request #678: LUCENE-10398: Add static method for getting Terms from LeafReader

Posted by GitBox <gi...@apache.org>.
spike-liu commented on pull request #678:
URL: https://github.com/apache/lucene/pull/678#issuecomment-1043674843


   > Going ahead and merging this now since there's been no opposition (of course it could always be backed out later if someone did take strong issue with this). Thanks again @spike-liu !
   
   It is my pleasure, Greg.


-- 
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-unsubscribe@lucene.apache.org

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



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


[GitHub] [lucene] spike-liu commented on a change in pull request #678: LUCENE-10398: Add static method for getting Terms from LeafReader

Posted by GitBox <gi...@apache.org>.
spike-liu commented on a change in pull request #678:
URL: https://github.com/apache/lucene/pull/678#discussion_r807570862



##########
File path: lucene/core/src/java/org/apache/lucene/index/Terms.java
##########
@@ -124,6 +124,69 @@ protected BytesRef nextSeekTerm(BytesRef term) throws IOException {
   /** Zero-length array of {@link Terms}. */
   public static final Terms[] EMPTY_ARRAY = new Terms[0];
 
+  /** An empty {@link Terms} which returns no terms */
+  public static Terms emptyTerms() {
+    return new Terms() {
+      @Override
+      public TermsEnum iterator() throws IOException {
+        return TermsEnum.EMPTY;
+      }
+
+      @Override
+      public long size() throws IOException {
+        return 0;
+      }
+
+      @Override
+      public long getSumTotalTermFreq() throws IOException {
+        return 0;
+      }
+
+      @Override
+      public long getSumDocFreq() throws IOException {
+        return 0;
+      }
+
+      @Override
+      public int getDocCount() throws IOException {
+        return 0;
+      }
+
+      @Override
+      public boolean hasFreqs() {
+        return false;
+      }
+
+      @Override
+      public boolean hasOffsets() {
+        return false;
+      }
+
+      @Override
+      public boolean hasPositions() {
+        return false;
+      }
+
+      @Override
+      public boolean hasPayloads() {
+        return false;
+      }
+    };
+  }
+
+  /**
+   * Returns the {@link Terms} index for this field, or {@link #emptyTerms} if it has none.
+   * @return terms instance, or an empty instance if {@code field} does not exist in this reader

Review comment:
       Thanks for your kindly instruction. Fixed.




-- 
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-unsubscribe@lucene.apache.org

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



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


[GitHub] [lucene] gsmiller merged pull request #678: LUCENE-10398: Add static method for getting Terms from LeafReader

Posted by GitBox <gi...@apache.org>.
gsmiller merged pull request #678:
URL: https://github.com/apache/lucene/pull/678


   


-- 
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-unsubscribe@lucene.apache.org

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



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


[GitHub] [lucene] gsmiller commented on a change in pull request #678: LUCENE-10398: Add static method for getting Terms from LeafReader

Posted by GitBox <gi...@apache.org>.
gsmiller commented on a change in pull request #678:
URL: https://github.com/apache/lucene/pull/678#discussion_r808256634



##########
File path: lucene/core/src/java/org/apache/lucene/document/FeatureQuery.java
##########
@@ -111,12 +111,9 @@ public Explanation explain(LeafReaderContext context, int doc) throws IOExceptio
 
       @Override
       public Scorer scorer(LeafReaderContext context) throws IOException {
-        Terms terms = context.reader().terms(fieldName);
-        if (terms == null) {
-          return null;
-        }
+        Terms terms = Terms.terms(context.reader(), fieldName);
         TermsEnum termsEnum = terms.iterator();
-        if (termsEnum.seekExact(new BytesRef(featureName)) == false) {
+        if (!termsEnum.seekExact(new BytesRef(featureName))) {

Review comment:
       As a side note, in case it's helpful, I know with IntelliJ at least you can disable the suggestion it likes to give to convert all these `== false` occurrences to `!` if that irritates you :)




-- 
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-unsubscribe@lucene.apache.org

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



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


[GitHub] [lucene] spike-liu commented on a change in pull request #678: LUCENE-10398: Add static method for getting Terms from LeafReader

Posted by GitBox <gi...@apache.org>.
spike-liu commented on a change in pull request #678:
URL: https://github.com/apache/lucene/pull/678#discussion_r807561536



##########
File path: lucene/core/src/java/org/apache/lucene/search/TermInSetQuery.java
##########
@@ -244,8 +244,8 @@ public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float bo
 
       @Override
       public Matches matches(LeafReaderContext context, int doc) throws IOException {
-        Terms terms = context.reader().terms(field);
-        if (terms == null || terms.hasPositions() == false) {
+        Terms terms = Terms.terms(context.reader(), field);
+        if (!terms.hasPositions()) {

Review comment:
       fixed.




-- 
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-unsubscribe@lucene.apache.org

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



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


[GitHub] [lucene] spike-liu commented on a change in pull request #678: LUCENE-10398: Add static method for getting Terms from LeafReader

Posted by GitBox <gi...@apache.org>.
spike-liu commented on a change in pull request #678:
URL: https://github.com/apache/lucene/pull/678#discussion_r807563855



##########
File path: lucene/core/src/java/org/apache/lucene/index/Terms.java
##########
@@ -124,6 +124,69 @@ protected BytesRef nextSeekTerm(BytesRef term) throws IOException {
   /** Zero-length array of {@link Terms}. */
   public static final Terms[] EMPTY_ARRAY = new Terms[0];
 
+  /** An empty {@link Terms} which returns no terms */
+  public static Terms emptyTerms() {
+    return new Terms() {
+      @Override
+      public TermsEnum iterator() throws IOException {
+        return TermsEnum.EMPTY;
+      }
+
+      @Override
+      public long size() throws IOException {
+        return 0;
+      }
+
+      @Override
+      public long getSumTotalTermFreq() throws IOException {
+        return 0;
+      }
+
+      @Override
+      public long getSumDocFreq() throws IOException {
+        return 0;
+      }
+
+      @Override
+      public int getDocCount() throws IOException {
+        return 0;
+      }
+
+      @Override
+      public boolean hasFreqs() {
+        return false;
+      }
+
+      @Override
+      public boolean hasOffsets() {
+        return false;
+      }
+
+      @Override
+      public boolean hasPositions() {
+        return false;
+      }
+
+      @Override
+      public boolean hasPayloads() {
+        return false;
+      }
+    };
+  }
+
+  /**
+   * Returns the {@link Terms} index for this field, or {@link #emptyTerms} if it has none.
+   * @return terms instance, or an empty instance if {@code field} does not exist in this reader
+   * @throws IOException if an I/O error occurs.
+   */
+  public static Terms terms(LeafReader reader, String field) throws IOException {

Review comment:
       fixed.




-- 
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-unsubscribe@lucene.apache.org

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



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


[GitHub] [lucene] spike-liu commented on a change in pull request #678: LUCENE-10398: Add static method for getting Terms from LeafReader

Posted by GitBox <gi...@apache.org>.
spike-liu commented on a change in pull request #678:
URL: https://github.com/apache/lucene/pull/678#discussion_r807561090



##########
File path: lucene/core/src/java/org/apache/lucene/document/FeatureQuery.java
##########
@@ -111,12 +111,9 @@ public Explanation explain(LeafReaderContext context, int doc) throws IOExceptio
 
       @Override
       public Scorer scorer(LeafReaderContext context) throws IOException {
-        Terms terms = context.reader().terms(fieldName);
-        if (terms == null) {
-          return null;
-        }
+        Terms terms = Terms.terms(context.reader(), fieldName);
         TermsEnum termsEnum = terms.iterator();
-        if (termsEnum.seekExact(new BytesRef(featureName)) == false) {
+        if (!termsEnum.seekExact(new BytesRef(featureName))) {

Review comment:
       Absolutely. Fixed.




-- 
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-unsubscribe@lucene.apache.org

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



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


[GitHub] [lucene] spike-liu commented on a change in pull request #678: LUCENE-10398: Add static method for getting Terms from LeafReader

Posted by GitBox <gi...@apache.org>.
spike-liu commented on a change in pull request #678:
URL: https://github.com/apache/lucene/pull/678#discussion_r807561320



##########
File path: lucene/queries/src/java/org/apache/lucene/queries/function/IndexReaderFunctions.java
##########
@@ -212,10 +212,10 @@ private TermFreqDoubleValuesSource(Term term) {
 
     @Override
     public DoubleValues getValues(LeafReaderContext ctx, DoubleValues scores) throws IOException {
-      Terms terms = ctx.reader().terms(term.field());
-      TermsEnum te = terms == null ? null : terms.iterator();
+      Terms terms = Terms.terms(ctx.reader(), term.field());
+      TermsEnum te = terms.iterator();
 
-      if (te == null || te.seekExact(term.bytes()) == false) {
+      if (!te.seekExact(term.bytes())) {

Review comment:
       fixed.




-- 
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-unsubscribe@lucene.apache.org

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



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