2020-10-10 18:37:02 +00:00
|
|
|
#pragma once
|
2019-01-17 14:23:12 +00:00
|
|
|
#include <Storages/MarkCache.h>
|
|
|
|
#include <Storages/MergeTree/MarkRange.h>
|
|
|
|
#include <Storages/MergeTree/MergeTreeData.h>
|
|
|
|
#include <Storages/MergeTree/MergeTreeRangeReader.h>
|
2019-06-19 10:07:56 +00:00
|
|
|
#include <Storages/MergeTree/MergeTreeIndexGranularityInfo.h>
|
2019-01-17 14:23:12 +00:00
|
|
|
#include <Compression/CachedCompressedReadBuffer.h>
|
|
|
|
#include <Compression/CompressedReadBufferFromFile.h>
|
2019-12-18 15:54:45 +00:00
|
|
|
#include <Storages/MergeTree/MergeTreeIOSettings.h>
|
2019-11-20 13:33:41 +00:00
|
|
|
#include <Storages/MergeTree/MergeTreeMarksLoader.h>
|
2019-01-17 14:23:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2019-02-06 08:24:16 +00:00
|
|
|
/// Class for reading a single column (or index).
|
2019-01-17 14:23:12 +00:00
|
|
|
class MergeTreeReaderStream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MergeTreeReaderStream(
|
2020-02-27 16:47:40 +00:00
|
|
|
DiskPtr disk_,
|
2020-01-04 05:46:50 +00:00
|
|
|
const String & path_prefix_, const String & data_file_extension_, size_t marks_count_,
|
|
|
|
const MarkRanges & all_mark_ranges,
|
2020-01-09 12:54:37 +00:00
|
|
|
const MergeTreeReaderSettings & settings_,
|
|
|
|
MarkCache * mark_cache, UncompressedCache * uncompressed_cache,
|
2021-10-15 08:36:26 +00:00
|
|
|
size_t file_size_, const MergeTreeIndexGranularityInfo * index_granularity_info_,
|
2020-01-04 05:46:50 +00:00
|
|
|
const ReadBufferFromFileBase::ProfileCallback & profile_callback, clockid_t clock_type);
|
2019-01-17 14:23:12 +00:00
|
|
|
|
|
|
|
void seekToMark(size_t index);
|
|
|
|
|
|
|
|
void seekToStart();
|
|
|
|
|
2021-10-27 21:54:06 +00:00
|
|
|
/**
|
|
|
|
* Does buffer need to know something about mark ranges bounds it is going to read?
|
|
|
|
* (In case of MergeTree* tables). Mostly needed for reading from remote fs.
|
|
|
|
*/
|
2021-10-24 17:43:34 +00:00
|
|
|
void adjustForRange(MarkRange range);
|
2021-10-15 08:36:26 +00:00
|
|
|
|
2019-02-06 08:17:57 +00:00
|
|
|
ReadBuffer * data_buffer;
|
2019-01-17 14:23:12 +00:00
|
|
|
|
|
|
|
private:
|
2021-10-15 08:36:26 +00:00
|
|
|
std::pair<size_t, size_t> getRightOffsetAndBytesRange(size_t left_mark, size_t right_mark);
|
|
|
|
|
2020-02-27 16:47:40 +00:00
|
|
|
DiskPtr disk;
|
2019-01-17 14:23:12 +00:00
|
|
|
std::string path_prefix;
|
2019-03-18 12:02:33 +00:00
|
|
|
std::string data_file_extension;
|
2019-01-17 14:23:12 +00:00
|
|
|
|
|
|
|
size_t marks_count;
|
2021-10-15 08:36:26 +00:00
|
|
|
size_t file_size;
|
2019-01-17 14:23:12 +00:00
|
|
|
|
2019-02-06 08:17:57 +00:00
|
|
|
MarkCache * mark_cache;
|
2019-01-17 14:23:12 +00:00
|
|
|
bool save_marks_in_cache;
|
|
|
|
|
2021-10-15 08:36:26 +00:00
|
|
|
size_t last_right_offset = 0;
|
|
|
|
|
2019-06-19 10:07:56 +00:00
|
|
|
const MergeTreeIndexGranularityInfo * index_granularity_info;
|
2019-03-27 16:23:38 +00:00
|
|
|
|
2019-01-17 14:23:12 +00:00
|
|
|
std::unique_ptr<CachedCompressedReadBuffer> cached_buffer;
|
|
|
|
std::unique_ptr<CompressedReadBufferFromFile> non_cached_buffer;
|
2019-11-20 13:33:41 +00:00
|
|
|
|
|
|
|
MergeTreeMarksLoader marks_loader;
|
2019-01-17 14:23:12 +00:00
|
|
|
};
|
2019-01-29 20:00:12 +00:00
|
|
|
}
|