ClickHouse/src/Storages/System/StorageSystemPartsBase.h

83 lines
2.0 KiB
C++
Raw Normal View History

#pragma once
2021-10-02 07:13:14 +00:00
#include <base/shared_ptr_helper.h>
#include <Formats/FormatSettings.h>
#include <Storages/IStorage.h>
#include <Storages/MergeTree/MergeTreeData.h>
namespace DB
{
class Context;
struct StoragesInfo
{
2019-05-21 13:58:55 +00:00
StoragePtr storage = nullptr;
2020-06-18 16:10:47 +00:00
TableLockHolder table_lock;
String database;
String table;
String engine;
2019-05-21 13:58:55 +00:00
bool need_inactive_parts = false;
MergeTreeData * data = nullptr;
operator bool() const { return storage != nullptr; }
MergeTreeData::DataPartsVector
getParts(MergeTreeData::DataPartStateVector & state, bool has_state_column, bool require_projection_parts = false) const;
};
/** A helper class that enumerates the storages that match given query. */
class StoragesInfoStream
{
public:
StoragesInfoStream(const SelectQueryInfo & query_info, ContextPtr context);
StoragesInfo next();
private:
String query_id;
Settings settings;
ColumnPtr database_column;
ColumnPtr table_column;
ColumnPtr active_column;
size_t next_row;
size_t rows;
using StoragesMap = std::map<std::pair<String, String>, StoragePtr>;
StoragesMap storages;
};
/** Implements system table 'parts' which allows to get information about data parts for tables of MergeTree family.
*/
class StorageSystemPartsBase : public IStorage
{
public:
2020-08-06 12:24:05 +00:00
Pipe read(
const Names & column_names,
2020-06-17 14:32:25 +00:00
const StorageMetadataPtr & metadata_snapshot,
SelectQueryInfo & query_info,
ContextPtr context,
QueryProcessingStage::Enum processed_stage,
size_t max_block_size,
unsigned num_streams) override;
NamesAndTypesList getVirtuals() const override;
2020-04-27 13:55:30 +00:00
private:
2020-06-17 14:32:25 +00:00
bool hasStateColumn(const Names & column_names, const StorageMetadataPtr & metadata_snapshot) const;
protected:
const FormatSettings format_settings;
2020-08-12 20:40:13 +00:00
StorageSystemPartsBase(const StorageID & table_id_, NamesAndTypesList && columns_);
virtual void
2021-03-01 10:25:20 +00:00
processNextStorage(MutableColumns & columns, std::vector<UInt8> & columns_mask, const StoragesInfo & info, bool has_state_column) = 0;
};
}