2020-05-26 14:38:20 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
2020-12-28 11:46:53 +00:00
|
|
|
# shellcheck source=../shell_config.sh
|
2020-08-01 00:51:12 +00:00
|
|
|
. "$CURDIR"/../shell_config.sh
|
2020-05-26 14:38:20 +00:00
|
|
|
|
|
|
|
TMP_DIR="/tmp"
|
|
|
|
|
2020-05-31 18:47:54 +00:00
|
|
|
$CLICKHOUSE_CLIENT -n --query="
|
|
|
|
DROP DATABASE IF EXISTS test_01037;
|
|
|
|
|
2020-09-22 11:56:40 +00:00
|
|
|
CREATE DATABASE test_01037;
|
2020-05-31 18:47:54 +00:00
|
|
|
|
|
|
|
DROP TABLE IF EXISTS test_01037.polygons_array;
|
|
|
|
|
|
|
|
CREATE TABLE test_01037.polygons_array (key Array(Array(Array(Array(Float64)))), name String, value UInt64) ENGINE = Memory;
|
|
|
|
INSERT INTO test_01037.polygons_array VALUES ([[[[1, 3], [1, 1], [3, 1], [3, -1], [1, -1], [1, -3], [-1, -3], [-1, -1], [-3, -1], [-3, 1], [-1, 1], [-1, 3]]], [[[5, 5], [5, 1], [7, 1], [7, 7], [1, 7], [1, 5]]]], 'Click', 42);
|
|
|
|
INSERT INTO test_01037.polygons_array VALUES ([[[[5, 5], [5, -5], [-5, -5], [-5, 5]], [[1, 3], [1, 1], [3, 1], [3, -1], [1, -1], [1, -3], [-1, -3], [-1, -1], [-3, -1], [-3, 1], [-1, 1], [-1, 3]]]], 'House', 314159);
|
|
|
|
INSERT INTO test_01037.polygons_array VALUES ([[[[3, 1], [0, 1], [0, -1], [3, -1]]]], 'Click East', 421);
|
|
|
|
INSERT INTO test_01037.polygons_array VALUES ([[[[-1, 1], [1, 1], [1, 3], [-1, 3]]]], 'Click North', 422);
|
|
|
|
INSERT INTO test_01037.polygons_array VALUES ([[[[-3, 1], [-3, -1], [0, -1], [0, 1]]]], 'Click South', 423);
|
|
|
|
INSERT INTO test_01037.polygons_array VALUES ([[[[-1, -1], [1, -1], [1, -3], [-1, -3]]]], 'Click West', 424);
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS test_01037.polygons_tuple;
|
|
|
|
|
|
|
|
CREATE TABLE test_01037.polygons_tuple (key Array(Array(Array(Tuple(Float64, Float64)))), name String, value UInt64) ENGINE = Memory;
|
|
|
|
INSERT INTO test_01037.polygons_tuple VALUES ([[[(1, 3), (1, 1), (3, 1), (3, -1), (1, -1), (1, -3), (-1, -3), (-1, -1), (-3, -1), (-3, 1), (-1, 1), (-1, 3)]], [[(5, 5), (5, 1), (7, 1), (7, 7), (1, 7), (1, 5)]]], 'Click', 42);
|
|
|
|
INSERT INTO test_01037.polygons_tuple VALUES ([[[(5, 5), (5, -5), (-5, -5), (-5, 5)], [(1, 3), (1, 1), (3, 1), (3, -1), (1, -1), (1, -3), (-1, -3), (-1, -1), (-3, -1), (-3, 1), (-1, 1), (-1, 3)]]], 'House', 314159);
|
|
|
|
INSERT INTO test_01037.polygons_tuple VALUES ([[[(3, 1), (0, 1), (0, -1), (3, -1)]]], 'Click East', 421);
|
|
|
|
INSERT INTO test_01037.polygons_tuple VALUES ([[[(-1, 1), (1, 1), (1, 3), (-1, 3)]]], 'Click North', 422);
|
|
|
|
INSERT INTO test_01037.polygons_tuple VALUES ([[[(-3, 1), (-3, -1), (0, -1), (0, 1)]]], 'Click South', 423);
|
|
|
|
INSERT INTO test_01037.polygons_tuple VALUES ([[[(-1, -1), (1, -1), (1, -3), (-1, -3)]]], 'Click West', 424);
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS test_01037.points;
|
|
|
|
|
|
|
|
CREATE TABLE test_01037.points (x Float64, y Float64, def_i UInt64, def_s String) ENGINE = Memory;
|
|
|
|
INSERT INTO test_01037.points VALUES (0.1, 0.0, 112, 'aax');
|
|
|
|
INSERT INTO test_01037.points VALUES (-0.1, 0.0, 113, 'aay');
|
|
|
|
INSERT INTO test_01037.points VALUES (0.0, 1.1, 114, 'aaz');
|
|
|
|
INSERT INTO test_01037.points VALUES (0.0, -1.1, 115, 'aat');
|
|
|
|
INSERT INTO test_01037.points VALUES (3.0, 3.0, 22, 'bb');
|
|
|
|
INSERT INTO test_01037.points VALUES (5.0, 6.0, 33, 'cc');
|
|
|
|
INSERT INTO test_01037.points VALUES (-100.0, -42.0, 44, 'dd');
|
|
|
|
INSERT INTO test_01037.points VALUES (7.01, 7.01, 55, 'ee');
|
|
|
|
INSERT INTO test_01037.points VALUES (0.99, 2.99, 66, 'ee');
|
|
|
|
INSERT INTO test_01037.points VALUES (1.0, 0.0, 771, 'ffa');
|
|
|
|
INSERT INTO test_01037.points VALUES (-1.0, 0.0, 772, 'ffb');
|
|
|
|
INSERT INTO test_01037.points VALUES (0.0, 2.0, 773, 'ffc');
|
|
|
|
INSERT INTO test_01037.points VALUES (0.0, -2.0, 774, 'ffd');
|
|
|
|
"
|
2020-05-26 14:38:20 +00:00
|
|
|
|
|
|
|
|
2020-07-29 01:32:23 +00:00
|
|
|
declare -a SearchTypes=("POLYGON" "POLYGON_SIMPLE" "POLYGON_INDEX_EACH" "POLYGON_INDEX_CELL")
|
2020-05-26 14:38:20 +00:00
|
|
|
|
2020-07-31 23:55:20 +00:00
|
|
|
for type in "${SearchTypes[@]}";
|
2020-05-26 14:38:20 +00:00
|
|
|
do
|
2020-05-31 18:47:54 +00:00
|
|
|
outputFile="${TMP_DIR}/results${type}.out"
|
2020-05-26 14:38:20 +00:00
|
|
|
|
|
|
|
$CLICKHOUSE_CLIENT -n --query="
|
2020-05-31 18:47:54 +00:00
|
|
|
DROP DICTIONARY IF EXISTS test_01037.dict_array;
|
2020-05-26 14:38:20 +00:00
|
|
|
CREATE DICTIONARY test_01037.dict_array
|
|
|
|
(
|
|
|
|
key Array(Array(Array(Array(Float64)))),
|
|
|
|
name String DEFAULT 'qqq',
|
|
|
|
value UInt64 DEFAULT 101
|
|
|
|
)
|
|
|
|
PRIMARY KEY key
|
2020-12-18 13:26:11 +00:00
|
|
|
SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'polygons_array' PASSWORD '' DB 'test_01037'))
|
2020-05-29 19:48:41 +00:00
|
|
|
LIFETIME(0)
|
2020-05-26 14:38:20 +00:00
|
|
|
LAYOUT($type());
|
|
|
|
|
2020-05-31 18:47:54 +00:00
|
|
|
DROP DICTIONARY IF EXISTS test_01037.dict_tuple;
|
2020-05-26 14:38:20 +00:00
|
|
|
|
|
|
|
CREATE DICTIONARY test_01037.dict_tuple
|
|
|
|
(
|
|
|
|
key Array(Array(Array(Tuple(Float64, Float64)))),
|
|
|
|
name String DEFAULT 'qqq',
|
|
|
|
value UInt64 DEFAULT 101
|
|
|
|
)
|
|
|
|
PRIMARY KEY key
|
2020-12-18 13:26:11 +00:00
|
|
|
SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'polygons_tuple' PASSWORD '' DB 'test_01037'))
|
2020-05-29 19:48:41 +00:00
|
|
|
LIFETIME(0)
|
2020-05-26 14:38:20 +00:00
|
|
|
LAYOUT($type());
|
|
|
|
|
|
|
|
select 'dictGet', 'test_01037.dict_array' as dict_name, tuple(x, y) as key,
|
|
|
|
dictGet(dict_name, 'name', key),
|
|
|
|
dictGet(dict_name, 'value', key) from test_01037.points order by x, y;
|
|
|
|
select 'dictGetOrDefault', 'test_01037.dict_array' as dict_name, tuple(x, y) as key,
|
|
|
|
dictGetOrDefault(dict_name, 'name', key, 'www'),
|
|
|
|
dictGetOrDefault(dict_name, 'value', key, toUInt64(1234)) from test_01037.points order by x, y;
|
|
|
|
select 'dictGetOrDefault', 'test_01037.dict_array' as dict_name, tuple(x, y) as key,
|
|
|
|
dictGetOrDefault(dict_name, 'name', key, def_s),
|
|
|
|
dictGetOrDefault(dict_name, 'value', key, def_i) from test_01037.points order by x, y;
|
|
|
|
select 'dictGet', 'test_01037.dict_tuple' as dict_name, tuple(x, y) as key,
|
|
|
|
dictGet(dict_name, 'name', key),
|
|
|
|
dictGet(dict_name, 'value', key) from test_01037.points order by x, y;
|
|
|
|
select 'dictGetOrDefault', 'test_01037.dict_tuple' as dict_name, tuple(x, y) as key,
|
|
|
|
dictGetOrDefault(dict_name, 'name', key, 'www'),
|
|
|
|
dictGetOrDefault(dict_name, 'value', key, toUInt64(1234)) from test_01037.points order by x, y;
|
|
|
|
select 'dictGetOrDefault', 'test_01037.dict_tuple' as dict_name, tuple(x, y) as key,
|
|
|
|
dictGetOrDefault(dict_name, 'name', key, def_s),
|
|
|
|
dictGetOrDefault(dict_name, 'value', key, def_i) from test_01037.points order by x, y;
|
|
|
|
select 'dictHas', 'test_01037.dict_array' as dict_name, tuple(x, y) as key,
|
|
|
|
dictHas(dict_name, key) from test_01037.points order by x, y;
|
|
|
|
select 'dictHas', 'test_01037.dict_tuple' as dict_name, tuple(x, y) as key,
|
|
|
|
dictHas(dict_name, key) from test_01037.points order by x, y;
|
2020-08-01 00:56:32 +00:00
|
|
|
" > "$outputFile"
|
2020-05-26 14:38:20 +00:00
|
|
|
|
2020-05-29 19:48:41 +00:00
|
|
|
diff -q "${CURDIR}/01037_polygon_dicts_simple_functions.ans" "$outputFile"
|
2020-05-26 14:38:20 +00:00
|
|
|
done
|
|
|
|
|
2020-05-31 18:47:54 +00:00
|
|
|
$CLICKHOUSE_CLIENT -n --query="
|
|
|
|
DROP DICTIONARY test_01037.dict_array;
|
|
|
|
DROP DICTIONARY test_01037.dict_tuple;
|
|
|
|
DROP TABLE test_01037.polygons_array;
|
|
|
|
DROP TABLE test_01037.polygons_tuple;
|
|
|
|
DROP TABLE test_01037.points;
|
|
|
|
DROP DATABASE test_01037;
|
|
|
|
"
|