You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ab...@apache.org on 2024/10/21 13:20:19 UTC
(lucene) branch branch_10x updated: Use RandomAccessInput instead of seeking in Lucene90DocValuesProducer (#13894)
This is an automated email from the ASF dual-hosted git repository.
abr 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 750d53c4d3c Use RandomAccessInput instead of seeking in Lucene90DocValuesProducer (#13894)
750d53c4d3c is described below
commit 750d53c4d3c5adc6750936adffcebc059f4975ee
Author: Armin Braun <me...@obrown.io>
AuthorDate: Sat Oct 12 10:31:51 2024 +0200
Use RandomAccessInput instead of seeking in Lucene90DocValuesProducer (#13894)
We use manual seeking and reading instead of random access in this class.
That seems just unnecessarily complicated.
---
.../codecs/lucene90/Lucene90DocValuesProducer.java | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90DocValuesProducer.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90DocValuesProducer.java
index f5d47966cad..da027a35f17 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90DocValuesProducer.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90DocValuesProducer.java
@@ -792,7 +792,7 @@ final class Lucene90DocValuesProducer extends DocValuesProducer {
return DocValues.emptyBinary();
}
- final IndexInput bytesSlice = data.slice("fixed-binary", entry.dataOffset, entry.dataLength);
+ final RandomAccessInput bytesSlice = data.randomAccessSlice(entry.dataOffset, entry.dataLength);
// Prefetch the first page of data. Following pages are expected to get prefetched through
// read-ahead.
if (bytesSlice.length() > 0) {
@@ -809,8 +809,7 @@ final class Lucene90DocValuesProducer extends DocValuesProducer {
@Override
public BytesRef binaryValue() throws IOException {
- bytesSlice.seek((long) doc * length);
- bytesSlice.readBytes(bytes.bytes, 0, length);
+ bytesSlice.readBytes((long) doc * length, bytes.bytes, 0, length);
return bytes;
}
};
@@ -832,8 +831,7 @@ final class Lucene90DocValuesProducer extends DocValuesProducer {
public BytesRef binaryValue() throws IOException {
long startOffset = addresses.get(doc);
bytes.length = (int) (addresses.get(doc + 1L) - startOffset);
- bytesSlice.seek(startOffset);
- bytesSlice.readBytes(bytes.bytes, 0, bytes.length);
+ bytesSlice.readBytes(startOffset, bytes.bytes, 0, bytes.length);
return bytes;
}
};
@@ -856,8 +854,7 @@ final class Lucene90DocValuesProducer extends DocValuesProducer {
@Override
public BytesRef binaryValue() throws IOException {
- bytesSlice.seek((long) disi.index() * length);
- bytesSlice.readBytes(bytes.bytes, 0, length);
+ bytesSlice.readBytes((long) disi.index() * length, bytes.bytes, 0, length);
return bytes;
}
};
@@ -880,8 +877,7 @@ final class Lucene90DocValuesProducer extends DocValuesProducer {
final int index = disi.index();
long startOffset = addresses.get(index);
bytes.length = (int) (addresses.get(index + 1L) - startOffset);
- bytesSlice.seek(startOffset);
- bytesSlice.readBytes(bytes.bytes, 0, bytes.length);
+ bytesSlice.readBytes(startOffset, bytes.bytes, 0, bytes.length);
return bytes;
}
};
@@ -1125,7 +1121,7 @@ final class Lucene90DocValuesProducer extends DocValuesProducer {
final IndexInput bytes;
final long blockMask;
final LongValues indexAddresses;
- final IndexInput indexBytes;
+ final RandomAccessInput indexBytes;
final BytesRef term;
long ord = -1;
@@ -1147,7 +1143,7 @@ final class Lucene90DocValuesProducer extends DocValuesProducer {
indexAddresses =
DirectMonotonicReader.getInstance(
entry.termsIndexAddressesMeta, indexAddressesSlice, merging);
- indexBytes = data.slice("terms-index", entry.termsIndexOffset, entry.termsIndexLength);
+ indexBytes = data.randomAccessSlice(entry.termsIndexOffset, entry.termsIndexLength);
term = new BytesRef(entry.maxTermLength);
// add the max term length for the dictionary
@@ -1205,8 +1201,7 @@ final class Lucene90DocValuesProducer extends DocValuesProducer {
assert index >= 0 && index <= (entry.termsDictSize - 1) >>> entry.termsDictIndexShift;
final long start = indexAddresses.get(index);
term.length = (int) (indexAddresses.get(index + 1) - start);
- indexBytes.seek(start);
- indexBytes.readBytes(term.bytes, 0, term.length);
+ indexBytes.readBytes(start, term.bytes, 0, term.length);
return term;
}