2020-04-14 19:47:19 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Storages/MergeTree/IMergeTreeDataPart.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2020-07-09 01:00:16 +00:00
|
|
|
class UncompressedCache;
|
|
|
|
|
2020-04-14 19:47:19 +00:00
|
|
|
class MergeTreeDataPartInMemory : public IMergeTreeDataPart
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MergeTreeDataPartInMemory(
|
|
|
|
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);
|
2020-04-14 19:47:19 +00:00
|
|
|
|
|
|
|
MergeTreeDataPartInMemory(
|
|
|
|
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);
|
2020-04-14 19:47:19 +00:00
|
|
|
|
|
|
|
MergeTreeReaderPtr getReader(
|
|
|
|
const NamesAndTypesList & columns,
|
2020-06-26 11:30:23 +00:00
|
|
|
const StorageMetadataPtr & metadata_snapshot,
|
2020-04-14 19:47:19 +00:00
|
|
|
const MarkRanges & mark_ranges,
|
|
|
|
UncompressedCache * uncompressed_cache,
|
|
|
|
MarkCache * mark_cache,
|
|
|
|
const MergeTreeReaderSettings & reader_settings_,
|
|
|
|
const ValueSizeMap & avg_value_size_hints,
|
|
|
|
const ReadBufferFromFileBase::ProfileCallback & profile_callback) const override;
|
2020-10-23 17:57:17 +00:00
|
|
|
|
2020-04-14 19:47:19 +00:00
|
|
|
MergeTreeWriterPtr getWriter(
|
|
|
|
const NamesAndTypesList & columns_list,
|
2020-06-26 11:30:23 +00:00
|
|
|
const StorageMetadataPtr & metadata_snapshot,
|
2020-04-14 19:47:19 +00:00
|
|
|
const std::vector<MergeTreeIndexPtr> & indices_to_recalc,
|
|
|
|
const CompressionCodecPtr & default_codec_,
|
|
|
|
const MergeTreeWriterSettings & writer_settings,
|
2022-10-22 22:51:59 +00:00
|
|
|
const MergeTreeIndexGranularity & computed_index_granularity) override;
|
2020-04-14 19:47:19 +00:00
|
|
|
|
|
|
|
bool isStoredOnDisk() const override { return false; }
|
2021-10-10 20:22:58 +00:00
|
|
|
bool isStoredOnRemoteDisk() const override { return false; }
|
2022-04-21 12:39:12 +00:00
|
|
|
bool isStoredOnRemoteDiskWithZeroCopySupport() const override { return false; }
|
2021-11-02 17:44:15 +00:00
|
|
|
bool hasColumnFiles(const NameAndTypePair & column) const override { return !!getColumnPosition(column.getNameInStorage()); }
|
2020-04-14 19:47:19 +00:00
|
|
|
String getFileNameForColumn(const NameAndTypePair & /* column */) const override { return ""; }
|
2022-10-23 03:29:26 +00:00
|
|
|
void renameTo(const String & new_relative_path, bool remove_new_dir_if_exists) override;
|
2020-06-26 11:30:23 +00:00
|
|
|
void makeCloneInDetached(const String & prefix, const StorageMetadataPtr & metadata_snapshot) const override;
|
2020-04-14 19:47:19 +00:00
|
|
|
|
2022-10-22 22:51:59 +00:00
|
|
|
MutableDataPartStoragePtr flushToDisk(const String & new_relative_path, const StorageMetadataPtr & metadata_snapshot) const;
|
2020-05-29 16:58:08 +00:00
|
|
|
|
2020-06-22 18:56:53 +00:00
|
|
|
/// Returns hash of parts's block
|
|
|
|
Checksum calculateBlockChecksum() const;
|
|
|
|
|
2020-04-14 19:47:19 +00:00
|
|
|
mutable Block block;
|
|
|
|
|
|
|
|
private:
|
2020-04-20 01:38:38 +00:00
|
|
|
mutable std::condition_variable is_merged;
|
|
|
|
|
2020-06-29 20:36:18 +00:00
|
|
|
/// Calculates uncompressed sizes in memory.
|
|
|
|
void calculateEachColumnSizes(ColumnSizeByName & each_columns_size, ColumnSize & total_size) const override;
|
2020-04-14 19:47:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
using DataPartInMemoryPtr = std::shared_ptr<const MergeTreeDataPartInMemory>;
|
2022-10-22 22:51:59 +00:00
|
|
|
using MutableDataPartInMemoryPtr = std::shared_ptr<MergeTreeDataPartInMemory>;
|
|
|
|
|
2020-06-05 20:47:46 +00:00
|
|
|
DataPartInMemoryPtr asInMemoryPart(const MergeTreeDataPartPtr & part);
|
2020-04-14 19:47:19 +00:00
|
|
|
|
|
|
|
}
|