@@ -1770,8 +1770,8 @@ namespace orc {
17701770 contents_->evictCache (boundary);
17711771 }
17721772
1773- void ReaderImpl::preBuffer ( const std::vector< uint32_t >& stripes,
1774- const std::list<uint64_t >& includeTypes) {
1773+ std::vector< std::pair< uint64_t , uint64_t >> ReaderImpl::preBufferRange (
1774+ const std::vector< uint32_t >& stripes, const std::list<uint64_t >& includeTypes) {
17751775 std::vector<uint32_t > newStripes;
17761776 for (auto stripe : stripes) {
17771777 if (stripe < static_cast <uint32_t >(footer_->stripes_size ())) newStripes.push_back (stripe);
@@ -1783,7 +1783,7 @@ namespace orc {
17831783 }
17841784
17851785 if (newStripes.empty () || newIncludeTypes.empty ()) {
1786- return ;
1786+ return {} ;
17871787 }
17881788
17891789 orc::RowReaderOptions rowReaderOptions;
@@ -1792,12 +1792,33 @@ namespace orc {
17921792 std::vector<bool > selectedColumns;
17931793 columnSelector.updateSelected (selectedColumns, rowReaderOptions);
17941794
1795+ std::vector<std::pair<uint64_t , uint64_t >> ranges;
1796+
17951797 for (auto stripe : newStripes) {
17961798 const auto & stripeInfo = footer_->stripes (stripe);
17971799 proto::StripeFooter stripeFooter = getStripeFooter (stripeInfo, *contents_);
1798- auto ranges = extractReadRangesForStripe (stripe, stripeInfo, stripeFooter, selectedColumns);
1799- contents_->cacheRanges (std::move (ranges));
1800+ auto stripeRanges =
1801+ extractReadRangesForStripe (stripe, stripeInfo, stripeFooter, selectedColumns);
1802+ for (const auto & range : stripeRanges) {
1803+ ranges.emplace_back (range.offset , range.length );
1804+ }
1805+ }
1806+ return ranges;
1807+ }
1808+
1809+ void ReaderImpl::preBuffer (const std::vector<uint32_t >& stripes,
1810+ const std::list<uint64_t >& includeTypes) {
1811+ auto ranges = preBufferRange (stripes, includeTypes);
1812+ if (ranges.empty ()) {
1813+ return ;
1814+ }
1815+
1816+ std::vector<ReadRange> readRanges;
1817+ readRanges.reserve (ranges.size ());
1818+ for (const auto & range : ranges) {
1819+ readRanges.emplace_back (range.first , range.second );
18001820 }
1821+ contents_->cacheRanges (std::move (readRanges));
18011822 }
18021823
18031824 RowReader::~RowReader () {
0 commit comments