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-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