MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / getBinaryTypeIndex

Function getBinaryTypeIndex

src/DataTypes/DataTypesBinaryEncoding.cpp:78–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76const UInt8 TYPE_JSON_SERIALIZATION_VERSION = 0;
77
78BinaryTypeIndex getBinaryTypeIndex(const DataTypePtr & type)
79{
80 /// By default custom types don't have their own BinaryTypeIndex.
81 if (type->hasCustomName())
82 {
83 /// Some widely used custom types have separate BinaryTypeIndex for better serialization.
84 /// Right now it's Bool, SimpleAggregateFunction and Nested types.
85 /// TODO: Consider adding BinaryTypeIndex for more custom types.
86
87 if (isBool(type))
88 return BinaryTypeIndex::Bool;
89
90 if (typeid_cast<const DataTypeCustomSimpleAggregateFunction *>(type->getCustomName()))
91 return BinaryTypeIndex::SimpleAggregateFunction;
92
93 if (isNested(type))
94 return BinaryTypeIndex::Nested;
95
96 return BinaryTypeIndex::Custom;
97 }
98
99 switch (type->getTypeId())
100 {
101 case TypeIndex::Nothing:
102 return BinaryTypeIndex::Nothing;
103 case TypeIndex::UInt8:
104 return BinaryTypeIndex::UInt8;
105 case TypeIndex::UInt16:
106 return BinaryTypeIndex::UInt16;
107 case TypeIndex::UInt32:
108 return BinaryTypeIndex::UInt32;
109 case TypeIndex::UInt64:
110 return BinaryTypeIndex::UInt64;
111 case TypeIndex::UInt128:
112 return BinaryTypeIndex::UInt128;
113 case TypeIndex::UInt256:
114 return BinaryTypeIndex::UInt256;
115 case TypeIndex::Int8:
116 return BinaryTypeIndex::Int8;
117 case TypeIndex::Int16:
118 return BinaryTypeIndex::Int16;
119 case TypeIndex::Int32:
120 return BinaryTypeIndex::Int32;
121 case TypeIndex::Int64:
122 return BinaryTypeIndex::Int64;
123 case TypeIndex::Int128:
124 return BinaryTypeIndex::Int128;
125 case TypeIndex::Int256:
126 return BinaryTypeIndex::Int256;
127 case TypeIndex::BFloat16:
128 return BinaryTypeIndex::BFloat16;
129 case TypeIndex::Float32:
130 return BinaryTypeIndex::Float32;
131 case TypeIndex::Float64:
132 return BinaryTypeIndex::Float64;
133 case TypeIndex::Date:
134 return BinaryTypeIndex::Date;
135 case TypeIndex::Date32:

Callers 1

encodeDataTypeImplFunction · 0.85

Calls 9

isBoolFunction · 0.85
isNestedFunction · 0.85
hasCustomNameMethod · 0.80
getCustomNameMethod · 0.80
hasExplicitNamesMethod · 0.80
ExceptionClass · 0.50
getTypeIdMethod · 0.45
hasExplicitTimeZoneMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected