mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 18:12:02 +00:00
dbms: improvements [#METR-19266]
This commit is contained in:
parent
ec30520c89
commit
d0d1ad3be1
@ -1,10 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <DB/Columns/IColumn.h>
|
||||
#include <DB/IO/ReadBuffer.h>
|
||||
#include <DB/IO/ReadHelpers.h>
|
||||
#include <DB/IO/WriteBuffer.h>
|
||||
#include <DB/IO/WriteHelpers.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
@ -70,35 +66,6 @@ struct XML
|
||||
static constexpr auto length = strlen_constexpr(name);
|
||||
};
|
||||
|
||||
template <typename Null>
|
||||
struct Deserializer
|
||||
{
|
||||
static bool execute(IColumn & column, ReadBuffer & istr, NullValuesByteMap * null_map)
|
||||
{
|
||||
if (null_map != nullptr)
|
||||
{
|
||||
if (!istr.eof())
|
||||
{
|
||||
if (*istr.position() == Null::prefix)
|
||||
{
|
||||
++istr.position();
|
||||
if (Null::length > 1)
|
||||
assertString(Null::suffix, istr);
|
||||
null_map->push_back(1);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
null_map->push_back(0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,10 @@
|
||||
#include <DB/DataTypes/DataTypeNull.h>
|
||||
#include <DB/DataTypes/NullSymbol.h>
|
||||
#include <DB/Columns/ColumnNull.h>
|
||||
#include <DB/IO/ReadBuffer.h>
|
||||
#include <DB/IO/ReadHelpers.h>
|
||||
#include <DB/IO/WriteBuffer.h>
|
||||
#include <DB/IO/WriteHelpers.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
@ -1,7 +1,11 @@
|
||||
#include <DB/DataTypes/DataTypeNullable.h>
|
||||
#include <DB/DataTypes/NullSymbol.h>
|
||||
#include <DB/Columns/ColumnNullable.h>
|
||||
#include <DB/Common/typeid_cast.h>
|
||||
#include <DB/DataTypes/NullSymbol.h>
|
||||
#include <DB/IO/ReadBuffer.h>
|
||||
#include <DB/IO/ReadHelpers.h>
|
||||
#include <DB/IO/WriteBuffer.h>
|
||||
#include <DB/IO/WriteHelpers.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
@ -9,6 +13,35 @@ namespace DB
|
||||
namespace
|
||||
{
|
||||
|
||||
template <typename Null>
|
||||
struct Deserializer
|
||||
{
|
||||
static bool execute(IColumn & column, ReadBuffer & istr, NullValuesByteMap * null_map)
|
||||
{
|
||||
if (null_map != nullptr)
|
||||
{
|
||||
if (!istr.eof())
|
||||
{
|
||||
if (*istr.position() == Null::prefix)
|
||||
{
|
||||
++istr.position();
|
||||
if (Null::length > 1)
|
||||
assertString(Null::suffix, istr);
|
||||
null_map->push_back(1);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
null_map->push_back(0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
inline bool isNullValue(const NullValuesByteMap * null_map, size_t row_num)
|
||||
{
|
||||
return (null_map != nullptr) && ((*null_map)[row_num] == 1);
|
||||
@ -116,7 +149,7 @@ void DataTypeNullable::deserializeTextEscaped(IColumn & column, ReadBuffer & ist
|
||||
ColumnUInt8 & content = static_cast<ColumnUInt8 &>(*(col->getNullValuesByteMap().get()));
|
||||
auto & null_map = content.getData();
|
||||
|
||||
if (NullSymbol::Deserializer<NullSymbol::Escaped>::execute(column, istr, &null_map))
|
||||
if (Deserializer<NullSymbol::Escaped>::execute(column, istr, &null_map))
|
||||
{
|
||||
ColumnPtr & nested_col = col->getNestedColumn();
|
||||
nested_col.get()->insertDefault();
|
||||
@ -149,7 +182,7 @@ void DataTypeNullable::deserializeTextQuoted(IColumn & column, ReadBuffer & istr
|
||||
ColumnUInt8 & content = static_cast<ColumnUInt8 &>(*(col->getNullValuesByteMap().get()));
|
||||
auto & null_map = content.getData();
|
||||
|
||||
if (NullSymbol::Deserializer<NullSymbol::Quoted>::execute(column, istr, &null_map))
|
||||
if (Deserializer<NullSymbol::Quoted>::execute(column, istr, &null_map))
|
||||
{
|
||||
ColumnPtr & nested_col = col->getNestedColumn();
|
||||
nested_col.get()->insertDefault();
|
||||
@ -182,7 +215,7 @@ void DataTypeNullable::deserializeTextCSV(IColumn & column, ReadBuffer & istr, c
|
||||
ColumnUInt8 & content = static_cast<ColumnUInt8 &>(*(col->getNullValuesByteMap().get()));
|
||||
auto & null_map = content.getData();
|
||||
|
||||
if (NullSymbol::Deserializer<NullSymbol::Quoted>::execute(column, istr, &null_map))
|
||||
if (Deserializer<NullSymbol::Quoted>::execute(column, istr, &null_map))
|
||||
{
|
||||
ColumnPtr & nested_col = col->getNestedColumn();
|
||||
nested_col.get()->insertDefault();
|
||||
@ -230,7 +263,7 @@ void DataTypeNullable::deserializeTextJSON(IColumn & column, ReadBuffer & istr)
|
||||
ColumnUInt8 & content = static_cast<ColumnUInt8 &>(*(col->getNullValuesByteMap().get()));
|
||||
auto & null_map = content.getData();
|
||||
|
||||
if (NullSymbol::Deserializer<NullSymbol::JSON>::execute(column, istr, &null_map))
|
||||
if (Deserializer<NullSymbol::JSON>::execute(column, istr, &null_map))
|
||||
{
|
||||
ColumnPtr & nested_col = col->getNestedColumn();
|
||||
nested_col.get()->insertDefault();
|
||||
|
@ -258,8 +258,17 @@ Block LogBlockInputStream::readImpl()
|
||||
|
||||
bool read_offsets = true;
|
||||
|
||||
const IDataType * observed_type;
|
||||
if (column.type.get()->isNullable())
|
||||
{
|
||||
const DataTypeNullable & nullable_type = static_cast<const DataTypeNullable &>(*(column.type.get()));
|
||||
observed_type = nullable_type.getNestedType().get();
|
||||
}
|
||||
else
|
||||
observed_type = column.type.get();
|
||||
|
||||
/// Для вложенных структур запоминаем указатели на столбцы со смещениями
|
||||
if (const DataTypeArray * type_arr = typeid_cast<const DataTypeArray *>(&*column.type))
|
||||
if (const DataTypeArray * type_arr = typeid_cast<const DataTypeArray *>(observed_type))
|
||||
{
|
||||
String name = DataTypeNested::extractNestedTableName(column.name);
|
||||
|
||||
|
@ -196,8 +196,17 @@ Block TinyLogBlockInputStream::readImpl()
|
||||
|
||||
bool read_offsets = true;
|
||||
|
||||
const IDataType * observed_type;
|
||||
if (column.type.get()->isNullable())
|
||||
{
|
||||
const DataTypeNullable & nullable_type = static_cast<const DataTypeNullable &>(*(column.type.get()));
|
||||
observed_type = nullable_type.getNestedType().get();
|
||||
}
|
||||
else
|
||||
observed_type = column.type.get();
|
||||
|
||||
/// Для вложенных структур запоминаем указатели на столбцы со смещениями
|
||||
if (const DataTypeArray * type_arr = typeid_cast<const DataTypeArray *>(&*column.type))
|
||||
if (const DataTypeArray * type_arr = typeid_cast<const DataTypeArray *>(observed_type))
|
||||
{
|
||||
String name = DataTypeNested::extractNestedTableName(column.name);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user