Skip to content

Commit

Permalink
Implement primitives reads in ByteArrayIndexInput (#79885)
Browse files Browse the repository at this point in the history
 enhance performance of those actions
  • Loading branch information
iverase authored Oct 27, 2021
1 parent 8f5069d commit 036f881
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package org.elasticsearch.common.lucene.store;

import org.apache.lucene.store.IndexInput;
import org.apache.lucene.util.BitUtil;

import java.io.EOFException;
import java.io.IOException;
Expand Down Expand Up @@ -85,4 +86,31 @@ public void readBytes(final byte[] b, final int offset, int len) throws IOExcept
System.arraycopy(bytes, this.offset + pos, b, offset, len);
pos += len;
}

@Override
public short readShort() throws IOException {
try {
return (short) BitUtil.VH_LE_SHORT.get(bytes, pos);
} finally {
pos += Short.BYTES;
}
}

@Override
public int readInt() throws IOException {
try {
return (int) BitUtil.VH_LE_INT.get(bytes, pos);
} finally {
pos += Integer.BYTES;
}
}

@Override
public long readLong() throws IOException {
try {
return (long) BitUtil.VH_LE_LONG.get(bytes, pos);
} finally {
pos += Long.BYTES;
}
}
}

0 comments on commit 036f881

Please sign in to comment.