提交 611f565f 编写于 作者: A Azat Khuzhin

Implement totalRows() for StorageMemory

上级 83f1fcaf
...@@ -136,6 +136,15 @@ void StorageMemory::truncate(const ASTPtr &, const Context &, TableStructureWrit ...@@ -136,6 +136,15 @@ void StorageMemory::truncate(const ASTPtr &, const Context &, TableStructureWrit
data.clear(); data.clear();
} }
std::optional<UInt64> StorageMemory::totalRows() const
{
UInt64 rows = 0;
std::lock_guard lock(mutex);
for (auto & buffer : data)
rows += buffer.rows();
return rows;
}
void registerStorageMemory(StorageFactory & factory) void registerStorageMemory(StorageFactory & factory)
{ {
......
...@@ -42,11 +42,13 @@ public: ...@@ -42,11 +42,13 @@ public:
void truncate(const ASTPtr &, const Context &, TableStructureWriteLockHolder &) override; void truncate(const ASTPtr &, const Context &, TableStructureWriteLockHolder &) override;
std::optional<UInt64> totalRows() const override;
private: private:
/// The data itself. `list` - so that when inserted to the end, the existing iterators are not invalidated. /// The data itself. `list` - so that when inserted to the end, the existing iterators are not invalidated.
BlocksList data; BlocksList data;
std::mutex mutex; mutable std::mutex mutex;
protected: protected:
StorageMemory(const StorageID & table_id_, ColumnsDescription columns_description_, ConstraintsDescription constraints_); StorageMemory(const StorageID & table_id_, ColumnsDescription columns_description_, ConstraintsDescription constraints_);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册