You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ch...@apache.org on 2025/01/09 16:24:40 UTC
(lucene) branch branch_10x updated: DirectIOIndexInput - add overloads for bulk retrieval (#14124)
This is an automated email from the ASF dual-hosted git repository.
chegar pushed a commit to branch branch_10x
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/branch_10x by this push:
new 18c187bfad6 DirectIOIndexInput - add overloads for bulk retrieval (#14124)
18c187bfad6 is described below
commit 18c187bfad65819b0d9bbf06027ddf930aad4915
Author: Chris Hegarty <62...@users.noreply.github.com>
AuthorDate: Thu Jan 9 16:23:18 2025 +0000
DirectIOIndexInput - add overloads for bulk retrieval (#14124)
This commit adds overloads for bulk retrieval to DirectIOIndexInput. The implementation of these methods is identical to that of BufferedIndexInput, and it already covered by existing tests.
---
.../lucene/misc/store/DirectIODirectory.java | 57 ++++++++++++++++++++++
1 file changed, 57 insertions(+)
diff --git a/lucene/misc/src/java/org/apache/lucene/misc/store/DirectIODirectory.java b/lucene/misc/src/java/org/apache/lucene/misc/store/DirectIODirectory.java
index 40d43e613a0..8b5f4fd76b7 100644
--- a/lucene/misc/src/java/org/apache/lucene/misc/store/DirectIODirectory.java
+++ b/lucene/misc/src/java/org/apache/lucene/misc/store/DirectIODirectory.java
@@ -463,6 +463,63 @@ public class DirectIODirectory extends FilterDirectory {
}
}
+ @Override
+ public void readInts(int[] dst, int offset, int len) throws IOException {
+ int remainingDst = len;
+ while (remainingDst > 0) {
+ int cnt = Math.min(buffer.remaining() / Integer.BYTES, remainingDst);
+ buffer.asIntBuffer().get(dst, offset + len - remainingDst, cnt);
+ buffer.position(buffer.position() + Integer.BYTES * cnt);
+ remainingDst -= cnt;
+ if (remainingDst > 0) {
+ if (buffer.hasRemaining()) {
+ dst[offset + len - remainingDst] = readInt();
+ --remainingDst;
+ } else {
+ refill(remainingDst * Integer.BYTES);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void readFloats(float[] dst, int offset, int len) throws IOException {
+ int remainingDst = len;
+ while (remainingDst > 0) {
+ int cnt = Math.min(buffer.remaining() / Float.BYTES, remainingDst);
+ buffer.asFloatBuffer().get(dst, offset + len - remainingDst, cnt);
+ buffer.position(buffer.position() + Float.BYTES * cnt);
+ remainingDst -= cnt;
+ if (remainingDst > 0) {
+ if (buffer.hasRemaining()) {
+ dst[offset + len - remainingDst] = Float.intBitsToFloat(readInt());
+ --remainingDst;
+ } else {
+ refill(remainingDst * Float.BYTES);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void readLongs(long[] dst, int offset, int len) throws IOException {
+ int remainingDst = len;
+ while (remainingDst > 0) {
+ int cnt = Math.min(buffer.remaining() / Long.BYTES, remainingDst);
+ buffer.asLongBuffer().get(dst, offset + len - remainingDst, cnt);
+ buffer.position(buffer.position() + Long.BYTES * cnt);
+ remainingDst -= cnt;
+ if (remainingDst > 0) {
+ if (buffer.hasRemaining()) {
+ dst[offset + len - remainingDst] = readLong();
+ --remainingDst;
+ } else {
+ refill(remainingDst * Long.BYTES);
+ }
+ }
+ }
+ }
+
@Override
public DirectIOIndexInput clone() {
try {