2019-10-10 16:30:30 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Storages/MergeTree/IMergeTreeDataPart.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2020-02-19 14:07:36 +00:00
|
|
|
/** In compact format all columns are stored in one file (`data.bin`).
|
2020-05-21 09:00:44 +00:00
|
|
|
* Data is split in granules and columns are serialized sequentially in one granule.
|
2020-02-19 14:07:36 +00:00
|
|
|
* Granules are written one by one in data file.
|
|
|
|
* Marks are also stored in single file (`data.mrk3`).
|
|
|
|
* In compact format one mark is an array of marks for every column and a number of rows in granule.
|
|
|
|
* Format of other data part files is not changed.
|
|
|
|
* It's considered to store only small parts in compact format (up to 10M).
|
2020-05-21 09:00:44 +00:00
|
|
|
* NOTE: Compact parts aren't supported for tables with non-adaptive granularity.
|
2020-02-19 14:07:36 +00:00
|
|
|
* NOTE: In compact part compressed and uncompressed size of single column is unknown.
|
|
|
|
*/
|
2019-10-10 16:30:30 +00:00
|
|
|
class MergeTreeDataPartCompact : public IMergeTreeDataPart
|
|
|
|
{
|
|
|
|
public:
|
2019-12-16 14:51:19 +00:00
|
|
|
static constexpr auto DATA_FILE_NAME = "data";
|
2020-01-13 14:53:32 +00:00
|
|
|
static constexpr auto DATA_FILE_NAME_WITH_EXTENSION = "data.bin";
|
2019-12-16 14:51:19 +00:00
|
|
|
|
2019-10-16 18:27:53 +00:00
|
|
|
MergeTreeDataPartCompact(
|
2019-10-10 16:30:30 +00:00
|
|
|
const MergeTreeData & storage_,
|
|
|
|
const String & name_,
|
|
|
|
const MergeTreePartInfo & info_,
|
2022-10-22 22:51:59 +00:00
|
|
|
const MutableDataPartStoragePtr & data_part_storage_,
|
2021-02-10 14:12:49 +00:00
|
|
|
const IMergeTreeDataPart * parent_part_ = nullptr);
|
2019-10-10 16:30:30 +00:00
|
|
|
|
2019-12-18 16:41:11 +00:00
|
|
|
MergeTreeDataPartCompact(
|
2019-10-10 16:30:30 +00:00
|
|
|
MergeTreeData & storage_,
|
|
|
|
const String & name_,
|
2022-10-22 22:51:59 +00:00
|
|
|
const MutableDataPartStoragePtr & data_part_storage_,
|
2021-02-10 14:12:49 +00:00
|
|
|
const IMergeTreeDataPart * parent_part_ = nullptr);
|
2019-10-10 16:30:30 +00:00
|
|
|
|
|
|
|
MergeTreeReaderPtr getReader(
|
|
|
|
const NamesAndTypesList & columns,
|
2020-06-17 16:39:58 +00:00
|
|
|
const StorageMetadataPtr & metadata_snapshot,
|
2019-10-10 16:30:30 +00:00
|
|
|
const MarkRanges & mark_ranges,
|
|
|
|
UncompressedCache * uncompressed_cache,
|
|
|
|
MarkCache * mark_cache,
|
2019-12-18 15:54:45 +00:00
|
|
|
const MergeTreeReaderSettings & reader_settings_,
|
2020-03-18 03:27:32 +00:00
|
|
|
const ValueSizeMap & avg_value_size_hints,
|
|
|
|
const ReadBufferFromFileBase::ProfileCallback & profile_callback) const override;
|
2019-12-18 16:41:11 +00:00
|
|
|
|
2019-10-21 15:33:59 +00:00
|
|
|
MergeTreeWriterPtr getWriter(
|
|
|
|
const NamesAndTypesList & columns_list,
|
2020-06-17 12:39:20 +00:00
|
|
|
const StorageMetadataPtr & metadata_snapshot,
|
2019-11-07 11:11:38 +00:00
|
|
|
const std::vector<MergeTreeIndexPtr> & indices_to_recalc,
|
|
|
|
const CompressionCodecPtr & default_codec_,
|
2019-12-18 15:54:45 +00:00
|
|
|
const MergeTreeWriterSettings & writer_settings,
|
2022-10-22 22:51:59 +00:00
|
|
|
const MergeTreeIndexGranularity & computed_index_granularity) override;
|
2019-10-10 16:30:30 +00:00
|
|
|
|
|
|
|
bool isStoredOnDisk() const override { return true; }
|
|
|
|
|
2021-10-10 20:22:58 +00:00
|
|
|
bool isStoredOnRemoteDisk() const override;
|
|
|
|
|
2022-04-21 12:39:12 +00:00
|
|
|
bool isStoredOnRemoteDiskWithZeroCopySupport() const override;
|
|
|
|
|
2020-09-14 11:22:17 +00:00
|
|
|
bool hasColumnFiles(const NameAndTypePair & column) const override;
|
2019-12-12 18:55:19 +00:00
|
|
|
|
2019-12-19 13:10:57 +00:00
|
|
|
String getFileNameForColumn(const NameAndTypePair & /* column */) const override { return DATA_FILE_NAME; }
|
|
|
|
|
2019-11-18 12:22:27 +00:00
|
|
|
~MergeTreeDataPartCompact() override;
|
|
|
|
|
2022-09-05 16:55:00 +00:00
|
|
|
protected:
|
|
|
|
static void loadIndexGranularityImpl(
|
|
|
|
MergeTreeIndexGranularity & index_granularity_, const MergeTreeIndexGranularityInfo & index_granularity_info_,
|
2022-09-12 16:09:55 +00:00
|
|
|
size_t columns_count, const DataPartStoragePtr & data_part_storage_);
|
2022-09-05 16:55:00 +00:00
|
|
|
|
2019-10-10 16:30:30 +00:00
|
|
|
private:
|
2020-01-16 16:15:01 +00:00
|
|
|
void checkConsistency(bool require_part_metadata) const override;
|
|
|
|
|
2019-10-10 16:30:30 +00:00
|
|
|
/// Loads marks index granularity into memory
|
2019-10-31 14:44:17 +00:00
|
|
|
void loadIndexGranularity() override;
|
2020-03-23 12:19:43 +00:00
|
|
|
|
|
|
|
/// Compact parts doesn't support per column size, only total size
|
2020-06-29 20:36:18 +00:00
|
|
|
void calculateEachColumnSizes(ColumnSizeByName & each_columns_size, ColumnSize & total_size) const override;
|
2019-10-10 16:30:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|