Remove virtual columns as separate field from IStorage

This commit is contained in:
alesapin 2020-04-23 18:07:19 +03:00
parent 82a71e9598
commit b0a73589b0
3 changed files with 5 additions and 10 deletions

View File

@ -31,7 +31,7 @@ namespace ErrorCodes
extern const int DEADLOCK_AVOIDED;
}
IStorage::IStorage(StorageID storage_id_, ColumnsDescription virtuals_) : storage_id(std::move(storage_id_)), virtuals(std::move(virtuals_))
IStorage::IStorage(StorageID storage_id_, ColumnsDescription virtuals_) : storage_id(std::move(storage_id_)), columns(std::move(virtuals_))
{
}
@ -40,11 +40,6 @@ const ColumnsDescription & IStorage::getColumns() const
return columns;
}
const ColumnsDescription & IStorage::getVirtuals() const
{
return virtuals;
}
const IndicesDescription & IStorage::getIndices() const
{
return indices;
@ -296,9 +291,11 @@ void IStorage::setColumns(ColumnsDescription columns_)
{
if (columns_.getOrdinary().empty())
throw Exception("Empty list of columns passed", ErrorCodes::EMPTY_LIST_OF_COLUMNS_PASSED);
ColumnsDescription old_virtuals(columns.getVirtuals(), true);
columns = std::move(columns_);
for (const auto & column : virtuals)
for (const auto & column : old_virtuals)
{
if (!columns.has(column.name))
columns.add(column);

View File

@ -144,7 +144,6 @@ public:
public: /// thread-unsafe part. lockStructure must be acquired
virtual const ColumnsDescription & getColumns() const; /// returns combined set of columns
virtual void setColumns(ColumnsDescription columns_); /// sets only real columns, possibly overwrites virtual ones.
const ColumnsDescription & getVirtuals() const;
const IndicesDescription & getIndices() const;
const ConstraintsDescription & getConstraints() const;
@ -191,7 +190,6 @@ private:
StorageID storage_id;
mutable std::mutex id_mutex;
ColumnsDescription columns; /// combined real and virtual columns
const ColumnsDescription virtuals = {};
IndicesDescription indices;
ConstraintsDescription constraints;

View File

@ -58,7 +58,7 @@ public:
protected:
StorageFromMergeTreeDataPart(const MergeTreeData::DataPartPtr & part_)
: IStorage(getIDFromPart(part_), part_->storage.getVirtuals())
: IStorage(getIDFromPart(part_), ColumnsDescription(part_->storage.getColumns().getVirtuals(), true))
, part(part_)
{
setColumns(part_->storage.getColumns());