Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
Summary: Avoid having two implementations to compute the size of a record.

Differential Revision: D67464294

fbshipit-source-id: 33823371548e74631686465ed90275635530328a
  • Loading branch information
Georges Berenger authored and facebook-github-bot committed Dec 19, 2024
1 parent 9413f4d commit 635ce51
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions vrs/RecordFileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,23 +540,12 @@ bool RecordFileReader::prefetchRecordSequence(
!file_->isRemoteFileSystem()) {
return false; // don't even try for local file systems!
}
const vector<int64_t>& recordBoundaries = getRecordBoundaries();
int64_t fileSize = file_->getTotalSize();
vector<pair<size_t, size_t>> segments;
segments.reserve(records.size());
for (const IndexRecord::RecordInfo* record : records) {
int64_t recordOffset = record->fileOffset;
if (XR_VERIFY(recordOffset < fileSize)) {
auto nextBoundary =
upper_bound(recordBoundaries.begin(), recordBoundaries.end(), recordOffset);
if (XR_VERIFY(nextBoundary != recordBoundaries.end())) {
int64_t nextRecordOffset = *nextBoundary;
if (XR_VERIFY(nextRecordOffset > recordOffset)) {
segments.emplace_back(
static_cast<size_t>(recordOffset),
static_cast<size_t>(nextRecordOffset - recordOffset - 1));
}
}
uint32_t recordSize = getRecordSize(record - recordIndex_.data());
if (XR_VERIFY(recordSize > 0)) {
segments.emplace_back(static_cast<size_t>(record->fileOffset), recordSize);
}
}
return file_->prefetchReadSequence(segments, clearSequence);
Expand Down

0 comments on commit 635ce51

Please sign in to comment.