mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 17:12:03 +00:00
Really atomic metadata
This commit is contained in:
parent
4de5331b0d
commit
d4c49816ab
@ -12,7 +12,7 @@ namespace DB
|
||||
struct BlockIO;
|
||||
class Context;
|
||||
struct StorageInMemoryMetadata;
|
||||
using StorageMetadataPtr = std::shared_ptr<StorageInMemoryMetadata>;
|
||||
using StorageMetadataPtr = std::shared_ptr<const StorageInMemoryMetadata>;
|
||||
|
||||
/** Prepares an input stream which produce data containing in INSERT query
|
||||
* Head of inserting data could be stored in INSERT ast directly
|
||||
|
@ -32,7 +32,7 @@ class ASTSelectQuery;
|
||||
struct ASTTablesInSelectQueryElement;
|
||||
|
||||
struct StorageInMemoryMetadata;
|
||||
using StorageMetadataPtr = std::shared_ptr<StorageInMemoryMetadata>;
|
||||
using StorageMetadataPtr = std::shared_ptr<const StorageInMemoryMetadata>;
|
||||
|
||||
/// Create columns in block or return false if not possible
|
||||
bool sanitizeBlock(Block & block);
|
||||
|
@ -14,7 +14,7 @@ class ASTSelectQuery;
|
||||
class TableJoin;
|
||||
struct SelectQueryOptions;
|
||||
struct StorageInMemoryMetadata;
|
||||
using StorageMetadataPtr = std::shared_ptr<StorageInMemoryMetadata>;
|
||||
using StorageMetadataPtr = std::shared_ptr<const StorageInMemoryMetadata>;
|
||||
|
||||
/// Joined tables' columns resolver.
|
||||
/// We want to get each table structure at most once per table occurance. Or even better once per table.
|
||||
|
@ -17,7 +17,7 @@ struct Settings;
|
||||
struct SelectQueryOptions;
|
||||
using Scalars = std::map<String, Block>;
|
||||
struct StorageInMemoryMetadata;
|
||||
using StorageMetadataPtr = std::shared_ptr<StorageInMemoryMetadata>;
|
||||
using StorageMetadataPtr = std::shared_ptr<const StorageInMemoryMetadata>;
|
||||
|
||||
struct SyntaxAnalyzerResult
|
||||
{
|
||||
|
@ -82,7 +82,7 @@ public:
|
||||
IStorage() = delete;
|
||||
/// Storage fields should be initialized in separate methods like setColumns
|
||||
/// or setTableTTLs.
|
||||
explicit IStorage(StorageID storage_id_) : storage_id(std::move(storage_id_)), metadata(std::make_shared<StorageInMemoryMetadata>()) {} //-V730
|
||||
explicit IStorage(StorageID storage_id_) : storage_id(std::move(storage_id_)), metadata(std::make_unique<StorageInMemoryMetadata>()) {} //-V730
|
||||
|
||||
virtual ~IStorage() = default;
|
||||
IStorage(const IStorage &) = delete;
|
||||
@ -137,9 +137,12 @@ public:
|
||||
|
||||
public: /// thread-unsafe part. lockStructure must be acquired
|
||||
|
||||
StorageInMemoryMetadata getInMemoryMetadata() const { return *metadata; }
|
||||
StorageMetadataPtr getInMemoryMetadataPtr() const { return metadata; }
|
||||
void setInMemoryMetadata(const StorageInMemoryMetadata & metadata_) { metadata = std::make_shared<StorageInMemoryMetadata>(metadata_); }
|
||||
StorageInMemoryMetadata getInMemoryMetadata() const { return *metadata.get(); }
|
||||
StorageMetadataPtr getInMemoryMetadataPtr() const { return metadata.get(); }
|
||||
void setInMemoryMetadata(const StorageInMemoryMetadata & metadata_)
|
||||
{
|
||||
metadata.set(std::make_unique<StorageInMemoryMetadata>(metadata_));
|
||||
}
|
||||
|
||||
|
||||
/// Return list of virtual columns (like _part, _table, etc). In the vast
|
||||
@ -165,9 +168,7 @@ private:
|
||||
StorageID storage_id;
|
||||
mutable std::mutex id_mutex;
|
||||
|
||||
/// TODO (alesap) just use multiversion for atomic metadata
|
||||
mutable std::mutex ttl_mutex;
|
||||
StorageMetadataPtr metadata;
|
||||
MultiVersionStorageMetadataPtr metadata;
|
||||
private:
|
||||
RWLockImpl::LockHolder tryLockTimed(
|
||||
const RWLock & rwlock, RWLockImpl::Type type, const String & query_id, const SettingSeconds & acquire_timeout) const;
|
||||
|
@ -17,7 +17,7 @@ class ASTSelectQuery;
|
||||
class ASTFunction;
|
||||
class MergeTreeData;
|
||||
struct StorageInMemoryMetadata;
|
||||
using StorageMetadataPtr = std::shared_ptr<StorageInMemoryMetadata>;
|
||||
using StorageMetadataPtr = std::shared_ptr<const StorageInMemoryMetadata>;
|
||||
|
||||
/** Identifies WHERE expressions that can be placed in PREWHERE by calculating respective
|
||||
* sizes of columns used in particular expression and identifying "good" conditions of
|
||||
|
@ -194,7 +194,7 @@ struct StorageInMemoryMetadata
|
||||
void check(const Block & block, bool need_all = false) const;
|
||||
};
|
||||
|
||||
using StorageMetadataPtr = std::shared_ptr<StorageInMemoryMetadata>;
|
||||
using StorageMetadataPtr = std::shared_ptr<const StorageInMemoryMetadata>;
|
||||
using MultiVersionStorageMetadataPtr = MultiVersion<StorageInMemoryMetadata>;
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user