@@ -30,6 +30,20 @@ index a914e5f26..efe1d4933 100644
3030 };
3131
3232 // Specializations for char
33+ diff --git a/c++/include/orc/Reader.hh b/c++/include/orc/Reader.hh
34+ index b015b6491..585e50ec5 100644
35+ --- a/c++/include/orc/Reader.hh
36+ +++ b/c++/include/orc/Reader.hh
37+ @@ -659,6 +659,9 @@ namespace orc {
38+ virtual void preBuffer(const std::vector<uint32_t>& stripes,
39+ const std::list<uint64_t>& includeTypes) = 0;
40+
41+ + virtual std::vector<std::pair<uint64_t, uint64_t>> preBufferRange(
42+ + const std::vector<uint32_t>& stripes, const std::list<uint64_t>& includeTypes) = 0;
43+ +
44+ /**
45+ * Release cached entries whose right boundary is less than or equal to the given boundary.
46+ * @param boundary the boundary value to release cache entries
3347diff --git a/c++/src/ColumnReader.cc b/c++/src/ColumnReader.cc
3448index af434c37c..08393259c 100644
3549--- a/c++/src/ColumnReader.cc
@@ -328,6 +342,86 @@ index ed7fee737..a8ee8a67c 100644
328342 reserve(newSize);
329343 if (newSize > currentSize_) {
330344 memset(buf_ + currentSize_, 0, newSize - currentSize_);
345+ diff --git a/c++/src/Reader.cc b/c++/src/Reader.cc
346+ index c93c62f6c..2a821b622 100644
347+ --- a/c++/src/Reader.cc
348+ +++ b/c++/src/Reader.cc
349+ @@ -1531,8 +1531,8 @@ namespace orc {
350+ }
351+ }
352+
353+ - void ReaderImpl::preBuffer(const std::vector<uint32_t>& stripes,
354+ - const std::list<uint64_t>& includeTypes) {
355+ + std::vector<std::pair<uint64_t, uint64_t>> ReaderImpl::preBufferRange(
356+ + const std::vector<uint32_t>& stripes, const std::list<uint64_t>& includeTypes) {
357+ std::vector<uint32_t> newStripes;
358+ for (auto stripe : stripes) {
359+ if (stripe < static_cast<uint32_t>(footer_->stripes_size())) newStripes.push_back(stripe);
360+ @@ -1544,7 +1544,7 @@ namespace orc {
361+ }
362+
363+ if (newStripes.empty() || newIncludeTypes.empty()) {
364+ - return;
365+ + return {};
366+ }
367+
368+ orc::RowReaderOptions rowReaderOptions;
369+ @@ -1553,7 +1553,7 @@ namespace orc {
370+ std::vector<bool> selectedColumns;
371+ columnSelector.updateSelected(selectedColumns, rowReaderOptions);
372+
373+ - std::vector<ReadRange> ranges;
374+ + std::vector<std::pair<uint64_t, uint64_t>> ranges;
375+ ranges.reserve(newIncludeTypes.size());
376+ for (auto stripe : newStripes) {
377+ // get stripe information
378+ @@ -1598,17 +1598,23 @@ namespace orc {
379+
380+ offset += stream.length();
381+ }
382+ + }
383+ + return ranges;
384+ + }
385+
386+ - {
387+ - std::lock_guard<std::mutex> lock(contents_->readCacheMutex);
388+ -
389+ - if (!contents_->readCache) {
390+ - contents_->readCache = std::make_shared<ReadRangeCache>(
391+ - getStream(), options_.getCacheOptions(), contents_->pool, contents_->readerMetrics);
392+ - }
393+ - contents_->readCache->cache(std::move(ranges));
394+ - }
395+ + void ReaderImpl::preBuffer(const std::vector<uint32_t>& stripes,
396+ + const std::list<uint64_t>& includeTypes) {
397+ + auto ranges = preBufferRange(stripes, includeTypes);
398+ + std::vector<ReadRange> read_ranges;
399+ + for (const auto& range : ranges) {
400+ + read_ranges.emplace_back(range.first, range.second);
401+ + }
402+ + std::lock_guard<std::mutex> lock(contents_->readCacheMutex);
403+ + if (!contents_->readCache) {
404+ + contents_->readCache = std::make_shared<ReadRangeCache>(
405+ + getStream(), options_.getCacheOptions(), contents_->pool, contents_->readerMetrics);
406+ }
407+ + contents_->readCache->cache(std::move(read_ranges));
408+ }
409+
410+ RowReader::~RowReader() {
411+ diff --git a/c++/src/Reader.hh b/c++/src/Reader.hh
412+ index 39ca73967..13da45a49 100644
413+ --- a/c++/src/Reader.hh
414+ +++ b/c++/src/Reader.hh
415+ @@ -387,6 +387,9 @@ namespace orc {
416+ std::map<uint32_t, BloomFilterIndex> getBloomFilters(
417+ uint32_t stripeIndex, const std::set<uint32_t>& included) const override;
418+
419+ + std::vector<std::pair<uint64_t, uint64_t>> preBufferRange(
420+ + const std::vector<uint32_t>& stripes, const std::list<uint64_t>& includeTypes) override;
421+ +
422+ void preBuffer(const std::vector<uint32_t>& stripes,
423+ const std::list<uint64_t>& includeTypes) override;
424+ void releaseBuffer(uint64_t boundary) override;
331425diff --git a/cmake_modules/ThirdpartyToolchain.cmake b/cmake_modules/ThirdpartyToolchain.cmake
332426index 9b2c829c7..434841224 100644
333427--- a/cmake_modules/ThirdpartyToolchain.cmake
0 commit comments