26 namespace data_conversion {
39 const bool error_tracking_enabled,
40 const bool geo_validate_geometry) {
42 ? param.
geo_chunks.begin()->getColumnDesc()->columnType
44 if (dst_type_info.is_dict_encoded_string()) {
45 switch (dst_type_info.get_size()) {
47 return std::make_unique<StringViewToStringDictEncoder<uint8_t>>(
50 return std::make_unique<StringViewToStringDictEncoder<uint16_t>>(
53 return std::make_unique<StringViewToStringDictEncoder<int32_t>>(
58 }
else if (dst_type_info.is_none_encoded_string()) {
59 return std::make_unique<StringViewToStringNoneEncoder>(param.
dst_chunk,
60 error_tracking_enabled);
61 }
else if (dst_type_info.is_date_in_days()) {
62 switch (dst_type_info.get_comp_param()) {
65 return std::make_unique<StringViewToScalarEncoder<int32_t, int64_t>>(
68 return std::make_unique<StringViewToScalarEncoder<int16_t, int64_t>>(
73 }
else if (dst_type_info.is_integer() || dst_type_info.is_boolean() ||
74 dst_type_info.is_fp() || dst_type_info.is_decimal() ||
75 dst_type_info.is_time_or_date()) {
77 switch (dst_type_info.get_type()) {
80 return std::make_unique<StringViewToScalarEncoder<int8_t>>(
83 return std::make_unique<StringViewToScalarEncoder<int16_t>>(
86 return std::make_unique<StringViewToScalarEncoder<int32_t>>(
94 return std::make_unique<StringViewToScalarEncoder<int64_t>>(
97 return std::make_unique<StringViewToScalarEncoder<float>>(
100 return std::make_unique<StringViewToScalarEncoder<double>>(
101 param.
dst_chunk, error_tracking_enabled);
106 switch (dst_type_info.get_type()) {
108 switch (dst_type_info.get_comp_param()) {
110 return std::make_unique<StringViewToScalarEncoder<int8_t, int16_t>>(
111 param.
dst_chunk, error_tracking_enabled);
117 switch (dst_type_info.get_comp_param()) {
119 return std::make_unique<StringViewToScalarEncoder<int8_t, int32_t>>(
120 param.
dst_chunk, error_tracking_enabled);
122 return std::make_unique<StringViewToScalarEncoder<int16_t, int32_t>>(
123 param.
dst_chunk, error_tracking_enabled);
131 switch (dst_type_info.get_comp_param()) {
133 return std::make_unique<StringViewToScalarEncoder<int8_t, int64_t>>(
134 param.
dst_chunk, error_tracking_enabled);
136 return std::make_unique<StringViewToScalarEncoder<int16_t, int64_t>>(
137 param.
dst_chunk, error_tracking_enabled);
139 return std::make_unique<StringViewToScalarEncoder<int32_t, int64_t>>(
140 param.
dst_chunk, error_tracking_enabled);
148 return std::make_unique<StringViewToScalarEncoder<int32_t, int64_t>>(
149 param.
dst_chunk, error_tracking_enabled);
156 }
else if (dst_type_info.is_array()) {
157 auto dst_sub_type_info = dst_type_info.get_elem_type();
158 if (dst_sub_type_info.is_dict_encoded_string()) {
159 switch (dst_sub_type_info.get_size()) {
161 return std::make_unique<
167 }
else if (dst_sub_type_info.is_none_encoded_string()) {
169 }
else if (dst_sub_type_info.is_date_in_days()) {
170 switch (dst_sub_type_info.get_comp_param()) {
173 return std::make_unique<
178 error_tracking_enabled);
182 }
else if (dst_sub_type_info.is_integer() || dst_sub_type_info.is_boolean() ||
183 dst_sub_type_info.is_fp() || dst_sub_type_info.is_decimal() ||
184 dst_sub_type_info.is_time_or_date()) {
186 switch (dst_sub_type_info.get_type()) {
188 return std::make_unique<
193 error_tracking_enabled);
195 return std::make_unique<
200 error_tracking_enabled);
202 return std::make_unique<
207 error_tracking_enabled);
209 return std::make_unique<
214 error_tracking_enabled);
221 return std::make_unique<
226 error_tracking_enabled);
228 return std::make_unique<
233 error_tracking_enabled);
235 return std::make_unique<
240 error_tracking_enabled);
250 }
else if (dst_type_info.is_geometry()) {
251 return std::make_unique<StringViewToGeoEncoder>(param.
geo_chunks,
253 error_tracking_enabled,
254 geo_validate_geometry);
257 UNREACHABLE() <<
"could not find appropriate encoder to create, conversion use case is "
265 CHECK(src_type_info.is_string()) <<
"Only string source types currently implemented.";
267 if (src_type_info.is_dict_encoded_string() || src_type_info.is_none_encoded_string()) {
268 return std::make_unique<StringViewSource>(input);
270 UNREACHABLE() <<
"unknown string type, not supported";
std::unique_ptr< BaseConvertEncoder > create_string_view_encoder(ConversionFactoryParam ¶m, const bool error_tracking_enabled, const bool geo_validate_geometry)
Chunk_NS::Chunk dst_chunk
const ColumnDescriptor * getColumnDesc() const
std::optional< Chunk_NS::Chunk > delete_chunk
Chunk_NS::Chunk scalar_temp_chunk
std::list< Chunk_NS::Chunk > geo_chunks
std::unique_ptr< BaseSource > create_source(const Chunk_NS::Chunk &input, const int db_id)
std::list< std::unique_ptr< ChunkMetadata > > geo_chunk_metadata