Merge remote-tracking branch 'upstream/master' into fix25

This commit is contained in:
proller 2019-07-15 19:40:14 +03:00
commit 22a1c1990c
5 changed files with 30 additions and 22 deletions

View File

@ -178,11 +178,16 @@ StringRef ColumnArray::serializeValueIntoArena(size_t n, Arena & arena, char con
char * pos = arena.allocContinue(sizeof(array_size), begin);
memcpy(pos, &array_size, sizeof(array_size));
size_t values_size = 0;
for (size_t i = 0; i < array_size; ++i)
values_size += getData().serializeValueIntoArena(offset + i, arena, begin).size;
StringRef res(pos, sizeof(array_size));
return StringRef(begin, sizeof(array_size) + values_size);
for (size_t i = 0; i < array_size; ++i)
{
auto value_ref = getData().serializeValueIntoArena(offset + i, arena, begin);
res.data = value_ref.data - res.size;
res.size += value_ref.size;
}
return res;
}

View File

@ -103,12 +103,13 @@ StringRef ColumnNullable::serializeValueIntoArena(size_t n, Arena & arena, char
auto pos = arena.allocContinue(s, begin);
memcpy(pos, &arr[n], s);
size_t nested_size = 0;
if (arr[n])
return StringRef(pos, s);
if (arr[n] == 0)
nested_size = getNestedColumn().serializeValueIntoArena(n, arena, begin).size;
auto nested_ref = getNestedColumn().serializeValueIntoArena(n, arena, begin);
return StringRef{begin, s + nested_size};
/// serializeValueIntoArena may reallocate memory. Have to use ptr from nested_ref.data and move it back.
return StringRef(nested_ref.data - s, nested_ref.size + s);
}
const char * ColumnNullable::deserializeAndInsertFromArena(const char * pos)

View File

@ -142,11 +142,15 @@ void ColumnTuple::popBack(size_t n)
StringRef ColumnTuple::serializeValueIntoArena(size_t n, Arena & arena, char const *& begin) const
{
size_t values_size = 0;
StringRef res(begin, 0);
for (auto & column : columns)
values_size += column->serializeValueIntoArena(n, arena, begin).size;
{
auto value_ref = column->serializeValueIntoArena(n, arena, begin);
res.data = value_ref.data - res.size;
res.size += value_ref.size;
}
return StringRef(begin, values_size);
return res;
}
const char * ColumnTuple::deserializeAndInsertFromArena(const char * pos)

View File

@ -300,19 +300,19 @@ StringRef ColumnUnique<ColumnType>::serializeValueIntoArena(size_t n, Arena & ar
{
if (is_nullable)
{
const UInt8 null_flag = 1;
const UInt8 not_null_flag = 0;
static constexpr auto s = sizeof(UInt8);
auto pos = arena.allocContinue(sizeof(null_flag), begin);
auto & flag = (n == getNullValueIndex() ? null_flag : not_null_flag);
memcpy(pos, &flag, sizeof(flag));
auto pos = arena.allocContinue(s, begin);
UInt8 flag = (n == getNullValueIndex() ? 1 : 0);
unalignedStore<UInt8>(pos, flag);
size_t nested_size = 0;
if (n == getNullValueIndex())
return StringRef(pos, s);
if (n != getNullValueIndex())
nested_size = column_holder->serializeValueIntoArena(n, arena, begin).size;
auto nested_ref = column_holder->serializeValueIntoArena(n, arena, begin);
return StringRef(pos, sizeof(null_flag) + nested_size);
/// serializeValueIntoArena may reallocate memory. Have to use ptr from nested_ref.data and move it back.
return StringRef(nested_ref.data - s, nested_ref.size + s);
}
return column_holder->serializeValueIntoArena(n, arena, begin);

View File

@ -46,8 +46,6 @@
<value>uniqCombined(16)</value>
<value>uniqCombined(17)</value>
<value>uniqCombined(18)</value>
<value>uniqCombined(19)</value>
<value>uniqCombined(20)</value>
<value>uniqUpTo(3)</value>
<value>uniqUpTo(5)</value>
<value>uniqUpTo(10)</value>