ClickHouse/src/Storages/MergeTree/MergeTreeReaderStream.h

64 lines
1.9 KiB
C++
Raw Normal View History

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>
#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(
DiskPtr disk_,
const String & path_prefix_, const String & data_file_extension_, size_t marks_count_,
const MarkRanges & all_mark_ranges,
const MergeTreeReaderSettings & settings_,
MarkCache * mark_cache, UncompressedCache * uncompressed_cache,
size_t file_size_, const MergeTreeIndexGranularityInfo * index_granularity_info_,
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);
2019-02-06 08:17:57 +00:00
ReadBuffer * data_buffer;
2019-01-17 14:23:12 +00:00
private:
std::pair<size_t, size_t> getRightOffsetAndBytesRange(size_t left_mark, size_t right_mark_non_included);
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;
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-11-05 16:57:09 +00:00
std::optional<size_t> last_right_offset;
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
};
}