mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Updated tests
This commit is contained in:
parent
92b79420a4
commit
6ab451d41d
@ -865,15 +865,14 @@ namespace
|
||||
directory_path = std::filesystem::path{config.getString("path")}.concat(directory_path).string();
|
||||
|
||||
const size_t max_stored_keys_in_partition = config.getInt64(dictionary_configuration_prefix + "max_stored_keys", DEFAULT_MAX_STORED_KEYS);
|
||||
/// TODO: FIX
|
||||
// const size_t rounded_size = roundUpToPowerOfTwoOrZero(max_stored_keys_in_partition);
|
||||
const size_t rounded_size = roundUpToPowerOfTwoOrZero(max_stored_keys_in_partition);
|
||||
|
||||
SSDCacheDictionaryStorageConfiguration configuration {
|
||||
strict_max_lifetime_seconds,
|
||||
dict_lifetime,
|
||||
directory_path,
|
||||
max_partitions_count,
|
||||
max_stored_keys_in_partition,
|
||||
rounded_size,
|
||||
block_size,
|
||||
file_size / block_size,
|
||||
read_buffer_size / block_size,
|
||||
|
@ -1,12 +1,12 @@
|
||||
SET send_logs_level = 'none';
|
||||
|
||||
DROP DATABASE IF EXISTS database_for_dict;
|
||||
DROP DATABASE IF EXISTS 01053_db;
|
||||
|
||||
CREATE DATABASE database_for_dict Engine = Ordinary;
|
||||
CREATE DATABASE 01053_db Engine = Ordinary;
|
||||
|
||||
DROP TABLE IF EXISTS database_for_dict.table_for_dict;
|
||||
DROP TABLE IF EXISTS 01053_db.table_for_dict;
|
||||
|
||||
CREATE TABLE database_for_dict.table_for_dict
|
||||
CREATE TABLE 01053_db.table_for_dict
|
||||
(
|
||||
id UInt64,
|
||||
a UInt64,
|
||||
@ -16,16 +16,16 @@ CREATE TABLE database_for_dict.table_for_dict
|
||||
ENGINE = MergeTree()
|
||||
ORDER BY id;
|
||||
|
||||
INSERT INTO database_for_dict.table_for_dict VALUES (1, 100, -100, 'clickhouse'), (2, 3, 4, 'database'), (5, 6, 7, 'columns'), (10, 9, 8, '');
|
||||
INSERT INTO database_for_dict.table_for_dict SELECT number, 0, -1, 'a' FROM system.numbers WHERE number NOT IN (1, 2, 5, 10) LIMIT 370;
|
||||
INSERT INTO database_for_dict.table_for_dict SELECT number, 0, -1, 'b' FROM system.numbers WHERE number NOT IN (1, 2, 5, 10) LIMIT 370, 370;
|
||||
INSERT INTO database_for_dict.table_for_dict SELECT number, 0, -1, 'c' FROM system.numbers WHERE number NOT IN (1, 2, 5, 10) LIMIT 700, 370;
|
||||
INSERT INTO 01053_db.table_for_dict VALUES (1, 100, -100, 'clickhouse'), (2, 3, 4, 'database'), (5, 6, 7, 'columns'), (10, 9, 8, '');
|
||||
INSERT INTO 01053_db.table_for_dict SELECT number, 0, -1, 'a' FROM system.numbers WHERE number NOT IN (1, 2, 5, 10) LIMIT 370;
|
||||
INSERT INTO 01053_db.table_for_dict SELECT number, 0, -1, 'b' FROM system.numbers WHERE number NOT IN (1, 2, 5, 10) LIMIT 370, 370;
|
||||
INSERT INTO 01053_db.table_for_dict SELECT number, 0, -1, 'c' FROM system.numbers WHERE number NOT IN (1, 2, 5, 10) LIMIT 700, 370;
|
||||
|
||||
DROP DICTIONARY IF EXISTS database_for_dict.ssd_dict;
|
||||
DROP DICTIONARY IF EXISTS 01053_db.ssd_dict;
|
||||
|
||||
-- FIXME filesystem error: in create_directory: Permission denied [/var/lib/clickhouse]
|
||||
-- Probably we need rewrite it to integration test
|
||||
CREATE DICTIONARY database_for_dict.ssd_dict
|
||||
CREATE DICTIONARY 01053_db.ssd_dict
|
||||
(
|
||||
id UInt64,
|
||||
a UInt64 DEFAULT 0,
|
||||
@ -33,40 +33,40 @@ CREATE DICTIONARY database_for_dict.ssd_dict
|
||||
c String DEFAULT 'none'
|
||||
)
|
||||
PRIMARY KEY id
|
||||
SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'table_for_dict' PASSWORD '' DB 'database_for_dict'))
|
||||
SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'table_for_dict' PASSWORD '' DB '01053_db'))
|
||||
LIFETIME(MIN 1000 MAX 2000)
|
||||
LAYOUT(SSD_CACHE(FILE_SIZE 8192 PATH '/var/lib/clickhouse/clickhouse_dicts/0d'));
|
||||
|
||||
SELECT 'TEST_SMALL';
|
||||
SELECT dictGetInt32('database_for_dict.ssd_dict', 'b', toUInt64(1));
|
||||
SELECT dictGetInt32('database_for_dict.ssd_dict', 'b', toUInt64(4));
|
||||
SELECT dictGetUInt64('database_for_dict.ssd_dict', 'a', toUInt64(5));
|
||||
SELECT dictGetUInt64('database_for_dict.ssd_dict', 'a', toUInt64(6));
|
||||
SELECT dictGetString('database_for_dict.ssd_dict', 'c', toUInt64(2));
|
||||
SELECT dictGetString('database_for_dict.ssd_dict', 'c', toUInt64(3));
|
||||
SELECT dictGetInt32('01053_db.ssd_dict', 'b', toUInt64(1));
|
||||
SELECT dictGetInt32('01053_db.ssd_dict', 'b', toUInt64(4));
|
||||
SELECT dictGetUInt64('01053_db.ssd_dict', 'a', toUInt64(5));
|
||||
SELECT dictGetUInt64('01053_db.ssd_dict', 'a', toUInt64(6));
|
||||
SELECT dictGetString('01053_db.ssd_dict', 'c', toUInt64(2));
|
||||
SELECT dictGetString('01053_db.ssd_dict', 'c', toUInt64(3));
|
||||
|
||||
SELECT * FROM database_for_dict.ssd_dict ORDER BY id;
|
||||
DROP DICTIONARY database_for_dict.ssd_dict;
|
||||
SELECT * FROM 01053_db.ssd_dict ORDER BY id;
|
||||
DROP DICTIONARY 01053_db.ssd_dict;
|
||||
|
||||
DROP TABLE IF EXISTS database_for_dict.keys_table;
|
||||
DROP TABLE IF EXISTS 01053_db.keys_table;
|
||||
|
||||
CREATE TABLE database_for_dict.keys_table
|
||||
CREATE TABLE 01053_db.keys_table
|
||||
(
|
||||
id UInt64
|
||||
)
|
||||
ENGINE = StripeLog();
|
||||
|
||||
INSERT INTO database_for_dict.keys_table VALUES (1);
|
||||
INSERT INTO database_for_dict.keys_table SELECT 11 + intHash64(number) % 1200 FROM system.numbers LIMIT 370;
|
||||
INSERT INTO database_for_dict.keys_table VALUES (2);
|
||||
INSERT INTO database_for_dict.keys_table SELECT 11 + intHash64(number) % 1200 FROM system.numbers LIMIT 370, 370;
|
||||
INSERT INTO database_for_dict.keys_table VALUES (5);
|
||||
INSERT INTO database_for_dict.keys_table SELECT 11 + intHash64(number) % 1200 FROM system.numbers LIMIT 700, 370;
|
||||
INSERT INTO database_for_dict.keys_table VALUES (10);
|
||||
INSERT INTO 01053_db.keys_table VALUES (1);
|
||||
INSERT INTO 01053_db.keys_table SELECT 11 + intHash64(number) % 1200 FROM system.numbers LIMIT 370;
|
||||
INSERT INTO 01053_db.keys_table VALUES (2);
|
||||
INSERT INTO 01053_db.keys_table SELECT 11 + intHash64(number) % 1200 FROM system.numbers LIMIT 370, 370;
|
||||
INSERT INTO 01053_db.keys_table VALUES (5);
|
||||
INSERT INTO 01053_db.keys_table SELECT 11 + intHash64(number) % 1200 FROM system.numbers LIMIT 700, 370;
|
||||
INSERT INTO 01053_db.keys_table VALUES (10);
|
||||
|
||||
DROP DICTIONARY IF EXISTS database_for_dict.ssd_dict;
|
||||
DROP DICTIONARY IF EXISTS 01053_db.ssd_dict;
|
||||
|
||||
CREATE DICTIONARY database_for_dict.ssd_dict
|
||||
CREATE DICTIONARY 01053_db.ssd_dict
|
||||
(
|
||||
id UInt64,
|
||||
a UInt64 DEFAULT 0,
|
||||
@ -74,86 +74,86 @@ CREATE DICTIONARY database_for_dict.ssd_dict
|
||||
c String DEFAULT 'none'
|
||||
)
|
||||
PRIMARY KEY id
|
||||
SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'table_for_dict' PASSWORD '' DB 'database_for_dict'))
|
||||
SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'table_for_dict' PASSWORD '' DB '01053_db'))
|
||||
LIFETIME(MIN 1000 MAX 2000)
|
||||
LAYOUT(SSD_CACHE(FILE_SIZE 8192 PATH '/var/lib/clickhouse/clickhouse_dicts/1d' BLOCK_SIZE 512 WRITE_BUFFER_SIZE 4096 MAX_STORED_KEYS 1000000));
|
||||
|
||||
SELECT 'UPDATE DICTIONARY';
|
||||
-- 118
|
||||
SELECT sum(dictGetUInt64('database_for_dict.ssd_dict', 'a', toUInt64(id))) FROM database_for_dict.keys_table;
|
||||
SELECT sum(dictGetUInt64('01053_db.ssd_dict', 'a', toUInt64(id))) FROM 01053_db.keys_table;
|
||||
|
||||
SELECT 'VALUE FROM DISK';
|
||||
-- -100
|
||||
SELECT dictGetInt32('database_for_dict.ssd_dict', 'b', toUInt64(1));
|
||||
SELECT dictGetInt32('01053_db.ssd_dict', 'b', toUInt64(1));
|
||||
|
||||
-- 'clickhouse'
|
||||
SELECT dictGetString('database_for_dict.ssd_dict', 'c', toUInt64(1));
|
||||
SELECT dictGetString('01053_db.ssd_dict', 'c', toUInt64(1));
|
||||
|
||||
SELECT 'VALUE FROM RAM BUFFER';
|
||||
-- 8
|
||||
SELECT dictGetInt32('database_for_dict.ssd_dict', 'b', toUInt64(10));
|
||||
SELECT dictGetInt32('01053_db.ssd_dict', 'b', toUInt64(10));
|
||||
|
||||
-- ''
|
||||
SELECT dictGetString('database_for_dict.ssd_dict', 'c', toUInt64(10));
|
||||
SELECT dictGetString('01053_db.ssd_dict', 'c', toUInt64(10));
|
||||
|
||||
SELECT 'VALUES FROM DISK AND RAM BUFFER';
|
||||
-- 118
|
||||
SELECT sum(dictGetUInt64('database_for_dict.ssd_dict', 'a', toUInt64(id))) FROM database_for_dict.keys_table;
|
||||
SELECT sum(dictGetUInt64('01053_db.ssd_dict', 'a', toUInt64(id))) FROM 01053_db.keys_table;
|
||||
|
||||
SELECT 'HAS';
|
||||
-- 1006
|
||||
SELECT count() FROM database_for_dict.keys_table WHERE dictHas('database_for_dict.ssd_dict', toUInt64(id));
|
||||
SELECT count() FROM 01053_db.keys_table WHERE dictHas('01053_db.ssd_dict', toUInt64(id));
|
||||
|
||||
SELECT 'VALUES NOT FROM TABLE';
|
||||
-- 0 -1 none
|
||||
SELECT dictGetUInt64('database_for_dict.ssd_dict', 'a', toUInt64(1000000)), dictGetInt32('database_for_dict.ssd_dict', 'b', toUInt64(1000000)), dictGetString('database_for_dict.ssd_dict', 'c', toUInt64(1000000));
|
||||
SELECT dictGetUInt64('database_for_dict.ssd_dict', 'a', toUInt64(1000000)), dictGetInt32('database_for_dict.ssd_dict', 'b', toUInt64(1000000)), dictGetString('database_for_dict.ssd_dict', 'c', toUInt64(1000000));
|
||||
SELECT dictGetUInt64('01053_db.ssd_dict', 'a', toUInt64(1000000)), dictGetInt32('01053_db.ssd_dict', 'b', toUInt64(1000000)), dictGetString('01053_db.ssd_dict', 'c', toUInt64(1000000));
|
||||
SELECT dictGetUInt64('01053_db.ssd_dict', 'a', toUInt64(1000000)), dictGetInt32('01053_db.ssd_dict', 'b', toUInt64(1000000)), dictGetString('01053_db.ssd_dict', 'c', toUInt64(1000000));
|
||||
|
||||
SELECT 'DUPLICATE KEYS';
|
||||
SELECT arrayJoin([1, 2, 3, 3, 2, 1]) AS id, dictGetInt32('database_for_dict.ssd_dict', 'b', toUInt64(id));
|
||||
SELECT arrayJoin([1, 2, 3, 3, 2, 1]) AS id, dictGetInt32('01053_db.ssd_dict', 'b', toUInt64(id));
|
||||
--SELECT
|
||||
DROP DICTIONARY IF EXISTS database_for_dict.ssd_dict;
|
||||
DROP DICTIONARY IF EXISTS 01053_db.ssd_dict;
|
||||
|
||||
DROP TABLE IF EXISTS database_for_dict.keys_table;
|
||||
DROP TABLE IF EXISTS 01053_db.keys_table;
|
||||
|
||||
CREATE TABLE database_for_dict.keys_table
|
||||
CREATE TABLE 01053_db.keys_table
|
||||
(
|
||||
id UInt64
|
||||
)
|
||||
ENGINE = MergeTree()
|
||||
ORDER BY id;
|
||||
|
||||
INSERT INTO database_for_dict.keys_table VALUES (1);
|
||||
INSERT INTO database_for_dict.keys_table SELECT intHash64(number) FROM system.numbers LIMIT 370;
|
||||
INSERT INTO database_for_dict.keys_table VALUES (2);
|
||||
INSERT INTO database_for_dict.keys_table SELECT intHash64(number) FROM system.numbers LIMIT 370, 370;
|
||||
INSERT INTO database_for_dict.keys_table VALUES (5);
|
||||
INSERT INTO database_for_dict.keys_table SELECT intHash64(number) FROM system.numbers LIMIT 700, 370;
|
||||
INSERT INTO database_for_dict.keys_table VALUES (10);
|
||||
INSERT INTO 01053_db.keys_table VALUES (1);
|
||||
INSERT INTO 01053_db.keys_table SELECT intHash64(number) FROM system.numbers LIMIT 370;
|
||||
INSERT INTO 01053_db.keys_table VALUES (2);
|
||||
INSERT INTO 01053_db.keys_table SELECT intHash64(number) FROM system.numbers LIMIT 370, 370;
|
||||
INSERT INTO 01053_db.keys_table VALUES (5);
|
||||
INSERT INTO 01053_db.keys_table SELECT intHash64(number) FROM system.numbers LIMIT 700, 370;
|
||||
INSERT INTO 01053_db.keys_table VALUES (10);
|
||||
|
||||
OPTIMIZE TABLE database_for_dict.keys_table;
|
||||
OPTIMIZE TABLE 01053_db.keys_table;
|
||||
|
||||
CREATE DICTIONARY database_for_dict.ssd_dict
|
||||
CREATE DICTIONARY 01053_db.ssd_dict
|
||||
(
|
||||
id UInt64,
|
||||
a UInt64 DEFAULT 0,
|
||||
b Int32 DEFAULT -1
|
||||
)
|
||||
PRIMARY KEY id
|
||||
SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'table_for_dict' PASSWORD '' DB 'database_for_dict'))
|
||||
SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'table_for_dict' PASSWORD '' DB '01053_db'))
|
||||
LIFETIME(MIN 1000 MAX 2000)
|
||||
LAYOUT(SSD_CACHE(FILE_SIZE 8192 PATH '/var/lib/clickhouse/clickhouse_dicts/2d' BLOCK_SIZE 512 WRITE_BUFFER_SIZE 1024 MAX_STORED_KEYS 10));
|
||||
|
||||
SELECT 'UPDATE DICTIONARY (MT)';
|
||||
-- 118
|
||||
SELECT sum(dictGetUInt64('database_for_dict.ssd_dict', 'a', toUInt64(id))) FROM database_for_dict.keys_table;
|
||||
SELECT sum(dictGetUInt64('01053_db.ssd_dict', 'a', toUInt64(id))) FROM 01053_db.keys_table;
|
||||
|
||||
SELECT 'VALUES FROM DISK AND RAM BUFFER (MT)';
|
||||
-- 118
|
||||
SELECT sum(dictGetUInt64('database_for_dict.ssd_dict', 'a', toUInt64(id))) FROM database_for_dict.keys_table;
|
||||
SELECT sum(dictGetUInt64('01053_db.ssd_dict', 'a', toUInt64(id))) FROM 01053_db.keys_table;
|
||||
|
||||
DROP DICTIONARY IF EXISTS database_for_dict.ssd_dict;
|
||||
DROP DICTIONARY IF EXISTS 01053_db.ssd_dict;
|
||||
|
||||
DROP TABLE IF EXISTS database_for_dict.table_for_dict;
|
||||
DROP TABLE IF EXISTS 01053_db.table_for_dict;
|
||||
|
||||
DROP DATABASE IF EXISTS database_for_dict;
|
||||
DROP DATABASE IF EXISTS 01053_db;
|
||||
|
@ -1,12 +1,12 @@
|
||||
SET send_logs_level = 'none';
|
||||
|
||||
DROP DATABASE IF EXISTS database_for_dict;
|
||||
DROP DATABASE IF EXISTS 01280_db;
|
||||
|
||||
CREATE DATABASE database_for_dict Engine = Ordinary;
|
||||
CREATE DATABASE 01280_db Engine = Ordinary;
|
||||
|
||||
DROP TABLE IF EXISTS database_for_dict.table_for_dict;
|
||||
DROP TABLE IF EXISTS 01280_db.table_for_dict;
|
||||
|
||||
CREATE TABLE database_for_dict.table_for_dict
|
||||
CREATE TABLE 01280_db.table_for_dict
|
||||
(
|
||||
k1 String,
|
||||
k2 Int32,
|
||||
@ -17,16 +17,16 @@ CREATE TABLE database_for_dict.table_for_dict
|
||||
ENGINE = MergeTree()
|
||||
ORDER BY (k1, k2);
|
||||
|
||||
INSERT INTO database_for_dict.table_for_dict VALUES (toString(1), 3, 100, -100, 'clickhouse'), (toString(2), -1, 3, 4, 'database'), (toString(5), -3, 6, 7, 'columns'), (toString(10), -20, 9, 8, '');
|
||||
INSERT INTO database_for_dict.table_for_dict SELECT toString(number), number + 1, 0, -1, 'a' FROM system.numbers WHERE number NOT IN (1, 2, 5, 10) LIMIT 370;
|
||||
INSERT INTO database_for_dict.table_for_dict SELECT toString(number), number + 10, 0, -1, 'b' FROM system.numbers WHERE number NOT IN (1, 2, 5, 10) LIMIT 370, 370;
|
||||
INSERT INTO database_for_dict.table_for_dict SELECT toString(number), number + 100, 0, -1, 'c' FROM system.numbers WHERE number NOT IN (1, 2, 5, 10) LIMIT 700, 370;
|
||||
INSERT INTO 01280_db.table_for_dict VALUES (toString(1), 3, 100, -100, 'clickhouse'), (toString(2), -1, 3, 4, 'database'), (toString(5), -3, 6, 7, 'columns'), (toString(10), -20, 9, 8, '');
|
||||
INSERT INTO 01280_db.table_for_dict SELECT toString(number), number + 1, 0, -1, 'a' FROM system.numbers WHERE number NOT IN (1, 2, 5, 10) LIMIT 370;
|
||||
INSERT INTO 01280_db.table_for_dict SELECT toString(number), number + 10, 0, -1, 'b' FROM system.numbers WHERE number NOT IN (1, 2, 5, 10) LIMIT 370, 370;
|
||||
INSERT INTO 01280_db.table_for_dict SELECT toString(number), number + 100, 0, -1, 'c' FROM system.numbers WHERE number NOT IN (1, 2, 5, 10) LIMIT 700, 370;
|
||||
|
||||
DROP DICTIONARY IF EXISTS database_for_dict.ssd_dict;
|
||||
DROP DICTIONARY IF EXISTS 01280_db.ssd_dict;
|
||||
|
||||
-- FIXME filesystem error: in create_directory: Permission denied [/var/lib/clickhouse]
|
||||
-- Probably we need rewrite it to integration test
|
||||
CREATE DICTIONARY database_for_dict.ssd_dict
|
||||
CREATE DICTIONARY 01280_db.ssd_dict
|
||||
(
|
||||
k1 String,
|
||||
k2 Int32,
|
||||
@ -35,7 +35,7 @@ CREATE DICTIONARY database_for_dict.ssd_dict
|
||||
c String DEFAULT 'none'
|
||||
)
|
||||
PRIMARY KEY k1, k2
|
||||
SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'table_for_dict' PASSWORD '' DB 'database_for_dict'))
|
||||
SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'table_for_dict' PASSWORD '' DB '01280_db'))
|
||||
LIFETIME(MIN 1000 MAX 2000)
|
||||
LAYOUT(COMPLEX_KEY_SSD_CACHE(FILE_SIZE 8192 PATH '/var/lib/clickhouse/clickhouse_dicts/0d'));
|
||||
|
||||
@ -43,52 +43,52 @@ SELECT 'TEST_SMALL';
|
||||
SELECT 'VALUE FROM RAM BUFFER';
|
||||
|
||||
-- NUMBER_OF_ARGUMENTS_DOESNT_MATCH
|
||||
SELECT dictHas('database_for_dict.ssd_dict', 'a', tuple('1')); -- { serverError 42 }
|
||||
SELECT dictHas('01280_db.ssd_dict', 'a', tuple('1')); -- { serverError 42 }
|
||||
|
||||
SELECT dictGetUInt64('database_for_dict.ssd_dict', 'a', tuple('1', toInt32(3)));
|
||||
SELECT dictGetInt32('database_for_dict.ssd_dict', 'b', tuple('1', toInt32(3)));
|
||||
SELECT dictGetString('database_for_dict.ssd_dict', 'c', tuple('1', toInt32(3)));
|
||||
SELECT dictGetUInt64('01280_db.ssd_dict', 'a', tuple('1', toInt32(3)));
|
||||
SELECT dictGetInt32('01280_db.ssd_dict', 'b', tuple('1', toInt32(3)));
|
||||
SELECT dictGetString('01280_db.ssd_dict', 'c', tuple('1', toInt32(3)));
|
||||
|
||||
SELECT dictGetUInt64('database_for_dict.ssd_dict', 'a', tuple('1', toInt32(3)));
|
||||
SELECT dictGetInt32('database_for_dict.ssd_dict', 'b', tuple('1', toInt32(3)));
|
||||
SELECT dictGetString('database_for_dict.ssd_dict', 'c', tuple('1', toInt32(3)));
|
||||
SELECT dictGetUInt64('01280_db.ssd_dict', 'a', tuple('1', toInt32(3)));
|
||||
SELECT dictGetInt32('01280_db.ssd_dict', 'b', tuple('1', toInt32(3)));
|
||||
SELECT dictGetString('01280_db.ssd_dict', 'c', tuple('1', toInt32(3)));
|
||||
|
||||
SELECT dictGetUInt64('database_for_dict.ssd_dict', 'a', tuple('2', toInt32(-1)));
|
||||
SELECT dictGetInt32('database_for_dict.ssd_dict', 'b', tuple('2', toInt32(-1)));
|
||||
SELECT dictGetString('database_for_dict.ssd_dict', 'c', tuple('2', toInt32(-1)));
|
||||
SELECT dictGetUInt64('01280_db.ssd_dict', 'a', tuple('2', toInt32(-1)));
|
||||
SELECT dictGetInt32('01280_db.ssd_dict', 'b', tuple('2', toInt32(-1)));
|
||||
SELECT dictGetString('01280_db.ssd_dict', 'c', tuple('2', toInt32(-1)));
|
||||
|
||||
SELECT dictGetUInt64('database_for_dict.ssd_dict', 'a', tuple('5', toInt32(-3)));
|
||||
SELECT dictGetInt32('database_for_dict.ssd_dict', 'b', tuple('5', toInt32(-3)));
|
||||
SELECT dictGetString('database_for_dict.ssd_dict', 'c', tuple('5', toInt32(-3)));
|
||||
SELECT dictGetUInt64('01280_db.ssd_dict', 'a', tuple('5', toInt32(-3)));
|
||||
SELECT dictGetInt32('01280_db.ssd_dict', 'b', tuple('5', toInt32(-3)));
|
||||
SELECT dictGetString('01280_db.ssd_dict', 'c', tuple('5', toInt32(-3)));
|
||||
|
||||
SELECT dictGetUInt64('database_for_dict.ssd_dict', 'a', tuple('10', toInt32(-20)));
|
||||
SELECT dictGetInt32('database_for_dict.ssd_dict', 'b', tuple('10', toInt32(-20)));
|
||||
SELECT dictGetString('database_for_dict.ssd_dict', 'c', tuple('10', toInt32(-20)));
|
||||
SELECT dictGetUInt64('01280_db.ssd_dict', 'a', tuple('10', toInt32(-20)));
|
||||
SELECT dictGetInt32('01280_db.ssd_dict', 'b', tuple('10', toInt32(-20)));
|
||||
SELECT dictGetString('01280_db.ssd_dict', 'c', tuple('10', toInt32(-20)));
|
||||
|
||||
SELECT dictGetUInt64('database_for_dict.ssd_dict', 'a', tuple(toInt32(3))); --{serverError 53}
|
||||
SELECT dictGetUInt64('01280_db.ssd_dict', 'a', tuple(toInt32(3))); --{serverError 53}
|
||||
|
||||
DROP DICTIONARY database_for_dict.ssd_dict;
|
||||
DROP DICTIONARY 01280_db.ssd_dict;
|
||||
|
||||
DROP TABLE IF EXISTS database_for_dict.keys_table;
|
||||
DROP TABLE IF EXISTS 01280_db.keys_table;
|
||||
|
||||
CREATE TABLE database_for_dict.keys_table
|
||||
CREATE TABLE 01280_db.keys_table
|
||||
(
|
||||
k1 String,
|
||||
k2 Int32
|
||||
)
|
||||
ENGINE = StripeLog();
|
||||
|
||||
INSERT INTO database_for_dict.keys_table VALUES ('1', 3);
|
||||
INSERT INTO database_for_dict.keys_table SELECT toString(intHash64(number + 1) % 1200), 11 + intHash64(number) % 1200 FROM system.numbers LIMIT 370;
|
||||
INSERT INTO database_for_dict.keys_table VALUES ('2', -1);
|
||||
INSERT INTO database_for_dict.keys_table SELECT toString(intHash64(number + 1) % 1200), 11 + intHash64(number) % 1200 FROM system.numbers LIMIT 370, 370;
|
||||
INSERT INTO database_for_dict.keys_table VALUES ('5', -3);
|
||||
INSERT INTO database_for_dict.keys_table SELECT toString(intHash64(number + 1) % 1200), 11 + intHash64(number) % 1200 FROM system.numbers LIMIT 700, 370;
|
||||
INSERT INTO database_for_dict.keys_table VALUES ('10', -20);
|
||||
INSERT INTO 01280_db.keys_table VALUES ('1', 3);
|
||||
INSERT INTO 01280_db.keys_table SELECT toString(intHash64(number + 1) % 1200), 11 + intHash64(number) % 1200 FROM system.numbers LIMIT 370;
|
||||
INSERT INTO 01280_db.keys_table VALUES ('2', -1);
|
||||
INSERT INTO 01280_db.keys_table SELECT toString(intHash64(number + 1) % 1200), 11 + intHash64(number) % 1200 FROM system.numbers LIMIT 370, 370;
|
||||
INSERT INTO 01280_db.keys_table VALUES ('5', -3);
|
||||
INSERT INTO 01280_db.keys_table SELECT toString(intHash64(number + 1) % 1200), 11 + intHash64(number) % 1200 FROM system.numbers LIMIT 700, 370;
|
||||
INSERT INTO 01280_db.keys_table VALUES ('10', -20);
|
||||
|
||||
DROP DICTIONARY IF EXISTS database_for_dict.ssd_dict;
|
||||
DROP DICTIONARY IF EXISTS 01280_db.ssd_dict;
|
||||
|
||||
CREATE DICTIONARY database_for_dict.ssd_dict
|
||||
CREATE DICTIONARY 01280_db.ssd_dict
|
||||
(
|
||||
k1 String,
|
||||
k2 Int32,
|
||||
@ -97,43 +97,43 @@ CREATE DICTIONARY database_for_dict.ssd_dict
|
||||
c String DEFAULT 'none'
|
||||
)
|
||||
PRIMARY KEY k1, k2
|
||||
SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'table_for_dict' PASSWORD '' DB 'database_for_dict'))
|
||||
SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'table_for_dict' PASSWORD '' DB '01280_db'))
|
||||
LIFETIME(MIN 1000 MAX 2000)
|
||||
LAYOUT(COMPLEX_KEY_SSD_CACHE(FILE_SIZE 8192 PATH '/var/lib/clickhouse/clickhouse_dicts/1d' BLOCK_SIZE 512 WRITE_BUFFER_SIZE 4096 MAX_STORED_KEYS 1000000));
|
||||
|
||||
SELECT 'UPDATE DICTIONARY';
|
||||
-- 118
|
||||
SELECT sum(dictGetUInt64('database_for_dict.ssd_dict', 'a', (k1, k2))) FROM database_for_dict.keys_table;
|
||||
SELECT sum(dictGetUInt64('01280_db.ssd_dict', 'a', (k1, k2))) FROM 01280_db.keys_table;
|
||||
|
||||
SELECT 'VALUE FROM DISK';
|
||||
-- -100
|
||||
SELECT dictGetInt32('database_for_dict.ssd_dict', 'b', ('1', toInt32(3)));
|
||||
SELECT dictGetInt32('01280_db.ssd_dict', 'b', ('1', toInt32(3)));
|
||||
|
||||
-- 'clickhouse'
|
||||
SELECT dictGetString('database_for_dict.ssd_dict', 'c', ('1', toInt32(3)));
|
||||
SELECT dictGetString('01280_db.ssd_dict', 'c', ('1', toInt32(3)));
|
||||
|
||||
SELECT 'VALUE FROM RAM BUFFER';
|
||||
-- 8
|
||||
SELECT dictGetInt32('database_for_dict.ssd_dict', 'b', ('10', toInt32(-20)));
|
||||
SELECT dictGetInt32('01280_db.ssd_dict', 'b', ('10', toInt32(-20)));
|
||||
|
||||
-- ''
|
||||
SELECT dictGetString('database_for_dict.ssd_dict', 'c', ('10', toInt32(-20)));
|
||||
SELECT dictGetString('01280_db.ssd_dict', 'c', ('10', toInt32(-20)));
|
||||
|
||||
SELECT 'VALUES FROM DISK AND RAM BUFFER';
|
||||
-- 118
|
||||
SELECT sum(dictGetUInt64('database_for_dict.ssd_dict', 'a', (k1, k2))) FROM database_for_dict.keys_table;
|
||||
SELECT sum(dictGetUInt64('01280_db.ssd_dict', 'a', (k1, k2))) FROM 01280_db.keys_table;
|
||||
|
||||
SELECT 'HAS';
|
||||
-- 6
|
||||
SELECT count() FROM database_for_dict.keys_table WHERE dictHas('database_for_dict.ssd_dict', (k1, k2));
|
||||
SELECT count() FROM 01280_db.keys_table WHERE dictHas('01280_db.ssd_dict', (k1, k2));
|
||||
|
||||
SELECT 'VALUES NOT FROM TABLE';
|
||||
-- 0 -1 none
|
||||
SELECT dictGetUInt64('database_for_dict.ssd_dict', 'a', ('unknown', toInt32(0))), dictGetInt32('database_for_dict.ssd_dict', 'b', ('unknown', toInt32(0))), dictGetString('database_for_dict.ssd_dict', 'c', ('unknown', toInt32(0)));
|
||||
SELECT dictGetUInt64('database_for_dict.ssd_dict', 'a', ('unknown', toInt32(0))), dictGetInt32('database_for_dict.ssd_dict', 'b', ('unknown', toInt32(0))), dictGetString('database_for_dict.ssd_dict', 'c', ('unknown', toInt32(0)));
|
||||
SELECT dictGetUInt64('01280_db.ssd_dict', 'a', ('unknown', toInt32(0))), dictGetInt32('01280_db.ssd_dict', 'b', ('unknown', toInt32(0))), dictGetString('01280_db.ssd_dict', 'c', ('unknown', toInt32(0)));
|
||||
SELECT dictGetUInt64('01280_db.ssd_dict', 'a', ('unknown', toInt32(0))), dictGetInt32('01280_db.ssd_dict', 'b', ('unknown', toInt32(0))), dictGetString('01280_db.ssd_dict', 'c', ('unknown', toInt32(0)));
|
||||
|
||||
SELECT 'DUPLICATE KEYS';
|
||||
SELECT arrayJoin([('1', toInt32(3)), ('2', toInt32(-1)), ('', toInt32(0)), ('', toInt32(0)), ('2', toInt32(-1)), ('1', toInt32(3))]) AS keys, dictGetInt32('database_for_dict.ssd_dict', 'b', keys);
|
||||
SELECT arrayJoin([('1', toInt32(3)), ('2', toInt32(-1)), ('', toInt32(0)), ('', toInt32(0)), ('2', toInt32(-1)), ('1', toInt32(3))]) AS keys, dictGetInt32('01280_db.ssd_dict', 'b', keys);
|
||||
|
||||
DROP DICTIONARY IF EXISTS database_for_dict.ssd_dict;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user