| 538 | } |
| 539 | |
| 540 | static void apply( |
| 541 | const ColumnString::Chars & data, |
| 542 | const ColumnString::Offsets & offsets, |
| 543 | size_t shingle_size, |
| 544 | size_t heap_size, |
| 545 | PaddedPODArray<UInt64> * res1, |
| 546 | PaddedPODArray<UInt64> * res2, |
| 547 | ColumnTuple * res1_strings, |
| 548 | ColumnTuple * res2_strings, |
| 549 | size_t input_rows_count) |
| 550 | { |
| 551 | MinHeap min_heap; |
| 552 | MaxHeap max_heap; |
| 553 | |
| 554 | for (size_t i = 0; i < input_rows_count; ++i) |
| 555 | { |
| 556 | const UInt8 * one_data = &data[offsets[i - 1]]; |
| 557 | const size_t data_size = offsets[i] - offsets[i - 1]; |
| 558 | |
| 559 | min_heap.values.clear(); |
| 560 | max_heap.values.clear(); |
| 561 | |
| 562 | if constexpr (Ngram) |
| 563 | { |
| 564 | if constexpr (!UTF8) |
| 565 | ngramHashASCII(min_heap, max_heap, one_data, data_size, shingle_size, heap_size); |
| 566 | else |
| 567 | ngramHashUTF8(min_heap, max_heap, one_data, data_size, shingle_size, heap_size); |
| 568 | } |
| 569 | else |
| 570 | { |
| 571 | wordShingleHash(min_heap, max_heap, one_data, data_size, shingle_size, heap_size); |
| 572 | } |
| 573 | |
| 574 | if (res1) |
| 575 | (*res1)[i] = min_heap.getHash(); |
| 576 | if (res2) |
| 577 | (*res2)[i] = max_heap.getHash(); |
| 578 | |
| 579 | if (res1_strings) |
| 580 | min_heap.fill(*res1_strings); |
| 581 | if (res2_strings) |
| 582 | max_heap.fill(*res2_strings); |
| 583 | } |
| 584 | } |
| 585 | }; |
| 586 | |
| 587 | struct NameNgramSimHash |