add comments and functional test

This commit is contained in:
xbthink 2023-05-07 16:22:05 +08:00
parent bc16cc59ff
commit 72dd039d1c
3 changed files with 36 additions and 0 deletions

View File

@ -54,6 +54,9 @@ public:
bool created_from_ddl)>;
bool isComplex(const std::string & layout_type) const;
/// if the argument `layout_type` is not complex layout and has corresponding complex layout,
/// change `layout_type` to corresponding complex and return true; otherwise do nothing and return false.
bool convertToComplex(std::string & layout_type) const;
void registerLayout(const std::string & layout_type, LayoutCreateFunction create_layout, bool is_layout_complex, bool has_layout_complex = true);

View File

@ -0,0 +1,4 @@
dict_flat_simple Flat
dict_hashed_simple Hashed
dict_hashed_complex ComplexKeyHashed
dict_hashed_simple_auto_convert ComplexKeyHashed

View File

@ -0,0 +1,29 @@
DROP DICTIONARY IF EXISTS dict_flat_simple;
DROP DICTIONARY IF EXISTS dict_hashed_simple;
DROP DICTIONARY IF EXISTS dict_hashed_complex;
DROP DICTIONARY IF EXISTS dict_hashed_simple_auto_convert;
DROP TABLE IF EXISTS dict_data;
CREATE TABLE dict_data (v0 UInt16, v1 UInt16, v2 UInt16, v3 UInt16, v4 UInt16) engine=Memory() AS SELECT number, number%65535, number%65535, number%6553, number%655355 FROM numbers(100);
CREATE DICTIONARY dict_flat_simple (v0 UInt16, v1 UInt16, v2 UInt16) PRIMARY KEY v0 SOURCE(CLICKHOUSE(TABLE 'dict_data')) LIFETIME(0) LAYOUT(flat());
SYSTEM RELOAD DICTIONARY dict_flat_simple;
SELECT name, type FROM system.dictionaries WHERE database = currentDatabase() AND name = 'dict_flat_simple';
DROP DICTIONARY dict_flat_simple;
CREATE DICTIONARY dict_hashed_simple (v0 UInt16, v1 UInt16, v2 UInt16) PRIMARY KEY v0 SOURCE(CLICKHOUSE(TABLE 'dict_data')) LIFETIME(0) LAYOUT(hashed());
SYSTEM RELOAD DICTIONARY dict_hashed_simple;
SELECT name, type FROM system.dictionaries WHERE database = currentDatabase() AND name = 'dict_hashed_simple';
DROP DICTIONARY dict_hashed_simple;
CREATE DICTIONARY dict_hashed_complex (v0 UInt16, v1 UInt16, v2 UInt16) PRIMARY KEY v0,v1 SOURCE(CLICKHOUSE(TABLE 'dict_data')) LIFETIME(0) LAYOUT(complex_key_hashed());
SYSTEM RELOAD DICTIONARY dict_hashed_complex;
SELECT name, type FROM system.dictionaries WHERE database = currentDatabase() AND name = 'dict_hashed_complex';
DROP DICTIONARY dict_hashed_complex;
CREATE DICTIONARY dict_hashed_simple_auto_convert (v0 UInt16, v1 UInt16, v2 UInt16) PRIMARY KEY v0,v1 SOURCE(CLICKHOUSE(TABLE 'dict_data')) LIFETIME(0) LAYOUT(hashed());
SYSTEM RELOAD DICTIONARY dict_hashed_simple_auto_convert;
SELECT name, type FROM system.dictionaries WHERE database = currentDatabase() AND name = 'dict_hashed_simple_auto_convert';
DROP DICTIONARY dict_hashed_simple_auto_convert;
DROP TABLE dict_data;