MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / computeHash

Method computeHash

src/jrd/recsrc/HashJoin.cpp:663–740  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

661}
662
663ULONG 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));

Callers

nothing calls this directly

Calls 10

EVL_exprFunction · 0.85
INTL_string_to_keyFunction · 0.85
MOV_moveFunction · 0.85
isTextMethod · 0.80
makeTextMethod · 0.80
getTextTypeMethod · 0.80
isDecFloatMethod · 0.80
makeKeyMethod · 0.80
hashFunction · 0.50
getCountMethod · 0.45

Tested by

no test coverage detected