| 341 | private: |
| 342 | template <typename ArgType> |
| 343 | ColumnPtr executeTyped(const ColumnsWithTypeAndName & arguments, const DataTypePtr &, size_t /*input_rows_count*/) const |
| 344 | { |
| 345 | using ColumnType = ColumnVector<ArgType>; |
| 346 | |
| 347 | const ColumnPtr & column = arguments[0].column; |
| 348 | |
| 349 | if (const ColumnType * col = typeid_cast<const ColumnType *>(column.get())) |
| 350 | { |
| 351 | const typename ColumnType::Container & vec_in = col->getData(); |
| 352 | |
| 353 | auto col_res = ColumnString::create(); |
| 354 | |
| 355 | ColumnString::Chars & vec_res = col_res->getChars(); |
| 356 | ColumnString::Offsets & offsets_res = col_res->getOffsets(); |
| 357 | |
| 358 | vec_res.resize(vec_in.size() * (IPV4_MAX_TEXT_LENGTH + 1)); /// the longest value is: 255.255.255.255\0 |
| 359 | offsets_res.resize(vec_in.size()); |
| 360 | char * begin = reinterpret_cast<char *>(vec_res.data()); |
| 361 | char * pos = begin; |
| 362 | |
| 363 | for (size_t i = 0; i < vec_in.size(); ++i) |
| 364 | { |
| 365 | DB::formatIPv4(reinterpret_cast<const unsigned char*>(&vec_in[i]), sizeof(ArgType), pos, mask_tail_octets, "xxx"); |
| 366 | offsets_res[i] = pos - begin; |
| 367 | } |
| 368 | |
| 369 | vec_res.resize(pos - begin); |
| 370 | |
| 371 | return col_res; |
| 372 | } |
| 373 | else |
| 374 | throw Exception(ErrorCodes::ILLEGAL_COLUMN, "Illegal column {} of argument of function {}", |
| 375 | arguments[0].column->getName(), getName()); |
| 376 | } |
| 377 | public: |
| 378 | static constexpr auto name = Name::name; |
| 379 | static FunctionPtr create(ContextPtr) { return std::make_shared<FunctionIPv4NumToString<mask_tail_octets, Name>>(); } |