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_,
|
2020-06-03 13:27:54 +00:00
|
|
|
const VolumePtr & volume_,
|
2020-04-14 19:47:19 +00:00
|
|
|
const std::optional<String> & relative_path_ = {});
|
|
|
|
|
|
|
|
MergeTreeDataPartInMemory(
|
|
|
|
MergeTreeData & storage_,
|
|
|
|
const String & name_,
|
2020-06-03 13:27:54 +00:00
|
|
|
const VolumePtr & volume_,
|
2020-04-14 19:47:19 +00:00
|
|
|
const std::optional<String> & relative_path_ = {});
|
|
|
|
|
|
|
|
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,
|
|
|
|
const MergeTreeIndexGranularity & computed_index_granularity) const override;
|
|
|
|
|
|
|
|
bool isStoredOnDisk() const override { return false; }
|
2021-01-12 23:20:32 +00:00
|
|
|
bool hasColumnFiles(const NameAndTypePair & column) const override { return !!getColumnPosition(column.name); }
|
2020-04-14 19:47:19 +00:00
|
|
|
String getFileNameForColumn(const NameAndTypePair & /* column */) const override { return ""; }
|
2020-06-03 18:59:18 +00:00
|
|
|
void renameTo(const String & new_relative_path, bool remove_new_dir_if_exists) const 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
|
|
|
|
2020-06-26 11:30:23 +00:00
|
|
|
void flushToDisk(const String & base_path, 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>;
|
2020-06-05 20:47:46 +00:00
|
|
|
DataPartInMemoryPtr asInMemoryPart(const MergeTreeDataPartPtr & part);
|
2020-04-14 19:47:19 +00:00
|
|
|
|
|
|
|
}
|