| 683 | }; |
| 684 | |
| 685 | UnorderedMapWithMemoryTracking<String, ColumnPtr> RegExpTreeDictionary::match( |
| 686 | const ColumnString::Chars & keys_data, |
| 687 | const ColumnString::Offsets & keys_offsets, |
| 688 | const UnorderedMapWithMemoryTracking<String, const DictionaryAttribute &> & attributes, |
| 689 | DefaultMapOrFilter default_or_filter, |
| 690 | std::optional<size_t> collect_values_limit) const |
| 691 | { |
| 692 | bool is_short_circuit = std::holds_alternative<RefFilter>(default_or_filter); |
| 693 | chassert(is_short_circuit || std::holds_alternative<RefDefaultMap>(default_or_filter)); |
| 694 | |
| 695 | #if USE_VECTORSCAN |
| 696 | hs_scratch_t * scratch = nullptr; |
| 697 | if (use_vectorscan) |
| 698 | { |
| 699 | hs_error_t err = hs_clone_scratch(origin_scratch.get(), &scratch); |
| 700 | |
| 701 | if (err != HS_SUCCESS) |
| 702 | { |
| 703 | throw Exception(ErrorCodes::CANNOT_ALLOCATE_MEMORY, "Could not clone scratch space for hyperscan"); |
| 704 | } |
| 705 | } |
| 706 | |
| 707 | MultiRegexps::ScratchPtr smart_scratch(scratch); |
| 708 | #endif |
| 709 | |
| 710 | UnorderedMapWithMemoryTracking<String, MutableColumnPtr> columns; |
| 711 | |
| 712 | size_t input_rows_count = keys_offsets.size(); |
| 713 | |
| 714 | /// initialize columns |
| 715 | for (const auto & [name_, attr] : attributes) |
| 716 | { |
| 717 | auto col_ptr = (collect_values_limit ? std::make_shared<DataTypeArray>(attr.type) : attr.type)->createColumn(); |
| 718 | col_ptr->reserve(input_rows_count); |
| 719 | columns[name_] = std::move(col_ptr); |
| 720 | } |
| 721 | |
| 722 | std::optional<RefDefaultMap> default_map; |
| 723 | std::optional<RefFilter> default_mask; |
| 724 | if (is_short_circuit) |
| 725 | { |
| 726 | default_mask = std::get<RefFilter>(default_or_filter).get(); |
| 727 | default_mask.value().get().resize(keys_offsets.size()); |
| 728 | } |
| 729 | else |
| 730 | { |
| 731 | default_map = std::get<RefDefaultMap>(default_or_filter).get(); |
| 732 | } |
| 733 | |
| 734 | UInt64 curr_offset = 0; |
| 735 | for (size_t key_idx = 0; key_idx < input_rows_count; ++key_idx) |
| 736 | { |
| 737 | auto next_offset = keys_offsets[key_idx]; |
| 738 | UInt64 length = next_offset - curr_offset; |
| 739 | |
| 740 | const char * begin = reinterpret_cast<const char *>(keys_data.data()) + curr_offset; |
| 741 | |
| 742 | MatchContext match_result(regexp_ids, topology_order, begin, length, regex_nodes); |
no test coverage detected