dbms: cleanup [#METR-19266]

This commit is contained in:
Alexey Arno 2016-08-18 18:58:46 +03:00
parent e138621b7c
commit e822631310
10 changed files with 30 additions and 32 deletions

View File

@ -307,6 +307,17 @@ using ColumnConstString = ColumnConst<String>;
using ColumnConstArray = ColumnConst<Array>;
using ColumnConstTuple = ColumnConst<Tuple>;
template <>
inline bool ColumnConst<Null>::isNull() const
{
return true;
}
template <>
inline StringRef ColumnConst<Null>::getDataAt(size_t n) const
{
return {};
}
template <typename T> ColumnPtr ColumnConst<T>::convertToFullColumn() const
{

View File

@ -23,6 +23,7 @@ public:
ColumnNullable(ColumnPtr nested_column_, ColumnPtr null_map_);
std::string getName() const override { return "ColumnNullable(" + nested_column->getName() + ")"; }
bool isNumeric() const override { return nested_column->isNumeric(); }
bool isNumericNotNullable() const override { return false; }
bool isConst() const override { return nested_column->isConst(); }
bool isFixed() const override { return nested_column->isFixed(); }
bool isNullable() const override { return true; }

View File

@ -45,6 +45,9 @@ public:
*/
virtual bool isNumeric() const { return false; }
/// Is this column numeric and not nullable?
virtual bool isNumericNotNullable() const { return isNumeric(); }
/** Столбец представляет собой константу.
*/
virtual bool isConst() const { return false; }

View File

@ -15,6 +15,7 @@ public:
std::string getName() const override { return "Nullable(" + nested_data_type->getName() + ")"; }
bool isNullable() const override { return true; }
bool isNumeric() const override { return nested_data_type->isNumeric(); }
bool isNumericNotNullable() const override { return false; }
bool behavesAsNumber() const override { return nested_data_type->behavesAsNumber(); }
DataTypePtr clone() const override { return std::make_shared<DataTypeNullable>(nested_data_type->clone()); }
void serializeBinary(const IColumn & column, WriteBuffer & ostr, size_t offset = 0, size_t limit = 0) const override;

View File

@ -33,11 +33,14 @@ public:
/// Is this type nullable?
virtual bool isNullable() const { return false; }
/// Является ли тип числовым. Дата и дата-с-временем тоже считаются такими.
/// Is this type numeric? Date and DateTime types are considered as such.
virtual bool isNumeric() const { return false; }
/// Если тип числовой, уместны ли с ним все арифметические операции и приведение типов.
/// true для чисел, false для даты и даты-с-временем.
/// Is this type numeric and not nullable?
virtual bool isNumericNotNullable() const { return isNumeric(); }
/// If this type is numeric, are all the arithmetic operations and type casting
/// relevant for it? True for numbers. False for Date and DateTime types.
virtual bool behavesAsNumber() const { return false; }
/// Клонировать

View File

@ -15,30 +15,6 @@
namespace DB
{
template <>
bool ColumnConst<Null>::isNull() const
{
return true;
}
template <>
StringRef ColumnConst<Null>::getDataAt(size_t n) const
{
return StringRef{};
}
template <>
StringRef ColumnConst<Null>::getDataAtWithTerminatingZero(size_t n) const
{
throw Exception("Method getDataAtWithTerminatingZero is not supported for " + this->getName(), ErrorCodes::NOT_IMPLEMENTED);
}
template <>
UInt64 ColumnConst<Null>::get64(size_t n) const
{
throw Exception("Method get64 is not supported for " + this->getName(), ErrorCodes::NOT_IMPLEMENTED);
}
template <>
ColumnPtr ColumnConst<Null>::convertToFullColumn() const
{

View File

@ -93,8 +93,11 @@ Block SummingSortedBlockInputStream::readImpl()
else
{
/// Оставляем только числовые типы. При чём, даты и даты-со-временем здесь такими не считаются.
if (!column.type->isNumeric() || column.type->getName() == "Date" ||
column.type->getName() == "DateTime")
if (!column.type->isNumeric() ||
column.type->getName() == "Date" ||
column.type->getName() == "DateTime" ||
column.type->getName() == "Nullable(Date)" ||
column.type->getName() == "Nullable(DateTime)")
continue;
/// Входят ли в PK?

View File

@ -390,7 +390,7 @@ AggregatedDataVariants::Type Aggregator::chooseAggregationMethod(const ConstColu
return AggregatedDataVariants::Type::without_key;
/// Если есть один числовой ключ, который помещается в 64 бита
if (params.keys_size == 1 && key_columns[0]->isNumeric())
if (params.keys_size == 1 && key_columns[0]->isNumericNotNullable())
{
size_t size_of_field = key_columns[0]->sizeOfField();
if (size_of_field == 1)

View File

@ -45,7 +45,7 @@ Join::Type Join::chooseMethod(const ConstColumnPlainPtrs & key_columns, bool & k
keys_fit_128_bits = false;
/// Если есть один числовой ключ, который помещается в 64 бита
if (keys_size == 1 && key_columns[0]->isNumeric())
if (keys_size == 1 && key_columns[0]->isNumericNotNullable())
return Type::KEY_64;
/// Если есть один строковый ключ, то используем хэш-таблицу с ним

View File

@ -116,7 +116,7 @@ SetVariants::Type SetVariants::chooseMethod(const ConstColumnPlainPtrs & key_col
}
/// Если есть один числовой ключ, который помещается в 64 бита
if (keys_size == 1 && key_columns[0]->isNumeric())
if (keys_size == 1 && key_columns[0]->isNumericNotNullable())
{
size_t size_of_field = key_columns[0]->sizeOfField();
if (size_of_field == 1)