mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 07:31:57 +00:00
optimize fixed size column
This commit is contained in:
parent
035dbdaf22
commit
f96b9b7512
@ -140,9 +140,9 @@ StringRef ColumnNullable::serializeValueIntoArena(size_t n, Arena & arena, char
|
||||
const bool is_null = arr[n];
|
||||
static constexpr auto s = sizeof(arr[0]);
|
||||
char * pos;
|
||||
if (const ColumnString * string_col = checkAndGetColumn<ColumnString>(getNestedColumn()))
|
||||
if (isString(nested_column->getDataType()))
|
||||
{
|
||||
auto data = string_col->getDataAt(n);
|
||||
auto data = nested_column->getDataAt(n);
|
||||
size_t string_size = data.size + 1;
|
||||
auto memory_size = is_null ? s : s + sizeof(string_size) + string_size;
|
||||
pos = arena.allocContinue(memory_size, begin);
|
||||
@ -154,6 +154,19 @@ StringRef ColumnNullable::serializeValueIntoArena(size_t n, Arena & arena, char
|
||||
}
|
||||
return StringRef(pos, memory_size);
|
||||
}
|
||||
else if (isNumber(nested_column->getDataType()) || isFixedString(nested_column->getDataType()))
|
||||
{
|
||||
auto data = nested_column->getDataAt(n);
|
||||
auto size = data.size;
|
||||
auto memory_size = is_null ? s : s + size;
|
||||
pos = arena.allocContinue(memory_size, begin);
|
||||
memcpy(pos, &arr[n], s);
|
||||
if (!is_null)
|
||||
{
|
||||
memcpy(pos + s, data.data, size);
|
||||
}
|
||||
return StringRef(pos, memory_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = arena.allocContinue(s, begin);
|
||||
|
@ -11,13 +11,19 @@
|
||||
key_string1 Nullable(String),
|
||||
key_string2 Nullable(String),
|
||||
key_string3 Nullable(String),
|
||||
key_int64_1 Nullable(Int64),
|
||||
key_int64_2 Nullable(Int64),
|
||||
key_int64_3 Nullable(Int64),
|
||||
key_int64_4 Nullable(Int64),
|
||||
key_int64_5 Nullable(Int64),
|
||||
m1 Int64,
|
||||
m2 Int64,
|
||||
m2 Int64
|
||||
)
|
||||
ENGINE = Memory
|
||||
</create_query>
|
||||
<fill_query>insert into t_nullable select ['aaaaaa','bbaaaa','ccaaaa','ddaaaa'][number % 101 + 1], ['aa','bb','cc','dd'][number % 100 + 1], ['aa','bb','cc','dd'][number % 102 + 1], number%6000+1, number%5000+2 from numbers_mt(20000000)</fill_query>
|
||||
<fill_query>insert into t_nullable select ['aaaaaa','bbaaaa','ccaaaa','ddaaaa'][number % 101 + 1], ['aa','bb','cc','dd'][number % 100 + 1], ['aa','bb','cc','dd'][number % 102 + 1], number%1000+1, number%1000+2, number%1000+3, number%1000+4,number%1000+5, number%6000+1, number%5000+2 from numbers_mt(20000000)</fill_query>
|
||||
<query>select key_string1,key_string2,key_string3, min(m1) from t_nullable group by key_string1,key_string2,key_string3</query>
|
||||
<query>select key_string3,key_int64_1,key_int64_2, min(m1) from t_nullable group by key_string3,key_int64_1,key_int64_2</query>
|
||||
|
||||
<drop_query>drop table if exists t_nullable</drop_query>
|
||||
</test>
|
Loading…
Reference in New Issue
Block a user