You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2022/01/05 14:29:42 UTC

[lucene] branch branch_9x updated: LUCENE-10355: clean zeros (#584)

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

jpountz 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 3fda998  LUCENE-10355: clean zeros (#584)
3fda998 is described below

commit 3fda998fc742a0af571685175cb3ff052836dab7
Author: gf2121 <52...@users.noreply.github.com>
AuthorDate: Wed Jan 5 22:23:16 2022 +0800

    LUCENE-10355: clean zeros (#584)
---
 .../backward_codecs/packed/LegacyDirectMonotonicReader.java  | 12 +-----------
 .../org/apache/lucene/util/packed/DirectMonotonicReader.java | 12 +-----------
 2 files changed, 2 insertions(+), 22 deletions(-)

diff --git a/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/packed/LegacyDirectMonotonicReader.java b/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/packed/LegacyDirectMonotonicReader.java
index 4b942a4..724bad0 100644
--- a/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/packed/LegacyDirectMonotonicReader.java
+++ b/lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/packed/LegacyDirectMonotonicReader.java
@@ -34,16 +34,6 @@ public final class LegacyDirectMonotonicReader extends LongValues implements Acc
   private static final long BASE_RAM_BYTES_USED =
       RamUsageEstimator.shallowSizeOfInstance(LegacyDirectMonotonicReader.class);
 
-  /** An instance that always returns {@code 0}. */
-  private static final LongValues EMPTY =
-      new LongValues() {
-
-        @Override
-        public long get(long index) {
-          return 0;
-        }
-      };
-
   /**
    * In-memory metadata that needs to be kept around for {@link LegacyDirectMonotonicReader} to read
    * data from disk.
@@ -105,7 +95,7 @@ public final class LegacyDirectMonotonicReader extends LongValues implements Acc
     final LongValues[] readers = new LongValues[meta.numBlocks];
     for (int i = 0; i < meta.mins.length; ++i) {
       if (meta.bpvs[i] == 0) {
-        readers[i] = EMPTY;
+        readers[i] = LongValues.ZEROES;
       } else {
         readers[i] = LegacyDirectReader.getInstance(data, meta.bpvs[i], meta.offsets[i]);
       }
diff --git a/lucene/core/src/java/org/apache/lucene/util/packed/DirectMonotonicReader.java b/lucene/core/src/java/org/apache/lucene/util/packed/DirectMonotonicReader.java
index 884c664..1f5954e 100644
--- a/lucene/core/src/java/org/apache/lucene/util/packed/DirectMonotonicReader.java
+++ b/lucene/core/src/java/org/apache/lucene/util/packed/DirectMonotonicReader.java
@@ -34,16 +34,6 @@ public final class DirectMonotonicReader extends LongValues implements Accountab
   private static final long BASE_RAM_BYTES_USED =
       RamUsageEstimator.shallowSizeOfInstance(DirectMonotonicReader.class);
 
-  /** An instance that always returns {@code 0}. */
-  private static final LongValues EMPTY =
-      new LongValues() {
-
-        @Override
-        public long get(long index) {
-          return 0;
-        }
-      };
-
   /**
    * In-memory metadata that needs to be kept around for {@link DirectMonotonicReader} to read data
    * from disk.
@@ -111,7 +101,7 @@ public final class DirectMonotonicReader extends LongValues implements Accountab
     final LongValues[] readers = new LongValues[meta.numBlocks];
     for (int i = 0; i < meta.numBlocks; ++i) {
       if (meta.bpvs[i] == 0) {
-        readers[i] = EMPTY;
+        readers[i] = LongValues.ZEROES;
       } else if (merging
           && i < meta.numBlocks - 1 // we only know the number of values for the last block
           && meta.blockShift >= DirectReader.MERGE_BUFFER_SHIFT) {