From 04f36b5f2c9f6ab72c9cea8b772606d03fbdb3a8 Mon Sep 17 00:00:00 2001 From: iverase Date: Wed, 27 Oct 2021 09:34:19 +0200 Subject: [PATCH] Delegate primitives in ByteArrayIndexInput --- .../lucene/store/ByteArrayIndexInput.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/server/src/main/java/org/elasticsearch/common/lucene/store/ByteArrayIndexInput.java b/server/src/main/java/org/elasticsearch/common/lucene/store/ByteArrayIndexInput.java index 3a03142d47219..5f855cf3ec4b6 100644 --- a/server/src/main/java/org/elasticsearch/common/lucene/store/ByteArrayIndexInput.java +++ b/server/src/main/java/org/elasticsearch/common/lucene/store/ByteArrayIndexInput.java @@ -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; @@ -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; + } + } }