mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Merge pull request #22867 from azat/sparse_hashed-bytes_allocated-fix
Fix bytes_allocated for sparse_hashed dictionaries
This commit is contained in:
commit
f7edcdf7c8
@ -567,7 +567,11 @@ void HashedDictionary<dictionary_key_type, sparse>::calculateBytesAllocated()
|
||||
|
||||
if constexpr (sparse || std::is_same_v<AttributeValueType, Field>)
|
||||
{
|
||||
bytes_allocated += container.max_size() * (sizeof(KeyType) + sizeof(AttributeValueType));
|
||||
/// bucket_count() - Returns table size, that includes empty and deleted
|
||||
/// size() - Returns table size, w/o empty and deleted
|
||||
/// and since this is sparsehash, empty cells should not be significant,
|
||||
/// and since items cannot be removed from the dictionary, deleted is also not important.
|
||||
bytes_allocated += container.size() * (sizeof(KeyType) + sizeof(AttributeValueType));
|
||||
bucket_count = container.bucket_count();
|
||||
}
|
||||
else
|
||||
|
@ -0,0 +1 @@
|
||||
4422
|
@ -0,0 +1,30 @@
|
||||
DROP TABLE IF EXISTS data_01802;
|
||||
DROP DICTIONARY IF EXISTS dict_01802;
|
||||
|
||||
CREATE TABLE data_01802
|
||||
(
|
||||
id UInt64,
|
||||
value UInt16
|
||||
)
|
||||
ENGINE = Memory();
|
||||
|
||||
INSERT INTO data_01802 VALUES(0, 0);
|
||||
INSERT INTO data_01802 VALUES(1, 0);
|
||||
INSERT INTO data_01802 VALUES(2, 0);
|
||||
|
||||
CREATE DICTIONARY dict_01802
|
||||
(
|
||||
id UInt64,
|
||||
value UInt16
|
||||
)
|
||||
PRIMARY KEY id
|
||||
SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'data_01802'))
|
||||
LIFETIME(MIN 1 MAX 1000)
|
||||
LAYOUT(SPARSE_HASHED());
|
||||
|
||||
SYSTEM RELOAD DICTIONARY dict_01802;
|
||||
|
||||
SELECT bytes_allocated FROM system.dictionaries WHERE database = currentDatabase() AND name = 'dict_01802';
|
||||
|
||||
DROP TABLE data_01802;
|
||||
DROP DICTIONARY dict_01802;
|
Loading…
Reference in New Issue
Block a user