1#include <Storages/MarkCache.h>
2#include <Storages/MergeTree/MarkRange.h>
3#include <Storages/MergeTree/MergeTreeData.h>
4#include <Storages/MergeTree/MergeTreeRangeReader.h>
5#include <Storages/MergeTree/MergeTreeIndexGranularityInfo.h>
6#include <Compression/CachedCompressedReadBuffer.h>
7#include <Compression/CompressedReadBufferFromFile.h>
8
9
10namespace DB
11{
12
13/// Class for reading a single column (or index).
14class MergeTreeReaderStream
15{
16public:
17 MergeTreeReaderStream(
18 const String & path_prefix_, const String & data_file_extension_, size_t marks_count_,
19 const MarkRanges & all_mark_ranges,
20 MarkCache * mark_cache, bool save_marks_in_cache,
21 UncompressedCache * uncompressed_cache,
22 size_t file_size, size_t aio_threshold, size_t max_read_buffer_size,
23 const MergeTreeIndexGranularityInfo * index_granularity_info_,
24 const ReadBufferFromFileBase::ProfileCallback & profile_callback, clockid_t clock_type);
25
26 void seekToMark(size_t index);
27
28 void seekToStart();
29
30 ReadBuffer * data_buffer;
31
32private:
33 /// NOTE: lazily loads marks from the marks cache.
34 const MarkInCompressedFile & getMark(size_t index);
35
36 void loadMarks();
37
38 std::string path_prefix;
39 std::string data_file_extension;
40
41 size_t marks_count;
42
43 MarkCache * mark_cache;
44 bool save_marks_in_cache;
45 MarkCache::MappedPtr marks;
46
47 const MergeTreeIndexGranularityInfo * index_granularity_info;
48
49 std::unique_ptr<CachedCompressedReadBuffer> cached_buffer;
50 std::unique_ptr<CompressedReadBufferFromFile> non_cached_buffer;
51};
52}
53