Apache Lucene open-source search software
LUCENE-10366: Override #readVInt and #readVLong for ByteBufferDataInput to avoid the abstraction confusion of #readByte. (#592)
gf2121ed7c78ce6d90
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 46c1a42679f..89edb6e5b90 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -205,6 +205,8 @@ ImprovementsOptimizations---------------------+* LUCENE-10366: Override readVInt() and readVLong() in ByteBufferDataInput to help Hotspot inline method. (Guo Feng)+* GITHUB#12839: Introduce method to grow arrays up to a given upper limit and use it to reduce overallocation forDirectoryTaxonomyReader#getBulkOrdinals. (Stefan Vodita)diff --git a/lucene/core/src/java/org/apache/lucene/store/ByteBufferIndexInput.java b/lucene/core/src/java/org/apache/lucene/store/ByteBufferIndexInput.javaindex 77840df9ed6..6d6040bd437 100644--- a/lucene/core/src/java/org/apache/lucene/store/ByteBufferIndexInput.java+++ b/lucene/core/src/java/org/apache/lucene/store/ByteBufferIndexInput.java@@ -159,7 +159,7 @@ public abstract class ByteBufferIndexInput extends IndexInput implements RandomA}@Override- public void readLongs(long[] dst, int offset, int length) throws IOException {+ public final void readLongs(long[] dst, int offset, int length) throws IOException {// ByteBuffer#getLong could work but it has some per-long overhead and there// is no ByteBuffer#getLongs to read multiple longs at once. So we use the// below trick in order to be able to leverage LongBuffer#get(long[]) to@@ -283,6 +283,18 @@ public abstract class ByteBufferIndexInput extends IndexInput implements RandomA}}+ @Override+ public final int readVInt() throws IOException {+ // this can make JVM less confused (see LUCENE-10366)+ return super.readVInt();+ }++ @Override+ public final long readVLong() throws IOException {+ // this can make JVM less confused (see LUCENE-10366)+ return super.readVLong();+ }+@Overridepublic final long readLong() throws IOException {try {diff --git a/lucene/core/src/java19/org/apache/lucene/store/MemorySegmentIndexInput.java b/lucene/core/src/java19/org/apache/lucene/store/MemorySegmentIndexInput.javaindex 72c7d69a1f2..ff2ab999319 100644--- a/lucene/core/src/java19/org/apache/lucene/store/MemorySegmentIndexInput.java+++ b/lucene/core/src/java19/org/apache/lucene/store/MemorySegmentIndexInput.java@@ -254,6 +254,18 @@ abstract class MemorySegmentIndexInput extends IndexInput implements RandomAcces}}+ @Override+ public final int readVInt() throws IOException {+ // this can make JVM less confused (see LUCENE-10366)+ return super.readVInt();+ }++ @Override+ public final long readVLong() throws IOException {+ // this can make JVM less confused (see LUCENE-10366)+ return super.readVLong();+ }+@Overridepublic final long readLong() throws IOException {try {diff --git a/lucene/core/src/java20/org/apache/lucene/store/MemorySegmentIndexInput.java b/lucene/core/src/java20/org/apache/lucene/store/MemorySegmentIndexInput.javaindex c8eec75249d..ba890d8056c 100644--- a/lucene/core/src/java20/org/apache/lucene/store/MemorySegmentIndexInput.java+++ b/lucene/core/src/java20/org/apache/lucene/store/MemorySegmentIndexInput.java@@ -252,6 +252,18 @@ abstract class MemorySegmentIndexInput extends IndexInput implements RandomAcces}}+ @Override+ public final int readVInt() throws IOException {+ // this can make JVM less confused (see LUCENE-10366)+ return super.readVInt();+ }++ @Override+ public final long readVLong() throws IOException {+ // this can make JVM less confused (see LUCENE-10366)+ return super.readVLong();+ }+@Overridepublic final long readLong() throws IOException {try {diff --git a/lucene/core/src/java21/org/apache/lucene/store/MemorySegmentIndexInput.java b/lucene/core/src/java21/org/apache/lucene/store/MemorySegmentIndexInput.javaindex c8eec75249d..ba890d8056c 100644--- a/lucene/core/src/java21/org/apache/lucene/store/MemorySegmentIndexInput.java+++ b/lucene/core/src/java21/org/apache/lucene/store/MemorySegmentIndexInput.java@@ -252,6 +252,18 @@ abstract class MemorySegmentIndexInput extends IndexInput implements RandomAcces}}+ @Override+ public final int readVInt() throws IOException {+ // this can make JVM less confused (see LUCENE-10366)+ return super.readVInt();+ }++ @Override+ public final long readVLong() throws IOException {+ // this can make JVM less confused (see LUCENE-10366)+ return super.readVLong();+ }+@Overridepublic final long readLong() throws IOException {try {