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 MergeTreeDataPartCompact;
|
|
|
|
using DataPartCompactPtr = std::shared_ptr<const MergeTreeDataPartCompact>;
|
|
|
|
|
2020-01-16 16:15:01 +00:00
|
|
|
/// Reader for compact parts
|
2019-10-10 16:30:30 +00:00
|
|
|
class MergeTreeReaderCompact : public IMergeTreeReader
|
|
|
|
{
|
|
|
|
public:
|
2020-02-10 20:27:06 +00:00
|
|
|
MergeTreeReaderCompact(
|
2020-03-23 02:12:31 +00:00
|
|
|
DataPartCompactPtr 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_ = {},
|
2020-01-17 12:24:27 +00:00
|
|
|
clockid_t clock_type_ = CLOCK_MONOTONIC_COARSE);
|
2019-10-10 16:30:30 +00:00
|
|
|
|
|
|
|
/// 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
|
2019-12-19 13:10:57 +00:00
|
|
|
size_t readRows(size_t from_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 false; }
|
|
|
|
|
2019-10-10 16:30:30 +00:00
|
|
|
private:
|
2019-12-25 17:34:23 +00:00
|
|
|
bool isContinuousReading(size_t mark, size_t column_position);
|
|
|
|
|
2019-10-10 16:30:30 +00:00
|
|
|
ReadBuffer * data_buffer;
|
2019-10-16 18:27:53 +00:00
|
|
|
std::unique_ptr<CachedCompressedReadBuffer> cached_buffer;
|
|
|
|
std::unique_ptr<CompressedReadBufferFromFile> non_cached_buffer;
|
2019-10-10 16:30:30 +00:00
|
|
|
|
2019-11-20 13:33:41 +00:00
|
|
|
MergeTreeMarksLoader marks_loader;
|
2019-10-11 15:37:16 +00:00
|
|
|
|
2020-01-17 12:24:27 +00:00
|
|
|
/// Positions of columns in part structure.
|
2020-01-09 17:06:34 +00:00
|
|
|
std::vector<ColumnPosition> column_positions;
|
2020-01-16 16:15:01 +00:00
|
|
|
/// Should we read full column or only it's offsets
|
2020-01-09 17:06:34 +00:00
|
|
|
std::vector<bool> read_only_offsets;
|
2019-12-12 18:55:19 +00:00
|
|
|
|
2019-11-28 20:14:41 +00:00
|
|
|
size_t next_mark = 0;
|
2019-12-25 17:34:23 +00:00
|
|
|
std::optional<std::pair<size_t, size_t>> last_read_granule;
|
2019-11-28 20:14:41 +00:00
|
|
|
|
2019-12-18 16:27:49 +00:00
|
|
|
void seekToMark(size_t row_index, size_t column_index);
|
2019-10-16 18:27:53 +00:00
|
|
|
|
2020-01-17 12:24:27 +00:00
|
|
|
void readData(const String & name, IColumn & column, const IDataType & type,
|
2020-01-09 15:46:32 +00:00
|
|
|
size_t from_mark, size_t column_position, size_t rows_to_read, bool only_offsets = false);
|
2020-07-14 14:03:09 +00:00
|
|
|
|
|
|
|
size_t getReadBufferSize();
|
2019-10-10 16:30:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|