2019-10-10 16:30:30 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Core/NamesAndTypes.h>
|
|
|
|
#include <Storages/MergeTree/IMergeTreeReader.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2020-02-10 20:27:06 +00:00
|
|
|
class MergeTreeDataPartWide;
|
|
|
|
using DataPartWidePtr = std::shared_ptr<const MergeTreeDataPartWide>;
|
|
|
|
|
2020-01-16 16:15:01 +00:00
|
|
|
/// Reader for Wide parts.
|
2019-10-10 16:30:30 +00:00
|
|
|
class MergeTreeReaderWide : public IMergeTreeReader
|
|
|
|
{
|
|
|
|
public:
|
2020-02-10 20:27:06 +00:00
|
|
|
MergeTreeReaderWide(
|
2020-03-23 02:12:31 +00:00
|
|
|
DataPartWidePtr data_part_,
|
|
|
|
NamesAndTypesList columns_,
|
2020-06-17 16:39:58 +00:00
|
|
|
const StorageMetadataPtr & metadata_snapshot_,
|
2019-10-10 16:30:30 +00:00
|
|
|
UncompressedCache * uncompressed_cache_,
|
|
|
|
MarkCache * mark_cache_,
|
2020-03-23 02:12:31 +00:00
|
|
|
MarkRanges mark_ranges_,
|
|
|
|
MergeTreeReaderSettings settings_,
|
|
|
|
ValueSizeMap avg_value_size_hints_ = {},
|
|
|
|
const ReadBufferFromFileBase::ProfileCallback & profile_callback_ = {},
|
2019-10-10 16:30:30 +00:00
|
|
|
clockid_t clock_type_ = CLOCK_MONOTONIC_COARSE);
|
|
|
|
|
|
|
|
/// Return the number of rows has been read or zero if there is no columns to read.
|
|
|
|
/// If continue_reading is true, continue reading from last state, otherwise seek to from_mark
|
2021-10-15 08:36:26 +00:00
|
|
|
size_t readRows(size_t from_mark, size_t current_task_last_mark,
|
|
|
|
bool continue_reading, size_t max_rows_to_read, Columns & res_columns) override;
|
2019-10-10 16:30:30 +00:00
|
|
|
|
2019-12-02 17:10:22 +00:00
|
|
|
bool canReadIncompleteGranules() const override { return true; }
|
|
|
|
|
2019-10-10 16:30:30 +00:00
|
|
|
using FileStreams = std::map<std::string, std::unique_ptr<MergeTreeReaderStream>>;
|
|
|
|
|
2021-07-26 00:34:36 +00:00
|
|
|
private:
|
2019-10-10 16:30:30 +00:00
|
|
|
FileStreams streams;
|
|
|
|
|
2022-07-27 14:05:16 +00:00
|
|
|
void addStreams(
|
|
|
|
const NameAndTypePair & name_and_type,
|
|
|
|
const SerializationPtr & serialization,
|
|
|
|
const ReadBufferFromFileBase::ProfileCallback & profile_callback,
|
|
|
|
clockid_t clock_type);
|
2019-10-10 16:30:30 +00:00
|
|
|
|
|
|
|
void readData(
|
2022-07-27 14:05:16 +00:00
|
|
|
const NameAndTypePair & name_and_type, const SerializationPtr & serialization, ColumnPtr & column,
|
2021-10-15 08:36:26 +00:00
|
|
|
size_t from_mark, bool continue_reading, size_t current_task_last_mark, size_t max_rows_to_read,
|
2021-10-05 09:11:25 +00:00
|
|
|
ISerialization::SubstreamsCache & cache, bool was_prefetched);
|
2021-07-26 00:34:36 +00:00
|
|
|
|
2021-10-05 09:11:25 +00:00
|
|
|
/// Make next readData more simple by calling 'prefetch' of all related ReadBuffers (column streams).
|
2021-07-26 00:34:36 +00:00
|
|
|
void prefetch(
|
|
|
|
const NameAndTypePair & name_and_type,
|
2022-07-27 14:05:16 +00:00
|
|
|
const SerializationPtr & serialization,
|
2021-07-26 00:34:36 +00:00
|
|
|
size_t from_mark,
|
|
|
|
bool continue_reading,
|
2021-10-15 08:36:26 +00:00
|
|
|
size_t current_task_last_mark,
|
2021-10-05 09:11:25 +00:00
|
|
|
ISerialization::SubstreamsCache & cache,
|
|
|
|
std::unordered_set<std::string> & prefetched_streams); /// if stream was already prefetched do nothing
|
2021-12-22 12:26:16 +00:00
|
|
|
|
|
|
|
void deserializePrefix(
|
|
|
|
const SerializationPtr & serialization,
|
|
|
|
const NameAndTypePair & name_and_type,
|
|
|
|
size_t current_task_last_mark,
|
|
|
|
ISerialization::SubstreamsCache & cache);
|
2019-10-10 16:30:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|