mirror of https://github.com/apache/lucene.git
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.
This commit is contained in:
parent
fa77d97c09
commit
48547f913c
|
@ -792,7 +792,7 @@ final class Lucene90DocValuesProducer extends DocValuesProducer {
|
||||||
return DocValues.emptyBinary();
|
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
|
// Prefetch the first page of data. Following pages are expected to get prefetched through
|
||||||
// read-ahead.
|
// read-ahead.
|
||||||
if (bytesSlice.length() > 0) {
|
if (bytesSlice.length() > 0) {
|
||||||
|
@ -809,8 +809,7 @@ final class Lucene90DocValuesProducer extends DocValuesProducer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BytesRef binaryValue() throws IOException {
|
public BytesRef binaryValue() throws IOException {
|
||||||
bytesSlice.seek((long) doc * length);
|
bytesSlice.readBytes((long) doc * length, bytes.bytes, 0, length);
|
||||||
bytesSlice.readBytes(bytes.bytes, 0, length);
|
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -832,8 +831,7 @@ final class Lucene90DocValuesProducer extends DocValuesProducer {
|
||||||
public BytesRef binaryValue() throws IOException {
|
public BytesRef binaryValue() throws IOException {
|
||||||
long startOffset = addresses.get(doc);
|
long startOffset = addresses.get(doc);
|
||||||
bytes.length = (int) (addresses.get(doc + 1L) - startOffset);
|
bytes.length = (int) (addresses.get(doc + 1L) - startOffset);
|
||||||
bytesSlice.seek(startOffset);
|
bytesSlice.readBytes(startOffset, bytes.bytes, 0, bytes.length);
|
||||||
bytesSlice.readBytes(bytes.bytes, 0, bytes.length);
|
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -856,8 +854,7 @@ final class Lucene90DocValuesProducer extends DocValuesProducer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BytesRef binaryValue() throws IOException {
|
public BytesRef binaryValue() throws IOException {
|
||||||
bytesSlice.seek((long) disi.index() * length);
|
bytesSlice.readBytes((long) disi.index() * length, bytes.bytes, 0, length);
|
||||||
bytesSlice.readBytes(bytes.bytes, 0, length);
|
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -880,8 +877,7 @@ final class Lucene90DocValuesProducer extends DocValuesProducer {
|
||||||
final int index = disi.index();
|
final int index = disi.index();
|
||||||
long startOffset = addresses.get(index);
|
long startOffset = addresses.get(index);
|
||||||
bytes.length = (int) (addresses.get(index + 1L) - startOffset);
|
bytes.length = (int) (addresses.get(index + 1L) - startOffset);
|
||||||
bytesSlice.seek(startOffset);
|
bytesSlice.readBytes(startOffset, bytes.bytes, 0, bytes.length);
|
||||||
bytesSlice.readBytes(bytes.bytes, 0, bytes.length);
|
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1125,7 +1121,7 @@ final class Lucene90DocValuesProducer extends DocValuesProducer {
|
||||||
final IndexInput bytes;
|
final IndexInput bytes;
|
||||||
final long blockMask;
|
final long blockMask;
|
||||||
final LongValues indexAddresses;
|
final LongValues indexAddresses;
|
||||||
final IndexInput indexBytes;
|
final RandomAccessInput indexBytes;
|
||||||
final BytesRef term;
|
final BytesRef term;
|
||||||
long ord = -1;
|
long ord = -1;
|
||||||
|
|
||||||
|
@ -1147,7 +1143,7 @@ final class Lucene90DocValuesProducer extends DocValuesProducer {
|
||||||
indexAddresses =
|
indexAddresses =
|
||||||
DirectMonotonicReader.getInstance(
|
DirectMonotonicReader.getInstance(
|
||||||
entry.termsIndexAddressesMeta, indexAddressesSlice, merging);
|
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);
|
term = new BytesRef(entry.maxTermLength);
|
||||||
|
|
||||||
// add the max term length for the dictionary
|
// 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;
|
assert index >= 0 && index <= (entry.termsDictSize - 1) >>> entry.termsDictIndexShift;
|
||||||
final long start = indexAddresses.get(index);
|
final long start = indexAddresses.get(index);
|
||||||
term.length = (int) (indexAddresses.get(index + 1) - start);
|
term.length = (int) (indexAddresses.get(index + 1) - start);
|
||||||
indexBytes.seek(start);
|
indexBytes.readBytes(start, term.bytes, 0, term.length);
|
||||||
indexBytes.readBytes(term.bytes, 0, term.length);
|
|
||||||
return term;
|
return term;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue