2020-10-10 18:37:02 +00:00
|
|
|
#pragma once
|
2022-04-29 17:39:06 +00:00
|
|
|
#include <tuple>
|
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(
|
2022-04-12 18:59:49 +00:00
|
|
|
DataPartStoragePtr data_part_storage_,
|
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_,
|
2022-05-02 18:06:47 +00:00
|
|
|
const ReadBufferFromFileBase::ProfileCallback & profile_callback, clockid_t clock_type,
|
|
|
|
bool is_low_cardinality_dictionary_);
|
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.
|
|
|
|
*/
|
2022-02-16 13:35:23 +00:00
|
|
|
void adjustRightMark(size_t right_mark);
|
2021-10-15 08:36:26 +00:00
|
|
|
|
2022-04-29 17:39:06 +00:00
|
|
|
ReadBuffer * getDataBuffer();
|
|
|
|
CompressedReadBufferBase * getCompressedDataBuffer();
|
2019-01-17 14:23:12 +00:00
|
|
|
|
|
|
|
private:
|
2022-04-29 17:39:06 +00:00
|
|
|
void init();
|
2022-02-16 13:35:23 +00:00
|
|
|
size_t getRightOffset(size_t right_mark_non_included);
|
2021-10-15 08:36:26 +00:00
|
|
|
|
2022-04-29 17:39:06 +00:00
|
|
|
const MergeTreeReaderSettings settings;
|
|
|
|
const ReadBufferFromFileBase::ProfileCallback profile_callback;
|
|
|
|
clockid_t clock_type;
|
|
|
|
const MarkRanges all_mark_ranges;
|
|
|
|
size_t file_size;
|
|
|
|
UncompressedCache * uncompressed_cache;
|
|
|
|
|
2022-04-12 18:59:49 +00:00
|
|
|
DataPartStoragePtr data_part_storage;
|
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
|
|
|
|
2022-05-02 18:06:47 +00:00
|
|
|
bool is_low_cardinality_dictionary = false;
|
|
|
|
|
2019-01-17 14:23:12 +00:00
|
|
|
size_t marks_count;
|
|
|
|
|
2022-04-29 17:39:06 +00:00
|
|
|
|
|
|
|
ReadBuffer * data_buffer;
|
|
|
|
CompressedReadBufferBase * compressed_data_buffer;
|
2019-02-06 08:17:57 +00:00
|
|
|
MarkCache * mark_cache;
|
2019-01-17 14:23:12 +00:00
|
|
|
bool save_marks_in_cache;
|
2022-04-29 17:39:06 +00:00
|
|
|
bool initialized = false;
|
2019-01-17 14:23:12 +00:00
|
|
|
|
2021-11-05 16:57:09 +00:00
|
|
|
std::optional<size_t> last_right_offset;
|
2021-10-15 08:36:26 +00:00
|
|
|
|
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
|
|
|
};
|
2022-08-28 20:33:42 +00:00
|
|
|
|
2019-01-29 20:00:12 +00:00
|
|
|
}
|