ClickHouse/dbms/DataTypes/DataTypeArray.h

121 lines
4.5 KiB
C++
Raw Normal View History

2012-08-26 06:48:39 +00:00
#pragma once
#include <DataTypes/DataTypeWithSimpleSerialization.h>
2012-08-26 06:48:39 +00:00
namespace DB
{
class DataTypeArray final : public DataTypeWithSimpleSerialization
2012-08-26 06:48:39 +00:00
{
private:
2017-04-17 11:56:55 +00:00
/// The type of array elements.
DataTypePtr nested;
2012-08-26 11:14:52 +00:00
2012-08-26 06:48:39 +00:00
public:
static constexpr bool is_parametric = true;
DataTypeArray(const DataTypePtr & nested_);
2018-08-31 08:59:21 +00:00
TypeIndex getTypeId() const override { return TypeIndex::Array; }
std::string doGetName() const override
{
return "Array(" + nested->getName() + ")";
}
2012-08-26 06:48:39 +00:00
const char * getFamilyName() const override
{
return "Array";
}
bool canBeInsideNullable() const override
{
return false;
}
void serializeBinary(const Field & field, WriteBuffer & ostr) const override;
void deserializeBinary(Field & field, ReadBuffer & istr) const override;
void serializeBinary(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
void deserializeBinary(IColumn & column, ReadBuffer & istr) const override;
2012-08-26 06:48:39 +00:00
void serializeText(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings &) const override;
void deserializeText(IColumn & column, ReadBuffer & istr, const FormatSettings &) const override;
void serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings &) const override;
void deserializeTextJSON(IColumn & column, ReadBuffer & istr, const FormatSettings &) const override;
void serializeTextXML(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings &) const override;
void serializeTextCSV(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings &) const override;
void deserializeTextCSV(IColumn & column, ReadBuffer & istr, const FormatSettings &) const override;
2017-04-17 11:56:55 +00:00
/** Streaming serialization of arrays is arranged in a special way:
* - elements placed in a row are written/read without array sizes;
* - the sizes are written/read in a separate stream,
2017-04-17 11:56:55 +00:00
* This is necessary, because when implementing nested structures, several arrays can have common sizes.
*/
2012-08-26 06:48:39 +00:00
void enumerateStreams(const StreamCallback & callback, SubstreamPath & path) const override;
void serializeBinaryBulkStatePrefix(
SerializeBinaryBulkSettings & settings,
SerializeBinaryBulkStatePtr & state) const override;
void serializeBinaryBulkStateSuffix(
SerializeBinaryBulkSettings & settings,
SerializeBinaryBulkStatePtr & state) const override;
void deserializeBinaryBulkStatePrefix(
DeserializeBinaryBulkSettings & settings,
DeserializeBinaryBulkStatePtr & state) const override;
void serializeBinaryBulkWithMultipleStreams(
const IColumn & column,
size_t offset,
size_t limit,
SerializeBinaryBulkSettings & settings,
SerializeBinaryBulkStatePtr & state) const override;
void deserializeBinaryBulkWithMultipleStreams(
IColumn & column,
size_t limit,
DeserializeBinaryBulkSettings & settings,
DeserializeBinaryBulkStatePtr & state) const override;
2012-08-27 05:13:14 +00:00
void serializeProtobuf(const IColumn & column,
size_t row_num,
ProtobufWriter & protobuf,
size_t & value_index) const override;
void deserializeProtobuf(IColumn & column,
ProtobufReader & protobuf,
bool allow_add_row,
bool & row_added) const override;
MutableColumnPtr createColumn() const override;
2012-08-26 06:48:39 +00:00
Field getDefault() const override;
2012-08-26 11:14:52 +00:00
bool equals(const IDataType & rhs) const override;
bool isParametric() const override { return true; }
bool haveSubtypes() const override { return true; }
bool cannotBeStoredInTables() const override { return nested->cannotBeStoredInTables(); }
bool textCanContainOnlyValidUTF8() const override { return nested->textCanContainOnlyValidUTF8(); }
bool isComparable() const override { return nested->isComparable(); }
bool canBeComparedWithCollation() const override { return nested->canBeComparedWithCollation(); }
bool isValueUnambiguouslyRepresentedInContiguousMemoryRegion() const override
{
return nested->isValueUnambiguouslyRepresentedInFixedSizeContiguousMemoryRegion();
}
const DataTypePtr & getNestedType() const { return nested; }
2019-03-05 21:53:16 +00:00
/// 1 for plain array, 2 for array of arrays and so on.
size_t getNumberOfDimensions() const;
2012-08-26 06:48:39 +00:00
};
}