Skip to content

Commit 485aba8

Browse files
authored
Change some IndexInput to RandomAccessInput in ES87TSDBDocValuesProducer (#115305)
1 parent e3c198a commit 485aba8

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

server/src/main/java/org/elasticsearch/index/codec/tsdb/ES87TSDBDocValuesProducer.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public BinaryDocValues getBinary(FieldInfo field) throws IOException {
132132
return DocValues.emptyBinary();
133133
}
134134

135-
final IndexInput bytesSlice = data.slice("fixed-binary", entry.dataOffset, entry.dataLength);
135+
final RandomAccessInput bytesSlice = data.randomAccessSlice(entry.dataOffset, entry.dataLength);
136136

137137
if (entry.docsWithFieldOffset == -1) {
138138
// dense
@@ -144,8 +144,7 @@ public BinaryDocValues getBinary(FieldInfo field) throws IOException {
144144

145145
@Override
146146
public BytesRef binaryValue() throws IOException {
147-
bytesSlice.seek((long) doc * length);
148-
bytesSlice.readBytes(bytes.bytes, 0, length);
147+
bytesSlice.readBytes((long) doc * length, bytes.bytes, 0, length);
149148
return bytes;
150149
}
151150
};
@@ -160,8 +159,7 @@ public BytesRef binaryValue() throws IOException {
160159
public BytesRef binaryValue() throws IOException {
161160
long startOffset = addresses.get(doc);
162161
bytes.length = (int) (addresses.get(doc + 1L) - startOffset);
163-
bytesSlice.seek(startOffset);
164-
bytesSlice.readBytes(bytes.bytes, 0, bytes.length);
162+
bytesSlice.readBytes(startOffset, bytes.bytes, 0, bytes.length);
165163
return bytes;
166164
}
167165
};
@@ -184,8 +182,7 @@ public BytesRef binaryValue() throws IOException {
184182

185183
@Override
186184
public BytesRef binaryValue() throws IOException {
187-
bytesSlice.seek((long) disi.index() * length);
188-
bytesSlice.readBytes(bytes.bytes, 0, length);
185+
bytesSlice.readBytes((long) disi.index() * length, bytes.bytes, 0, length);
189186
return bytes;
190187
}
191188
};
@@ -201,8 +198,7 @@ public BytesRef binaryValue() throws IOException {
201198
final int index = disi.index();
202199
long startOffset = addresses.get(index);
203200
bytes.length = (int) (addresses.get(index + 1L) - startOffset);
204-
bytesSlice.seek(startOffset);
205-
bytesSlice.readBytes(bytes.bytes, 0, bytes.length);
201+
bytesSlice.readBytes(startOffset, bytes.bytes, 0, bytes.length);
206202
return bytes;
207203
}
208204
};
@@ -407,7 +403,7 @@ private static class TermsDict extends BaseTermsEnum {
407403
final IndexInput bytes;
408404
final long blockMask;
409405
final LongValues indexAddresses;
410-
final IndexInput indexBytes;
406+
final RandomAccessInput indexBytes;
411407
final BytesRef term;
412408
long ord = -1;
413409

@@ -427,7 +423,7 @@ private static class TermsDict extends BaseTermsEnum {
427423
entry.termsIndexAddressesLength
428424
);
429425
indexAddresses = DirectMonotonicReader.getInstance(entry.termsIndexAddressesMeta, indexAddressesSlice);
430-
indexBytes = data.slice("terms-index", entry.termsIndexOffset, entry.termsIndexLength);
426+
indexBytes = data.randomAccessSlice(entry.termsIndexOffset, entry.termsIndexLength);
431427
term = new BytesRef(entry.maxTermLength);
432428

433429
// add the max term length for the dictionary
@@ -485,8 +481,7 @@ private BytesRef getTermFromIndex(long index) throws IOException {
485481
assert index >= 0 && index <= (entry.termsDictSize - 1) >>> entry.termsDictIndexShift;
486482
final long start = indexAddresses.get(index);
487483
term.length = (int) (indexAddresses.get(index + 1) - start);
488-
indexBytes.seek(start);
489-
indexBytes.readBytes(term.bytes, 0, term.length);
484+
indexBytes.readBytes(start, term.bytes, 0, term.length);
490485
return term;
491486
}
492487

0 commit comments

Comments
 (0)