| 531 | bool useDefaultImplementationForConstants() const override { return true; } |
| 532 | |
| 533 | ColumnPtr executeImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr &, size_t /*input_rows_count*/) const override |
| 534 | { |
| 535 | const auto & col_type_name = arguments[0]; |
| 536 | const ColumnPtr & column = col_type_name.column; |
| 537 | |
| 538 | if (const auto * col_in = checkAndGetColumn<ColumnIPv4>(*column)) |
| 539 | { |
| 540 | auto col_res = ColumnIPv6::create(); |
| 541 | |
| 542 | auto & vec_res = col_res->getData(); |
| 543 | vec_res.resize(col_in->size()); |
| 544 | |
| 545 | const auto & vec_in = col_in->getData(); |
| 546 | |
| 547 | for (size_t i = 0; i < vec_res.size(); ++i) |
| 548 | mapIPv4ToIPv6(vec_in[i], reinterpret_cast<UInt8 *>(&vec_res[i].toUnderType())); |
| 549 | |
| 550 | return col_res; |
| 551 | } |
| 552 | |
| 553 | if (const auto * col_in = checkAndGetColumn<ColumnUInt32>(*column)) |
| 554 | { |
| 555 | auto col_res = ColumnFixedString::create(IPV6_BINARY_LENGTH); |
| 556 | |
| 557 | auto & vec_res = col_res->getChars(); |
| 558 | vec_res.resize(col_in->size() * IPV6_BINARY_LENGTH); |
| 559 | |
| 560 | const auto & vec_in = col_in->getData(); |
| 561 | |
| 562 | for (size_t out_offset = 0, i = 0; out_offset < vec_res.size(); out_offset += IPV6_BINARY_LENGTH, ++i) |
| 563 | mapIPv4ToIPv6(vec_in[i], &vec_res[out_offset]); |
| 564 | |
| 565 | return col_res; |
| 566 | } |
| 567 | |
| 568 | throw Exception( |
| 569 | ErrorCodes::ILLEGAL_COLUMN, |
| 570 | "Illegal column {} of argument of function {}", arguments[0].column->getName(), getName() |
| 571 | ); |
| 572 | } |
| 573 | |
| 574 | private: |
| 575 | static void mapIPv4ToIPv6(UInt32 in, UInt8 * buf) |