LUCENE-10366: Override #readVInt and #readVLong for ByteBufferDataInput to avoid the abstraction confusion of #readByte. (#592)

This commit is contained in:
gf2121 2024-01-16 17:30:09 +08:00 committed by GitHub
parent c746bea233
commit ed7c78ce6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 51 additions and 1 deletions

View File

@ -205,6 +205,8 @@ Improvements
Optimizations
---------------------
* 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 for
DirectoryTaxonomyReader#getBulkOrdinals. (Stefan Vodita)

View File

@ -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();
}
@Override
public final long readLong() throws IOException {
try {

View File

@ -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();
}
@Override
public final long readLong() throws IOException {
try {

View File

@ -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();
}
@Override
public final long readLong() throws IOException {
try {

View File

@ -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();
}
@Override
public final long readLong() throws IOException {
try {