2013-05-08 09:54:07 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <DB/Columns/IColumn.h>
|
2015-11-21 03:19:43 +00:00
|
|
|
|
#include <DB/Columns/ColumnsCommon.h>
|
2013-05-08 09:54:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
|
{
|
2014-08-20 04:57:03 +00:00
|
|
|
|
|
2013-05-08 09:54:07 +00:00
|
|
|
|
/** Базовый класс для столбцов-констант, содержащих значение, не входящее в Field.
|
|
|
|
|
* Не является полноценым столбцом и используется особым образом.
|
|
|
|
|
*/
|
|
|
|
|
class IColumnDummy : public IColumn
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
IColumnDummy(size_t s_) : s(s_) {}
|
2014-08-20 04:57:03 +00:00
|
|
|
|
|
2013-05-08 09:54:07 +00:00
|
|
|
|
virtual ColumnPtr cloneDummy(size_t s_) const = 0;
|
2014-08-20 04:57:03 +00:00
|
|
|
|
|
2014-10-31 22:15:17 +00:00
|
|
|
|
ColumnPtr cloneResized(size_t s_) const override { return cloneDummy(s_); }
|
|
|
|
|
bool isConst() const override { return true; }
|
|
|
|
|
size_t size() const override { return s; }
|
|
|
|
|
void insertDefault() override { ++s; }
|
|
|
|
|
size_t byteSize() const override { return 0; }
|
|
|
|
|
int compareAt(size_t n, size_t m, const IColumn & rhs_, int nan_direction_hint) const override { return 0; }
|
|
|
|
|
|
|
|
|
|
Field operator[](size_t n) const override { throw Exception("Cannot get value from " + getName(), ErrorCodes::NOT_IMPLEMENTED); }
|
|
|
|
|
void get(size_t n, Field & res) const override { throw Exception("Cannot get value from " + getName(), ErrorCodes::NOT_IMPLEMENTED); };
|
|
|
|
|
void insert(const Field & x) override { throw Exception("Cannot insert element into " + getName(), ErrorCodes::NOT_IMPLEMENTED); }
|
|
|
|
|
StringRef getDataAt(size_t n) const override { throw Exception("Method getDataAt is not supported for " + getName(), ErrorCodes::NOT_IMPLEMENTED); }
|
|
|
|
|
void insertData(const char * pos, size_t length) override { throw Exception("Method insertData is not supported for " + getName(), ErrorCodes::NOT_IMPLEMENTED); }
|
|
|
|
|
|
2015-10-04 03:17:36 +00:00
|
|
|
|
StringRef serializeValueIntoArena(size_t n, Arena & arena, char const *& begin) const override
|
|
|
|
|
{
|
|
|
|
|
throw Exception("Method serializeValueIntoArena is not supported for " + getName(), ErrorCodes::NOT_IMPLEMENTED);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char * deserializeAndInsertFromArena(const char * pos) override
|
|
|
|
|
{
|
|
|
|
|
throw Exception("Method deserializeAndInsertFromArena is not supported for " + getName(), ErrorCodes::NOT_IMPLEMENTED);
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-31 22:15:17 +00:00
|
|
|
|
void getExtremes(Field & min, Field & max) const override
|
2013-09-06 20:28:22 +00:00
|
|
|
|
{
|
|
|
|
|
throw Exception("Method getExtremes is not supported for " + getName(), ErrorCodes::NOT_IMPLEMENTED);
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-29 17:06:30 +00:00
|
|
|
|
void insertRangeFrom(const IColumn & src, size_t start, size_t length) override
|
2013-05-08 09:54:07 +00:00
|
|
|
|
{
|
2015-11-29 17:06:30 +00:00
|
|
|
|
s += length;
|
2013-05-08 09:54:07 +00:00
|
|
|
|
}
|
2014-08-20 04:57:03 +00:00
|
|
|
|
|
2015-12-05 07:01:18 +00:00
|
|
|
|
ColumnPtr filter(const Filter & filt, ssize_t result_size_hint) const override
|
2013-05-08 09:54:07 +00:00
|
|
|
|
{
|
2015-06-19 02:34:47 +00:00
|
|
|
|
return cloneDummy(countBytesInFilter(filt));
|
2013-05-08 09:54:07 +00:00
|
|
|
|
}
|
2014-08-20 04:57:03 +00:00
|
|
|
|
|
2014-10-31 22:15:17 +00:00
|
|
|
|
ColumnPtr permute(const Permutation & perm, size_t limit) const override
|
2013-05-08 09:54:07 +00:00
|
|
|
|
{
|
|
|
|
|
if (s != perm.size())
|
|
|
|
|
throw Exception("Size of permutation doesn't match size of column.", ErrorCodes::SIZES_OF_COLUMNS_DOESNT_MATCH);
|
2014-08-20 04:57:03 +00:00
|
|
|
|
|
2013-09-16 05:44:47 +00:00
|
|
|
|
return cloneDummy(limit ? std::min(s, limit) : s);
|
2013-05-08 09:54:07 +00:00
|
|
|
|
}
|
2014-08-20 04:57:03 +00:00
|
|
|
|
|
2014-10-31 22:15:17 +00:00
|
|
|
|
void getPermutation(bool reverse, size_t limit, Permutation & res) const override
|
2013-05-08 09:54:07 +00:00
|
|
|
|
{
|
2013-12-08 02:29:40 +00:00
|
|
|
|
res.resize(s);
|
2013-05-08 09:54:07 +00:00
|
|
|
|
for (size_t i = 0; i < s; ++i)
|
|
|
|
|
res[i] = i;
|
|
|
|
|
}
|
2014-08-20 04:57:03 +00:00
|
|
|
|
|
2014-10-31 22:15:17 +00:00
|
|
|
|
ColumnPtr replicate(const Offsets_t & offsets) const override
|
2013-05-08 09:54:07 +00:00
|
|
|
|
{
|
|
|
|
|
if (s != offsets.size())
|
|
|
|
|
throw Exception("Size of offsets doesn't match size of column.", ErrorCodes::SIZES_OF_COLUMNS_DOESNT_MATCH);
|
2014-08-20 04:57:03 +00:00
|
|
|
|
|
|
|
|
|
return cloneDummy(s == 0 ? 0 : offsets.back());
|
2013-05-08 09:54:07 +00:00
|
|
|
|
}
|
2014-08-20 04:57:03 +00:00
|
|
|
|
|
2013-05-08 09:54:07 +00:00
|
|
|
|
private:
|
|
|
|
|
size_t s;
|
|
|
|
|
};
|
2014-08-20 04:57:03 +00:00
|
|
|
|
|
2013-05-08 09:54:07 +00:00
|
|
|
|
}
|