@@ -1679,17 +1679,22 @@ TEST_F(ParquetFileBatchReaderTest, TestPreBufferRangeFeedsReadAheadCache) {
16791679 WriteArray (file_path_, src_array, arrow_schema, /* write_batch_size=*/ 10 ,
16801680 /* enable_dictionary=*/ true , /* max_row_group_length=*/ 10 );
16811681
1682+ // A pool of its own, so that a buffer outliving the pool it was allocated
1683+ // from shows up instead of being covered by the global pool, which never
1684+ // goes away. Declared first, so that it outlives the cache and the reader.
1685+ std::shared_ptr<MemoryPool> pool (GetMemoryPool ());
1686+
16821687 ASSERT_OK_AND_ASSIGN (std::shared_ptr<InputStream> cache_stream, fs_->Open (file_path_));
16831688 // The file size is left unknown so the block cache stays off: this test is
16841689 // about the pre-buffered ranges feeding the cache.
1685- auto cache = std::make_shared<ReadAheadCache>(cache_stream, CacheConfig (), /* file_size= */ 0 ,
1686- GetDefaultPool () );
1690+ auto cache =
1691+ std::make_shared<ReadAheadCache>(cache_stream, CacheConfig (), /* file_size= */ 0 , pool );
16871692 ASSERT_OK_AND_ASSIGN (std::unique_ptr<InputStream> reader_stream, fs_->Open (file_path_));
16881693 auto cache_input_stream = std::make_shared<CacheInputStream>(std::move (reader_stream), cache);
16891694
16901695 std::map<std::string, std::string> options;
16911696 ParquetReaderBuilder builder (options, batch_size_);
1692- builder.WithMemoryPool (GetDefaultPool () );
1697+ builder.WithMemoryPool (pool );
16931698 ASSERT_OK_AND_ASSIGN (std::unique_ptr<FileBatchReader> base_reader,
16941699 builder.Build (cache_input_stream));
16951700 auto parquet_batch_reader = dynamic_cast <ParquetFileBatchReader*>(base_reader.get ());
@@ -2111,17 +2116,22 @@ TEST_F(ParquetFileBatchReaderTest, TestBlockCacheSharesTailReadsAcrossReaders) {
21112116 const int64_t tail_begin = file_length - static_cast <int64_t >(CacheConfig ().GetBlockSize ());
21122117 ASSERT_GT (tail_begin, 0 );
21132118
2119+ // A pool of its own, so that a buffer outliving the pool it was allocated
2120+ // from shows up instead of being covered by the global pool, which never
2121+ // goes away. Declared first, so that it outlives the cache and the readers.
2122+ std::shared_ptr<MemoryPool> pool (GetMemoryPool ());
2123+
21142124 auto tail_read_count = std::make_shared<std::atomic<int32_t >>(0 );
21152125 ASSERT_OK_AND_ASSIGN (std::unique_ptr<InputStream> cache_stream, fs_->Open (file_path_));
21162126 auto counting_cache_stream = std::make_shared<TailReadCountingInputStream>(
21172127 std::move (cache_stream), tail_begin, tail_read_count);
2118- auto cache = std::make_shared<ReadAheadCache>(
2119- counting_cache_stream, CacheConfig (), static_cast <uint64_t >(file_length), GetDefaultPool () );
2128+ auto cache = std::make_shared<ReadAheadCache>(counting_cache_stream, CacheConfig (),
2129+ static_cast <uint64_t >(file_length), pool );
21202130
21212131 std::map<std::string, std::string> options;
21222132 options[PARQUET_READ_ENABLE_PAGE_INDEX_FILTER ] = " true" ;
21232133 ParquetReaderBuilder builder (options, batch_size_);
2124- builder.WithMemoryPool (GetDefaultPool () );
2134+ builder.WithMemoryPool (pool );
21252135
21262136 constexpr int32_t kReaderCount = 3 ;
21272137 std::vector<std::future<Result<std::unique_ptr<FileBatchReader>>>> futures;
0 commit comments