2016-07-05 16:23:37 +00:00
|
|
|
#include <DB/Columns/ColumnNullable.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
|
|
|
|
|
|
|
extern const int LOGICAL_ERROR;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-08-10 19:12:29 +00:00
|
|
|
ColumnNullable::ColumnNullable(ColumnPtr nested_column_)
|
|
|
|
: nested_column{nested_column_}
|
|
|
|
{
|
2016-08-12 15:22:28 +00:00
|
|
|
if (nested_column->isNullable())
|
2016-08-10 19:12:29 +00:00
|
|
|
throw Exception{"A nullable column cannot contain another nullable column", ErrorCodes::LOGICAL_ERROR};
|
|
|
|
}
|
|
|
|
|
2016-07-25 18:26:45 +00:00
|
|
|
ColumnNullable::ColumnNullable(ColumnPtr nested_column_, bool fill_with_nulls)
|
2016-07-07 10:33:12 +00:00
|
|
|
: nested_column{nested_column_},
|
|
|
|
null_map{std::make_shared<ColumnUInt8>()}
|
2016-07-05 16:23:37 +00:00
|
|
|
{
|
2016-08-12 15:22:28 +00:00
|
|
|
if (nested_column->isNullable())
|
2016-07-05 16:23:37 +00:00
|
|
|
throw Exception{"A nullable column cannot contain another nullable column", ErrorCodes::LOGICAL_ERROR};
|
|
|
|
|
2016-08-12 15:22:28 +00:00
|
|
|
size_t n = nested_column->size();
|
2016-07-05 16:23:37 +00:00
|
|
|
if (n > 0)
|
2016-07-25 18:26:45 +00:00
|
|
|
getNullMapContent().getData().resize_fill(n, (fill_with_nulls ? 1 : 0));
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string ColumnNullable::getName() const
|
|
|
|
{
|
2016-08-12 15:22:28 +00:00
|
|
|
return "ColumnNullable(" + nested_column->getName() + ")";
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ColumnNullable::isNullable() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnPtr ColumnNullable::convertToFullColumnIfConst() const
|
|
|
|
{
|
|
|
|
ColumnPtr new_col_holder;
|
|
|
|
|
2016-08-12 15:22:28 +00:00
|
|
|
if (auto full_col = nested_column->convertToFullColumnIfConst())
|
2016-07-05 16:23:37 +00:00
|
|
|
{
|
|
|
|
new_col_holder = std::make_shared<ColumnNullable>(full_col);
|
2016-08-10 19:12:29 +00:00
|
|
|
ColumnNullable & new_col = static_cast<ColumnNullable &>(*new_col_holder);
|
2016-08-16 12:25:45 +00:00
|
|
|
new_col.null_map = null_map;
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return new_col_holder;
|
|
|
|
}
|
|
|
|
|
2016-07-11 10:09:16 +00:00
|
|
|
void ColumnNullable::updateHashWithValue(size_t n, SipHash & hash) const
|
|
|
|
{
|
2016-08-10 19:12:29 +00:00
|
|
|
if (isNullAt(n))
|
|
|
|
{
|
|
|
|
UInt8 tag = 1;
|
|
|
|
hash.update(reinterpret_cast<const char *>(&tag), sizeof(tag));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
UInt8 tag = 0;
|
|
|
|
hash.update(reinterpret_cast<const char *>(&tag), sizeof(tag));
|
2016-08-12 15:22:28 +00:00
|
|
|
nested_column->updateHashWithValue(n, hash);
|
2016-08-10 19:12:29 +00:00
|
|
|
}
|
2016-07-11 10:09:16 +00:00
|
|
|
}
|
|
|
|
|
2016-07-05 16:23:37 +00:00
|
|
|
ColumnPtr ColumnNullable::cloneResized(size_t size) const
|
|
|
|
{
|
2016-08-12 15:22:28 +00:00
|
|
|
ColumnPtr new_col_holder = std::make_shared<ColumnNullable>(nested_column->cloneResized(size));
|
2016-08-10 19:12:29 +00:00
|
|
|
auto & new_col = static_cast<ColumnNullable &>(*new_col_holder);
|
2016-08-16 11:26:17 +00:00
|
|
|
new_col.null_map = getNullMapContent().cloneResized(size);
|
2016-08-10 19:12:29 +00:00
|
|
|
return new_col_holder;
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t ColumnNullable::size() const
|
|
|
|
{
|
2016-08-12 15:22:28 +00:00
|
|
|
return nested_column->size();
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Field ColumnNullable::operator[](size_t n) const
|
|
|
|
{
|
|
|
|
if (isNullAt(n))
|
|
|
|
return Field{};
|
|
|
|
else
|
2016-07-07 10:33:12 +00:00
|
|
|
{
|
2016-08-10 19:12:29 +00:00
|
|
|
const IColumn & col = *nested_column;
|
2016-07-07 10:33:12 +00:00
|
|
|
return col[n];
|
|
|
|
}
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ColumnNullable::get(size_t n, Field & res) const
|
|
|
|
{
|
|
|
|
if (isNullAt(n))
|
|
|
|
res = Field{};
|
|
|
|
else
|
2016-08-12 15:22:28 +00:00
|
|
|
nested_column->get(n, res);
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
UInt64 ColumnNullable::get64(size_t n) const
|
|
|
|
{
|
2016-08-16 11:26:17 +00:00
|
|
|
return nested_column->get64(n);
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StringRef ColumnNullable::getDataAt(size_t n) const
|
|
|
|
{
|
2016-08-10 19:12:29 +00:00
|
|
|
throw Exception{"Method getDataAt is not supported for " + getName(), ErrorCodes::NOT_IMPLEMENTED};
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ColumnNullable::insertData(const char * pos, size_t length)
|
|
|
|
{
|
2016-08-10 19:12:29 +00:00
|
|
|
throw Exception{"Method insertData is not supported for " + getName(), ErrorCodes::NOT_IMPLEMENTED};
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StringRef ColumnNullable::serializeValueIntoArena(size_t n, Arena & arena, char const *& begin) const
|
|
|
|
{
|
2016-08-10 19:12:29 +00:00
|
|
|
if (isNullAt(n))
|
|
|
|
{
|
|
|
|
const UInt8 tag = 1;
|
|
|
|
auto pos = arena.allocContinue(sizeof(tag), begin);
|
|
|
|
memcpy(pos, &tag, sizeof(tag));
|
|
|
|
return StringRef{pos, sizeof(tag)};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const UInt8 tag = 0;
|
|
|
|
auto pos = arena.allocContinue(sizeof(tag), begin);
|
|
|
|
memcpy(pos, &tag, sizeof(tag));
|
2016-08-12 15:22:28 +00:00
|
|
|
return nested_column->serializeValueIntoArena(n, arena, begin);
|
2016-08-10 19:12:29 +00:00
|
|
|
}
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char * ColumnNullable::deserializeAndInsertFromArena(const char * pos)
|
|
|
|
{
|
2016-08-10 19:12:29 +00:00
|
|
|
UInt8 tag = *reinterpret_cast<const UInt8 *>(pos);
|
|
|
|
const auto next_pos = pos + sizeof(tag);
|
|
|
|
if (tag == 1)
|
|
|
|
{
|
|
|
|
/// Apppend a null.
|
|
|
|
getNullMapContent().insert(1);
|
|
|
|
return next_pos;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
getNullMapContent().insert(0);
|
2016-08-12 15:22:28 +00:00
|
|
|
return nested_column->deserializeAndInsertFromArena(pos + sizeof(next_pos));
|
2016-08-10 19:12:29 +00:00
|
|
|
}
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ColumnNullable::insertRangeFrom(const IColumn & src, size_t start, size_t length)
|
|
|
|
{
|
2016-08-16 11:26:17 +00:00
|
|
|
const ColumnNullable & nullable_col = static_cast<const ColumnNullable &>(src);
|
|
|
|
getNullMapContent().insertRangeFrom(*nullable_col.null_map, start, length);
|
|
|
|
nested_column->insertRangeFrom(*nullable_col.nested_column, start, length);
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ColumnNullable::insert(const Field & x)
|
|
|
|
{
|
|
|
|
if (x.isNull())
|
|
|
|
{
|
2016-08-12 15:22:28 +00:00
|
|
|
nested_column->insertDefault();
|
2016-07-07 10:33:12 +00:00
|
|
|
getNullMapContent().insert(1);
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-08-12 15:22:28 +00:00
|
|
|
nested_column->insert(x);
|
2016-07-07 10:33:12 +00:00
|
|
|
getNullMapContent().insert(0);
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ColumnNullable::insertDefault()
|
|
|
|
{
|
2016-08-12 15:22:28 +00:00
|
|
|
nested_column->insertDefault();
|
2016-07-07 10:33:12 +00:00
|
|
|
getNullMapContent().insert(0);
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ColumnNullable::popBack(size_t n)
|
|
|
|
{
|
2016-08-12 15:22:28 +00:00
|
|
|
nested_column->popBack(n);
|
2016-07-07 10:33:12 +00:00
|
|
|
getNullMapContent().popBack(n);
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ColumnPtr ColumnNullable::filter(const Filter & filt, ssize_t result_size_hint) const
|
|
|
|
{
|
2016-08-12 15:22:28 +00:00
|
|
|
ColumnPtr new_data = nested_column->filter(filt, result_size_hint);
|
2016-07-05 16:23:37 +00:00
|
|
|
ColumnPtr filtered_col_holder = std::make_shared<ColumnNullable>(new_data);
|
2016-08-10 19:12:29 +00:00
|
|
|
ColumnNullable & filtered_col = static_cast<ColumnNullable &>(*filtered_col_holder);
|
2016-07-07 10:33:12 +00:00
|
|
|
filtered_col.null_map = getNullMapContent().filter(filt, result_size_hint);
|
2016-07-05 16:23:37 +00:00
|
|
|
return filtered_col_holder;
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnPtr ColumnNullable::permute(const Permutation & perm, size_t limit) const
|
|
|
|
{
|
2016-08-12 15:22:28 +00:00
|
|
|
ColumnPtr new_data = nested_column->permute(perm, limit);
|
2016-07-05 16:23:37 +00:00
|
|
|
ColumnPtr permuted_col_holder = std::make_shared<ColumnNullable>(new_data);
|
|
|
|
ColumnNullable & permuted_col = static_cast<ColumnNullable &>(*permuted_col_holder);
|
2016-07-07 10:33:12 +00:00
|
|
|
permuted_col.null_map = getNullMapContent().permute(perm, limit);
|
2016-07-05 16:23:37 +00:00
|
|
|
return permuted_col_holder;
|
|
|
|
}
|
|
|
|
|
2016-08-16 11:26:17 +00:00
|
|
|
int ColumnNullable::compareAt(size_t n, size_t m, const IColumn & rhs_, int null_direction_hint) const
|
2016-07-05 16:23:37 +00:00
|
|
|
{
|
2016-08-10 19:12:29 +00:00
|
|
|
const ColumnNullable & nullable_rhs = static_cast<const ColumnNullable &>(rhs_);
|
2016-07-05 16:23:37 +00:00
|
|
|
|
2016-08-10 19:12:29 +00:00
|
|
|
bool lval_is_null = isNullAt(n);
|
|
|
|
bool rval_is_null = nullable_rhs.isNullAt(m);
|
2016-07-05 16:23:37 +00:00
|
|
|
|
2016-08-10 19:12:29 +00:00
|
|
|
/// Two null values are equal.
|
|
|
|
if (lval_is_null && rval_is_null)
|
2016-07-05 16:23:37 +00:00
|
|
|
return 0;
|
2016-08-10 19:12:29 +00:00
|
|
|
/// The null value is always lesser than any value.
|
|
|
|
if (lval_is_null)
|
2016-07-05 16:23:37 +00:00
|
|
|
return -1;
|
2016-08-10 19:12:29 +00:00
|
|
|
/// A non-null value is always greater than the null value.
|
|
|
|
if (rval_is_null)
|
2016-07-05 16:23:37 +00:00
|
|
|
return 1;
|
|
|
|
|
2016-08-10 19:12:29 +00:00
|
|
|
const IColumn & nested_rhs = *(nullable_rhs.getNestedColumn());
|
2016-08-16 11:26:17 +00:00
|
|
|
return nested_column->compareAt(n, m, nested_rhs, null_direction_hint);
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ColumnNullable::getPermutation(bool reverse, size_t limit, Permutation & res) const
|
|
|
|
{
|
2016-08-12 15:22:28 +00:00
|
|
|
nested_column->getPermutation(reverse, limit, res);
|
2016-08-10 19:12:29 +00:00
|
|
|
size_t s = res.size();
|
|
|
|
|
|
|
|
/// Since we have created a permutation "res" that sorts a subset of the column values
|
|
|
|
/// and some of these values may actually be nulls, there is no guarantee that
|
|
|
|
/// these null values are well positioned. So we create a permutation "p" which
|
|
|
|
/// operates on the result of "res" by moving all the null values to the required
|
|
|
|
/// direction and leaving the order of the remaining elements unchanged.
|
|
|
|
|
|
|
|
/// Create the permutation p.
|
|
|
|
Permutation p;
|
|
|
|
p.resize(s);
|
|
|
|
|
|
|
|
size_t pos_left = 0;
|
|
|
|
size_t pos_right = s - 1;
|
|
|
|
|
|
|
|
if (reverse)
|
|
|
|
{
|
|
|
|
/// Move the null elements to the right.
|
|
|
|
for (size_t i = 0; i < s; ++i)
|
|
|
|
{
|
|
|
|
if (isNullAt(res[i]))
|
|
|
|
{
|
|
|
|
p[i] = pos_right;
|
|
|
|
--pos_right;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
p[i] = pos_left;
|
|
|
|
++pos_left;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/// Move the null elements to the left.
|
|
|
|
for (size_t i = 0; i < s; ++i)
|
|
|
|
{
|
|
|
|
size_t j = s - i - 1;
|
|
|
|
|
|
|
|
if (isNullAt(res[j]))
|
|
|
|
{
|
|
|
|
p[j] = pos_left;
|
|
|
|
++pos_left;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
p[j] = pos_right;
|
|
|
|
--pos_right;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Combine the permutations res and p.
|
|
|
|
Permutation res2;
|
|
|
|
res2.resize(s);
|
|
|
|
|
|
|
|
for (size_t i = 0; i < s; ++i)
|
|
|
|
res2[i] = res[p[i]];
|
|
|
|
|
|
|
|
res = std::move(res2);
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ColumnNullable::reserve(size_t n)
|
|
|
|
{
|
2016-08-12 15:22:28 +00:00
|
|
|
nested_column->reserve(n);
|
2016-07-07 10:33:12 +00:00
|
|
|
getNullMapContent().reserve(n);
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t ColumnNullable::byteSize() const
|
|
|
|
{
|
2016-08-12 15:22:28 +00:00
|
|
|
return nested_column->byteSize() + getNullMapContent().byteSize();
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
2016-08-16 11:26:17 +00:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
|
|
|
|
/// The following function implements a slightly more general version
|
|
|
|
/// of getExtremes() than the implementation from ColumnVector.
|
|
|
|
/// It takes into account the possible presence of nullable values.
|
|
|
|
template <typename T>
|
|
|
|
void getExtremesFromNullableContent(const ColumnVector<T> & col, const NullValuesByteMap & null_map, Field & min, Field & max)
|
|
|
|
{
|
|
|
|
const auto & data = col.getData();
|
|
|
|
size_t size = data.size();
|
|
|
|
|
|
|
|
if (size == 0)
|
|
|
|
{
|
|
|
|
min = typename NearestFieldType<T>::Type(0);
|
|
|
|
max = typename NearestFieldType<T>::Type(0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t min_i = 0;
|
|
|
|
|
|
|
|
for (; min_i < size; ++min_i)
|
|
|
|
{
|
|
|
|
if (null_map[min_i] == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (min_i == size)
|
|
|
|
{
|
|
|
|
min = Field{};
|
|
|
|
max = Field{};
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
T cur_min = data[min_i];
|
|
|
|
T cur_max = data[min_i];
|
|
|
|
|
|
|
|
for (size_t i = min_i + 1; i < size; ++i)
|
|
|
|
{
|
|
|
|
if (null_map[i] != 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (data[i] < cur_min)
|
|
|
|
cur_min = data[i];
|
|
|
|
|
|
|
|
if (data[i] > cur_max)
|
|
|
|
cur_max = data[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
min = typename NearestFieldType<T>::Type(cur_min);
|
|
|
|
max = typename NearestFieldType<T>::Type(cur_max);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-08-10 19:12:29 +00:00
|
|
|
void ColumnNullable::getExtremes(Field & min, Field & max) const
|
|
|
|
{
|
2016-08-16 11:26:17 +00:00
|
|
|
if (const auto col = typeid_cast<const ColumnInt8 *>(nested_column.get()))
|
|
|
|
getExtremesFromNullableContent<Int8>(*col, getNullMapContent().getData(), min, max);
|
|
|
|
else if (const auto col = typeid_cast<const ColumnInt16 *>(nested_column.get()))
|
|
|
|
getExtremesFromNullableContent<Int16>(*col, getNullMapContent().getData(), min, max);
|
|
|
|
else if (const auto col = typeid_cast<const ColumnInt32 *>(nested_column.get()))
|
|
|
|
getExtremesFromNullableContent<Int32>(*col, getNullMapContent().getData(), min, max);
|
|
|
|
else if (const auto col = typeid_cast<const ColumnInt64 *>(nested_column.get()))
|
|
|
|
getExtremesFromNullableContent<Int64>(*col, getNullMapContent().getData(), min, max);
|
|
|
|
else if (const auto col = typeid_cast<const ColumnUInt8 *>(nested_column.get()))
|
|
|
|
getExtremesFromNullableContent<UInt8>(*col, getNullMapContent().getData(), min, max);
|
|
|
|
else if (const auto col = typeid_cast<const ColumnUInt16 *>(nested_column.get()))
|
|
|
|
getExtremesFromNullableContent<UInt16>(*col, getNullMapContent().getData(), min, max);
|
|
|
|
else if (const auto col = typeid_cast<const ColumnUInt32 *>(nested_column.get()))
|
|
|
|
getExtremesFromNullableContent<UInt32>(*col, getNullMapContent().getData(), min, max);
|
|
|
|
else if (const auto col = typeid_cast<const ColumnUInt64 *>(nested_column.get()))
|
|
|
|
getExtremesFromNullableContent<UInt64>(*col, getNullMapContent().getData(), min, max);
|
|
|
|
else if (const auto col = typeid_cast<const ColumnFloat32 *>(nested_column.get()))
|
|
|
|
getExtremesFromNullableContent<Float32>(*col, getNullMapContent().getData(), min, max);
|
|
|
|
else if (const auto col = typeid_cast<const ColumnFloat64 *>(nested_column.get()))
|
|
|
|
getExtremesFromNullableContent<Float64>(*col, getNullMapContent().getData(), min, max);
|
2016-08-10 19:12:29 +00:00
|
|
|
else
|
2016-08-12 15:22:28 +00:00
|
|
|
nested_column->getExtremes(min, max);
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ColumnPtr ColumnNullable::replicate(const Offsets_t & offsets) const
|
|
|
|
{
|
2016-08-12 15:22:28 +00:00
|
|
|
ColumnPtr replicated_col_holder = std::make_shared<ColumnNullable>(nested_column->replicate(offsets));
|
2016-07-05 16:23:37 +00:00
|
|
|
ColumnNullable & replicated_col = static_cast<ColumnNullable &>(*replicated_col_holder);
|
2016-07-07 10:33:12 +00:00
|
|
|
replicated_col.null_map = getNullMapContent().replicate(offsets);
|
2016-07-05 16:23:37 +00:00
|
|
|
return replicated_col_holder;
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnPtr & ColumnNullable::getNestedColumn()
|
|
|
|
{
|
2016-07-07 10:33:12 +00:00
|
|
|
return nested_column;
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const ColumnPtr & ColumnNullable::getNestedColumn() const
|
|
|
|
{
|
2016-07-07 10:33:12 +00:00
|
|
|
return nested_column;
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ColumnPtr & ColumnNullable::getNullValuesByteMap()
|
|
|
|
{
|
2016-07-07 10:33:12 +00:00
|
|
|
return null_map;
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const ColumnPtr & ColumnNullable::getNullValuesByteMap() const
|
|
|
|
{
|
2016-07-07 10:33:12 +00:00
|
|
|
return null_map;
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ColumnNullable::updateNullValuesByteMap(const ColumnNullable & other)
|
|
|
|
{
|
2016-07-07 10:33:12 +00:00
|
|
|
NullValuesByteMap & arr1 = getNullMapContent().getData();
|
|
|
|
const NullValuesByteMap & arr2 = other.getNullMapContent().getData();
|
2016-07-05 16:23:37 +00:00
|
|
|
|
|
|
|
if (arr1.size() != arr2.size())
|
|
|
|
throw Exception{"Inconsistent sizes", ErrorCodes::LOGICAL_ERROR};
|
|
|
|
|
|
|
|
for (size_t i = 0; i < arr1.size(); ++i)
|
|
|
|
arr1[i] |= arr2[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ColumnNullable::isNullAt(size_t n) const
|
|
|
|
{
|
2016-07-07 10:33:12 +00:00
|
|
|
auto & arr = getNullMapContent().getData();
|
2016-07-05 16:23:37 +00:00
|
|
|
return arr[n] != 0;
|
|
|
|
}
|
|
|
|
|
2016-07-07 10:33:12 +00:00
|
|
|
ColumnUInt8 & ColumnNullable::getNullMapContent()
|
|
|
|
{
|
2016-08-10 19:12:29 +00:00
|
|
|
return static_cast<ColumnUInt8 &>(*null_map);
|
2016-07-07 10:33:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const ColumnUInt8 & ColumnNullable::getNullMapContent() const
|
|
|
|
{
|
2016-08-10 19:12:29 +00:00
|
|
|
return static_cast<const ColumnUInt8 &>(*null_map);
|
2016-07-07 10:33:12 +00:00
|
|
|
}
|
|
|
|
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|