| 1 | #include <Common/typeid_cast.h> |
|---|---|
| 2 | #include <DataTypes/DataTypeNothing.h> |
| 3 | #include <DataTypes/DataTypeFactory.h> |
| 4 | #include <Columns/ColumnNothing.h> |
| 5 | #include <IO/ReadBuffer.h> |
| 6 | #include <IO/WriteBuffer.h> |
| 7 | |
| 8 | |
| 9 | namespace DB |
| 10 | { |
| 11 | |
| 12 | MutableColumnPtr DataTypeNothing::createColumn() const |
| 13 | { |
| 14 | return ColumnNothing::create(0); |
| 15 | } |
| 16 | |
| 17 | void DataTypeNothing::serializeBinaryBulk(const IColumn & column, WriteBuffer & ostr, size_t offset, size_t limit) const |
| 18 | { |
| 19 | size_t size = column.size(); |
| 20 | |
| 21 | if (limit == 0 || offset + limit > size) |
| 22 | limit = size - offset; |
| 23 | |
| 24 | for (size_t i = 0; i < limit; ++i) |
| 25 | ostr.write('0'); |
| 26 | } |
| 27 | |
| 28 | void DataTypeNothing::deserializeBinaryBulk(IColumn & column, ReadBuffer & istr, size_t limit, double /*avg_value_size_hint*/) const |
| 29 | { |
| 30 | typeid_cast<ColumnNothing &>(column).addSize(istr.tryIgnore(limit)); |
| 31 | } |
| 32 | |
| 33 | bool DataTypeNothing::equals(const IDataType & rhs) const |
| 34 | { |
| 35 | return typeid(rhs) == typeid(*this); |
| 36 | } |
| 37 | |
| 38 | |
| 39 | void registerDataTypeNothing(DataTypeFactory & factory) |
| 40 | { |
| 41 | const auto & creator = [&](const String & /*type_name*/) { return DataTypePtr(std::make_shared<DataTypeNothing>()); }; |
| 42 | |
| 43 | factory.registerSimpleDataType("Nothing", creator); |
| 44 | } |
| 45 | |
| 46 | } |
| 47 |