Proper variables capturing in CachedCompressedReadBuffer.

This commit is contained in:
Pavel Kovalenko 2020-03-06 15:28:26 +03:00 committed by Pavel Kovalenko
parent 898eb1f1d7
commit bf3cd54c19
3 changed files with 21 additions and 6 deletions

View File

@ -5,6 +5,7 @@
#include <Compression/CompressionFactory.h>
#include <Compression/CachedCompressedReadBuffer.h>
#include <IO/WriteBufferFromFile.h>
#include <IO/createReadBufferFromFileBase.h>
#include <IO/copyData.h>
#include <Common/Stopwatch.h>
@ -32,7 +33,14 @@ int main(int argc, char ** argv)
{
Stopwatch watch;
CachedCompressedReadBuffer in(path, &cache, 0, 0, 0);
CachedCompressedReadBuffer in(
path,
[&]()
{
return createReadBufferFromFileBase(path, 0, 0, 0);
},
&cache
);
WriteBufferFromFile out("/dev/null");
copyData(in, out);
@ -44,7 +52,14 @@ int main(int argc, char ** argv)
{
Stopwatch watch;
CachedCompressedReadBuffer in(path, &cache, 0, 0, 0);
CachedCompressedReadBuffer in(
path,
[&]()
{
return createReadBufferFromFileBase(path, 0, 0, 0);
},
&cache
);
WriteBufferFromFile out("/dev/null");
copyData(in, out);

View File

@ -40,8 +40,8 @@ MergeTreeReaderCompact::MergeTreeReaderCompact(
if (uncompressed_cache)
{
auto buffer = std::make_unique<CachedCompressedReadBuffer>(
full_data_path,
[&]()
fullPath(data_part->disk, full_data_path),
[this, full_data_path, buffer_size]()
{
return data_part->disk->readFile(
full_data_path,

View File

@ -79,8 +79,8 @@ MergeTreeReaderStream::MergeTreeReaderStream(
if (uncompressed_cache)
{
auto buffer = std::make_unique<CachedCompressedReadBuffer>(
path_prefix + data_file_extension,
[&]()
fullPath(disk, path_prefix + data_file_extension),
[this, buffer_size, sum_mark_range_bytes, &settings]()
{
return disk->readFile(
path_prefix + data_file_extension,