2017-03-11 01:25:27 +00:00
|
|
|
#include <DB/Common/Arena.h>
|
2016-07-05 16:23:37 +00:00
|
|
|
#include <DB/Columns/ColumnNullable.h>
|
|
|
|
|
2017-03-11 01:25:27 +00:00
|
|
|
|
2016-07-05 16:23:37 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
2017-03-11 01:25:27 +00:00
|
|
|
extern const int LOGICAL_ERROR;
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
2017-03-11 01:25:27 +00:00
|
|
|
|
2016-08-16 22:40:05 +00:00
|
|
|
ColumnNullable::ColumnNullable(ColumnPtr nested_column_, ColumnPtr null_map_)
|
|
|
|
: nested_column{nested_column_}, null_map{null_map_}
|
2016-08-10 19:12:29 +00:00
|
|
|
{
|
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};
|
2017-03-06 21:36:33 +00:00
|
|
|
|
2017-03-09 03:57:51 +00:00
|
|
|
/// ColumnNullable cannot have constant nested column. But constant argument could be passed. Materialize it.
|
|
|
|
if (auto nested_column_materialized = nested_column->convertToFullColumnIfConst())
|
|
|
|
nested_column = nested_column_materialized;
|
2017-03-06 21:36:33 +00:00
|
|
|
|
|
|
|
if (null_map->isConst())
|
|
|
|
throw Exception{"ColumnNullable cannot have constant null map", ErrorCodes::LOGICAL_ERROR};
|
2016-08-10 19:12:29 +00:00
|
|
|
}
|
|
|
|
|
2016-12-30 05:13:14 +00:00
|
|
|
|
2016-07-05 16:23:37 +00:00
|
|
|
ColumnPtr ColumnNullable::convertToFullColumnIfConst() const
|
|
|
|
{
|
|
|
|
ColumnPtr new_col_holder;
|
|
|
|
|
2016-08-12 15:22:28 +00:00
|
|
|
if (auto full_col = nested_column->convertToFullColumnIfConst())
|
2016-08-16 22:40:05 +00:00
|
|
|
new_col_holder = std::make_shared<ColumnNullable>(full_col, null_map);
|
2016-07-05 16:23:37 +00:00
|
|
|
|
|
|
|
return new_col_holder;
|
|
|
|
}
|
|
|
|
|
2016-12-30 05:13:14 +00:00
|
|
|
|
2016-07-11 10:09:16 +00:00
|
|
|
void ColumnNullable::updateHashWithValue(size_t n, SipHash & hash) const
|
|
|
|
{
|
2016-12-30 05:13:14 +00:00
|
|
|
const auto & arr = getNullMap();
|
2016-08-16 12:34:54 +00:00
|
|
|
hash.update(reinterpret_cast<const char *>(&arr[n]), sizeof(arr[0]));
|
|
|
|
if (arr[n] == 0)
|
2016-08-12 15:22:28 +00:00
|
|
|
nested_column->updateHashWithValue(n, hash);
|
2016-07-11 10:09:16 +00:00
|
|
|
}
|
|
|
|
|
2016-12-30 05:13:14 +00:00
|
|
|
|
2017-01-04 04:30:18 +00:00
|
|
|
ColumnPtr ColumnNullable::cloneResized(size_t new_size) const
|
2016-07-05 16:23:37 +00:00
|
|
|
{
|
2017-01-04 04:30:18 +00:00
|
|
|
ColumnPtr new_nested_col = nested_column->cloneResized(new_size);
|
|
|
|
auto new_null_map = std::make_shared<ColumnUInt8>();
|
|
|
|
|
|
|
|
if (new_size > 0)
|
|
|
|
{
|
|
|
|
new_null_map->getData().resize(new_size);
|
|
|
|
|
|
|
|
size_t count = std::min(size(), new_size);
|
|
|
|
memcpy(new_null_map->getData().data(), getNullMap().data(), count * sizeof(getNullMap()[0]));
|
|
|
|
|
|
|
|
/// If resizing to bigger one, set all new values to NULLs.
|
|
|
|
if (new_size > count)
|
|
|
|
memset(&new_null_map->getData()[count], 1, new_size - count);
|
|
|
|
}
|
|
|
|
|
2016-08-16 22:40:05 +00:00
|
|
|
return std::make_shared<ColumnNullable>(new_nested_col, new_null_map);
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
2016-12-30 05:13:14 +00:00
|
|
|
|
2016-07-05 16:23:37 +00:00
|
|
|
Field ColumnNullable::operator[](size_t n) const
|
|
|
|
{
|
|
|
|
if (isNullAt(n))
|
2016-12-30 05:13:14 +00:00
|
|
|
return Null();
|
2016-07-05 16:23:37 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2016-12-30 05:13:14 +00:00
|
|
|
|
2016-07-05 16:23:37 +00:00
|
|
|
void ColumnNullable::get(size_t n, Field & res) const
|
|
|
|
{
|
|
|
|
if (isNullAt(n))
|
2016-12-30 05:13:14 +00:00
|
|
|
res = Null();
|
2016-07-05 16:23:37 +00:00
|
|
|
else
|
2016-08-12 15:22:28 +00:00
|
|
|
nested_column->get(n, res);
|
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-12-30 05:13:14 +00:00
|
|
|
const auto & arr = getNullMap();
|
2016-08-16 12:53:22 +00:00
|
|
|
static constexpr auto s = sizeof(arr[0]);
|
|
|
|
|
|
|
|
auto pos = arena.allocContinue(s, begin);
|
|
|
|
memcpy(pos, &arr[n], s);
|
|
|
|
|
2016-10-20 12:58:18 +00:00
|
|
|
size_t nested_size = 0;
|
|
|
|
|
2016-08-16 12:53:22 +00:00
|
|
|
if (arr[n] == 0)
|
2016-10-20 12:58:18 +00:00
|
|
|
nested_size = nested_column->serializeValueIntoArena(n, arena, begin).size;
|
|
|
|
|
|
|
|
return StringRef{begin, s + nested_size};
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char * ColumnNullable::deserializeAndInsertFromArena(const char * pos)
|
|
|
|
{
|
2016-08-16 12:53:22 +00:00
|
|
|
UInt8 val = *reinterpret_cast<const UInt8 *>(pos);
|
2016-10-20 12:58:18 +00:00
|
|
|
pos += sizeof(val);
|
2016-08-16 12:53:22 +00:00
|
|
|
|
2016-12-30 05:13:14 +00:00
|
|
|
getNullMap().push_back(val);
|
2016-08-16 12:53:22 +00:00
|
|
|
|
|
|
|
if (val == 0)
|
2016-10-20 12:58:18 +00:00
|
|
|
pos = nested_column->deserializeAndInsertFromArena(pos);
|
2016-08-16 12:53:22 +00:00
|
|
|
else
|
2016-10-20 12:58:18 +00:00
|
|
|
nested_column->insertDefault();
|
|
|
|
|
|
|
|
return pos;
|
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);
|
2016-12-30 05:13:14 +00:00
|
|
|
getNullMapConcreteColumn().insertRangeFrom(*nullable_col.null_map, start, length);
|
2016-08-16 11:26:17 +00:00
|
|
|
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-12-30 05:13:14 +00:00
|
|
|
getNullMap().push_back(1);
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-08-12 15:22:28 +00:00
|
|
|
nested_column->insert(x);
|
2016-12-30 05:13:14 +00:00
|
|
|
getNullMap().push_back(0);
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-17 20:47:37 +00:00
|
|
|
void ColumnNullable::insertFrom(const IColumn & src, size_t n)
|
|
|
|
{
|
|
|
|
const ColumnNullable & src_concrete = static_cast<const ColumnNullable &>(src);
|
|
|
|
nested_column->insertFrom(*src_concrete.getNestedColumn(), n);
|
|
|
|
getNullMap().push_back(src_concrete.getNullMap()[n]);
|
|
|
|
}
|
|
|
|
|
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-12-30 05:13:14 +00:00
|
|
|
getNullMapConcreteColumn().popBack(n);
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ColumnPtr ColumnNullable::filter(const Filter & filt, ssize_t result_size_hint) const
|
|
|
|
{
|
2016-08-16 22:40:05 +00:00
|
|
|
ColumnPtr filtered_data = nested_column->filter(filt, result_size_hint);
|
2016-12-30 05:13:14 +00:00
|
|
|
ColumnPtr filtered_null_map = getNullMapConcreteColumn().filter(filt, result_size_hint);
|
2016-08-16 22:40:05 +00:00
|
|
|
return std::make_shared<ColumnNullable>(filtered_data, filtered_null_map);
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ColumnPtr ColumnNullable::permute(const Permutation & perm, size_t limit) const
|
|
|
|
{
|
2016-08-16 22:40:05 +00:00
|
|
|
ColumnPtr permuted_data = nested_column->permute(perm, limit);
|
2016-12-30 05:13:14 +00:00
|
|
|
ColumnPtr permuted_null_map = getNullMapConcreteColumn().permute(perm, limit);
|
2016-08-16 22:40:05 +00:00
|
|
|
return std::make_shared<ColumnNullable>(permuted_data, permuted_null_map);
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
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-17 17:20:21 +00:00
|
|
|
/// NULL values share the properties of NaN values.
|
|
|
|
/// Here the last parameter of compareAt is called null_direction_hint
|
|
|
|
/// instead of the usual nan_direction_hint and is used to implement
|
|
|
|
/// the ordering specified by either NULLS FIRST or NULLS LAST in the
|
|
|
|
/// ORDER BY construction.
|
|
|
|
|
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-17 17:20:21 +00:00
|
|
|
if (unlikely(lval_is_null || rval_is_null))
|
|
|
|
{
|
|
|
|
if (lval_is_null && rval_is_null)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return lval_is_null ? null_direction_hint : -null_direction_hint;
|
|
|
|
}
|
2016-07-05 16:23:37 +00:00
|
|
|
|
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
|
|
|
|
{
|
2017-02-10 10:20:06 +00:00
|
|
|
/// Cannot pass limit because of unknown amount of NULLs.
|
|
|
|
nested_column->getPermutation(reverse, 0, res);
|
2016-08-10 19:12:29 +00:00
|
|
|
|
2017-02-10 10:20:06 +00:00
|
|
|
/// Shift all NULL values to the end.
|
2016-08-10 19:12:29 +00:00
|
|
|
|
2017-02-10 10:20:06 +00:00
|
|
|
size_t read_idx = 0;
|
|
|
|
size_t write_idx = 0;
|
|
|
|
size_t end_idx = res.size();
|
2016-08-10 19:12:29 +00:00
|
|
|
|
2017-02-10 10:20:06 +00:00
|
|
|
if (!limit)
|
|
|
|
limit = end_idx;
|
2016-08-10 19:12:29 +00:00
|
|
|
|
2017-02-10 10:20:06 +00:00
|
|
|
while (read_idx < limit && !isNullAt(res[read_idx]))
|
2016-08-10 19:12:29 +00:00
|
|
|
{
|
2017-02-10 10:20:06 +00:00
|
|
|
++read_idx;
|
|
|
|
++write_idx;
|
2016-08-10 19:12:29 +00:00
|
|
|
}
|
2017-02-10 10:20:06 +00:00
|
|
|
|
|
|
|
++read_idx;
|
|
|
|
|
|
|
|
/// Invariants:
|
|
|
|
/// write_idx < read_idx
|
|
|
|
/// write_idx points to NULL
|
|
|
|
/// read_idx will be incremented to position of next not-NULL
|
|
|
|
/// there are range of NULLs between write_idx and read_idx - 1,
|
|
|
|
/// We are moving elements from end to begin of this range,
|
|
|
|
/// so range will "bubble" towards the end.
|
|
|
|
/// Relative order of NULL elements could be changed,
|
|
|
|
/// but relative order of non-NULLs is preserved.
|
|
|
|
|
|
|
|
while (read_idx < end_idx && write_idx < limit)
|
2016-08-10 19:12:29 +00:00
|
|
|
{
|
2017-02-10 10:20:06 +00:00
|
|
|
if (!isNullAt(res[read_idx]))
|
2016-08-10 19:12:29 +00:00
|
|
|
{
|
2017-02-10 10:20:06 +00:00
|
|
|
std::swap(res[read_idx], res[write_idx]);
|
|
|
|
++write_idx;
|
2016-08-10 19:12:29 +00:00
|
|
|
}
|
2017-02-10 10:20:06 +00:00
|
|
|
++read_idx;
|
2016-08-10 19:12:29 +00:00
|
|
|
}
|
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-12-30 05:13:14 +00:00
|
|
|
getNullMap().reserve(n);
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t ColumnNullable::byteSize() const
|
|
|
|
{
|
2016-12-30 05:13:14 +00:00
|
|
|
return nested_column->byteSize() + getNullMapConcreteColumn().byteSize();
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
2017-01-17 20:54:32 +00:00
|
|
|
size_t ColumnNullable::allocatedSize() const
|
|
|
|
{
|
|
|
|
return nested_column->allocatedSize() + getNullMapConcreteColumn().allocatedSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2016-12-30 05:13:14 +00:00
|
|
|
min = Null();
|
|
|
|
max = Null();
|
2016-08-16 11:26:17 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-12-30 05:13:14 +00:00
|
|
|
bool has_not_null = false;
|
|
|
|
bool has_not_nan = false;
|
2016-08-16 11:26:17 +00:00
|
|
|
|
2016-12-30 05:13:14 +00:00
|
|
|
T cur_min = 0;
|
|
|
|
T cur_max = 0;
|
2016-08-16 11:26:17 +00:00
|
|
|
|
2016-12-30 05:13:14 +00:00
|
|
|
for (size_t i = 0; i < size; ++i)
|
2016-08-16 11:26:17 +00:00
|
|
|
{
|
2016-12-30 05:13:14 +00:00
|
|
|
const T x = data[i];
|
2016-08-16 11:26:17 +00:00
|
|
|
|
2016-12-30 05:13:14 +00:00
|
|
|
if (null_map[i])
|
|
|
|
continue;
|
2016-08-16 11:26:17 +00:00
|
|
|
|
2016-12-30 05:13:14 +00:00
|
|
|
if (!has_not_null)
|
|
|
|
{
|
|
|
|
cur_min = x;
|
|
|
|
cur_max = x;
|
|
|
|
has_not_null = true;
|
2016-08-16 11:26:17 +00:00
|
|
|
continue;
|
2016-12-30 05:13:14 +00:00
|
|
|
}
|
2016-08-16 11:26:17 +00:00
|
|
|
|
2016-12-30 05:13:14 +00:00
|
|
|
if (isNaN(x))
|
|
|
|
continue;
|
2016-08-16 11:26:17 +00:00
|
|
|
|
2016-12-30 05:13:14 +00:00
|
|
|
if (!has_not_nan)
|
|
|
|
{
|
|
|
|
cur_min = x;
|
|
|
|
cur_max = x;
|
|
|
|
has_not_nan = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x < cur_min)
|
|
|
|
cur_min = x;
|
|
|
|
|
|
|
|
if (x > cur_max)
|
|
|
|
cur_max = x;
|
2016-08-16 11:26:17 +00:00
|
|
|
}
|
|
|
|
|
2016-12-30 05:13:14 +00:00
|
|
|
if (has_not_null)
|
|
|
|
{
|
|
|
|
min = typename NearestFieldType<T>::Type(cur_min);
|
|
|
|
max = typename NearestFieldType<T>::Type(cur_max);
|
|
|
|
}
|
2016-08-16 11:26:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-12-30 05:13:14 +00:00
|
|
|
|
2016-08-10 19:12:29 +00:00
|
|
|
void ColumnNullable::getExtremes(Field & min, Field & max) const
|
|
|
|
{
|
2016-12-30 05:13:14 +00:00
|
|
|
min = Null();
|
|
|
|
max = Null();
|
|
|
|
|
|
|
|
const auto & null_map = getNullMap();
|
|
|
|
|
2016-08-16 11:26:17 +00:00
|
|
|
if (const auto col = typeid_cast<const ColumnInt8 *>(nested_column.get()))
|
2016-12-30 05:13:14 +00:00
|
|
|
getExtremesFromNullableContent<Int8>(*col, null_map, min, max);
|
2016-08-16 11:26:17 +00:00
|
|
|
else if (const auto col = typeid_cast<const ColumnInt16 *>(nested_column.get()))
|
2016-12-30 05:13:14 +00:00
|
|
|
getExtremesFromNullableContent<Int16>(*col, null_map, min, max);
|
2016-08-16 11:26:17 +00:00
|
|
|
else if (const auto col = typeid_cast<const ColumnInt32 *>(nested_column.get()))
|
2016-12-30 05:13:14 +00:00
|
|
|
getExtremesFromNullableContent<Int32>(*col, null_map, min, max);
|
2016-08-16 11:26:17 +00:00
|
|
|
else if (const auto col = typeid_cast<const ColumnInt64 *>(nested_column.get()))
|
2016-12-30 05:13:14 +00:00
|
|
|
getExtremesFromNullableContent<Int64>(*col, null_map, min, max);
|
2016-08-16 11:26:17 +00:00
|
|
|
else if (const auto col = typeid_cast<const ColumnUInt8 *>(nested_column.get()))
|
2016-12-30 05:13:14 +00:00
|
|
|
getExtremesFromNullableContent<UInt8>(*col, null_map, min, max);
|
2016-08-16 11:26:17 +00:00
|
|
|
else if (const auto col = typeid_cast<const ColumnUInt16 *>(nested_column.get()))
|
2016-12-30 05:13:14 +00:00
|
|
|
getExtremesFromNullableContent<UInt16>(*col, null_map, min, max);
|
2016-08-16 11:26:17 +00:00
|
|
|
else if (const auto col = typeid_cast<const ColumnUInt32 *>(nested_column.get()))
|
2016-12-30 05:13:14 +00:00
|
|
|
getExtremesFromNullableContent<UInt32>(*col, null_map, min, max);
|
2016-08-16 11:26:17 +00:00
|
|
|
else if (const auto col = typeid_cast<const ColumnUInt64 *>(nested_column.get()))
|
2016-12-30 05:13:14 +00:00
|
|
|
getExtremesFromNullableContent<UInt64>(*col, null_map, min, max);
|
2016-08-16 11:26:17 +00:00
|
|
|
else if (const auto col = typeid_cast<const ColumnFloat32 *>(nested_column.get()))
|
2016-12-30 05:13:14 +00:00
|
|
|
getExtremesFromNullableContent<Float32>(*col, null_map, min, max);
|
2016-08-16 11:26:17 +00:00
|
|
|
else if (const auto col = typeid_cast<const ColumnFloat64 *>(nested_column.get()))
|
2016-12-30 05:13:14 +00:00
|
|
|
getExtremesFromNullableContent<Float64>(*col, null_map, min, max);
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
2016-12-30 05:13:14 +00:00
|
|
|
|
2016-07-05 16:23:37 +00:00
|
|
|
ColumnPtr ColumnNullable::replicate(const Offsets_t & offsets) const
|
|
|
|
{
|
2016-08-16 22:40:05 +00:00
|
|
|
ColumnPtr replicated_data = nested_column->replicate(offsets);
|
2016-12-30 05:13:14 +00:00
|
|
|
ColumnPtr replicated_null_map = getNullMapConcreteColumn().replicate(offsets);
|
2016-08-16 22:40:05 +00:00
|
|
|
return std::make_shared<ColumnNullable>(replicated_data, replicated_null_map);
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
2016-12-30 05:13:14 +00:00
|
|
|
|
2017-03-07 20:52:09 +00:00
|
|
|
template <bool negative>
|
|
|
|
void ColumnNullable::applyNullValuesByteMapImpl(const ColumnUInt8 & map)
|
2016-07-05 16:23:37 +00:00
|
|
|
{
|
2016-12-30 05:13:14 +00:00
|
|
|
NullValuesByteMap & arr1 = getNullMap();
|
2017-03-07 20:42:01 +00:00
|
|
|
const NullValuesByteMap & arr2 = map.getData();
|
2016-07-05 16:23:37 +00:00
|
|
|
|
|
|
|
if (arr1.size() != arr2.size())
|
2016-12-30 05:13:14 +00:00
|
|
|
throw Exception{"Inconsistent sizes of ColumnNullable objects", ErrorCodes::LOGICAL_ERROR};
|
2016-07-05 16:23:37 +00:00
|
|
|
|
2017-01-04 06:51:01 +00:00
|
|
|
for (size_t i = 0, size = arr1.size(); i < size; ++i)
|
2017-03-07 20:52:09 +00:00
|
|
|
arr1[i] |= negative ^ arr2[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ColumnNullable::applyNullValuesByteMap(const ColumnUInt8 & map)
|
|
|
|
{
|
|
|
|
applyNullValuesByteMapImpl<false>(map);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ColumnNullable::applyNegatedNullValuesByteMap(const ColumnUInt8 & map)
|
|
|
|
{
|
|
|
|
applyNullValuesByteMapImpl<true>(map);
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|
|
|
|
|
2017-03-07 20:42:01 +00:00
|
|
|
|
|
|
|
void ColumnNullable::applyNullValuesByteMap(const ColumnNullable & other)
|
|
|
|
{
|
|
|
|
applyNullValuesByteMap(other.getNullMapConcreteColumn());
|
|
|
|
}
|
|
|
|
|
2016-07-05 16:23:37 +00:00
|
|
|
}
|