| 661 | } |
| 662 | |
| 663 | ULONG HashJoin::computeHash(thread_db* tdbb, |
| 664 | Request* request, |
| 665 | const SubStream& sub, |
| 666 | UCHAR* keyBuffer) const |
| 667 | { |
| 668 | memset(keyBuffer, 0, sub.totalKeyLength); |
| 669 | |
| 670 | UCHAR* keyPtr = keyBuffer; |
| 671 | |
| 672 | for (FB_SIZE_T i = 0; i < sub.keys->getCount(); i++) |
| 673 | { |
| 674 | dsc* const desc = EVL_expr(tdbb, request, (*sub.keys)[i]); |
| 675 | const USHORT keyLength = sub.keyLengths[i]; |
| 676 | |
| 677 | if (desc && !(request->req_flags & req_null)) |
| 678 | { |
| 679 | if (desc->isText()) |
| 680 | { |
| 681 | dsc to; |
| 682 | to.makeText(keyLength, desc->getTextType(), keyPtr); |
| 683 | |
| 684 | if (IS_INTL_DATA(desc)) |
| 685 | { |
| 686 | // Convert the INTL string into the binary comparable form |
| 687 | INTL_string_to_key(tdbb, INTL_INDEX_TYPE(desc), |
| 688 | desc, &to, INTL_KEY_UNIQUE); |
| 689 | } |
| 690 | else |
| 691 | { |
| 692 | // This call ensures that the padding bytes are appended |
| 693 | MOV_move(tdbb, desc, &to); |
| 694 | } |
| 695 | } |
| 696 | else |
| 697 | { |
| 698 | const auto data = desc->dsc_address; |
| 699 | |
| 700 | if (desc->isDecFloat()) |
| 701 | { |
| 702 | // Values inside our key buffer are not aligned, |
| 703 | // so ensure we satisfy our platform's alignment rules |
| 704 | OutAligner<ULONG, MAX_DEC_KEY_LONGS> key(keyPtr, keyLength); |
| 705 | |
| 706 | if (desc->dsc_dtype == dtype_dec64) |
| 707 | ((Decimal64*) data)->makeKey(key); |
| 708 | else if (desc->dsc_dtype == dtype_dec128) |
| 709 | ((Decimal128*) data)->makeKey(key); |
| 710 | else |
| 711 | fb_assert(false); |
| 712 | } |
| 713 | else if (desc->dsc_dtype == dtype_real && *(float*) data == 0) |
| 714 | { |
| 715 | fb_assert(keyLength == sizeof(float)); |
| 716 | memset(keyPtr, 0, keyLength); // positive zero in binary |
| 717 | } |
| 718 | else if (desc->dsc_dtype == dtype_double && *(double*) data == 0) |
| 719 | { |
| 720 | fb_assert(keyLength == sizeof(double)); |
nothing calls this directly
no test coverage detected