Skip to content

Commit

Permalink
Consider allocatedBytes() instead of bytes() in Storage{Buffer,Memory}.
Browse files Browse the repository at this point in the history
  • Loading branch information
zlobober committed Jun 24, 2020
1 parent 3e6da7d commit 29d2928
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/Storages/IStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,14 +449,18 @@ class IStorage : public std::enable_shared_from_this<IStorage>, public TypePromo
}

/// If it is possible to quickly determine exact number of bytes for the table on storage:
/// - memory (approximated)
/// - memory (approximated, resident)
/// - disk (compressed)
///
/// Used for:
/// - For total_bytes column in system.tables
//
/// Does not takes underlying Storage (if any) into account
/// (since for Buffer we still need to know how much bytes it uses).
///
/// Memory part should be estimated as a resident memory size.
/// In particular, alloctedBytes() is preferable over bytes()
/// when considering in-memory blocks.
virtual std::optional<UInt64> totalBytes() const
{
return {};
Expand Down
2 changes: 1 addition & 1 deletion src/Storages/StorageBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ std::optional<UInt64> StorageBuffer::totalBytes() const
for (const auto & buffer : buffers)
{
std::lock_guard lock(buffer.mutex);
bytes += buffer.data.bytes();
bytes += buffer.data.allocatedBytes();
}
return bytes;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Storages/StorageMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ std::optional<UInt64> StorageMemory::totalBytes() const
UInt64 bytes = 0;
std::lock_guard lock(mutex);
for (const auto & buffer : data)
bytes += buffer.bytes();
bytes += buffer.allocatedBytes();
return bytes;
}

Expand Down

0 comments on commit 29d2928

Please sign in to comment.