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

Function compress

src/jrd/btr.cpp:2773–3325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2771
2772
2773static void compress(thread_db* tdbb,
2774 const dsc* desc,
2775 const SSHORT matchScale,
2776 temporary_key* key,
2777 USHORT itype,
2778 bool descending, USHORT key_type,
2779 bool* forceInclude)
2780{
2781/**************************************
2782 *
2783 * c o m p r e s s
2784 *
2785 **************************************
2786 *
2787 * Functional description
2788 * Compress a data value into an index key.
2789 *
2790 **************************************/
2791 if (!desc) // this indicates NULL
2792 {
2793 const UCHAR pad = 0;
2794 key->key_flags &= ~key_empty;
2795 // AB: NULL should be threated as lowest value possible.
2796 // Therefore don't complement pad when we have an ascending index.
2797 if (descending)
2798 {
2799 // DESC NULLs are stored as 1 byte
2800 key->key_data[0] = pad;
2801 key->key_length = 1;
2802 }
2803 else
2804 key->key_length = 0; // ASC NULLs are stored with no data
2805
2806 fb_assert(!key->key_next);
2807 return;
2808 }
2809
2810 // For descending index and new index structure we insert 0xFE at the beginning.
2811 // This is only done for values which begin with 0xFE (254) or 0xFF (255) and
2812 // is needed to make a difference between a NULL state and a VALUE.
2813 // Note! By descending index key is complemented after this compression routine.
2814 // Further a NULL state is always returned as 1 byte 0xFF (descending index).
2815 const UCHAR desc_end_value_prefix = 0x01; // ~0xFE
2816 const UCHAR desc_end_value_check = 0x00; // ~0xFF;
2817
2818 const Database* dbb = tdbb->getDatabase();
2819 bool first_key = true;
2820 VaryStr<MAX_KEY * 4> buffer;
2821 size_t multiKeyLength;
2822 UCHAR* ptr;
2823 UCHAR* p = key->key_data;
2824 SSHORT scale = matchScale ? matchScale : desc->dsc_scale;
2825
2826 if (itype == idx_string || itype == idx_byte_array || itype == idx_metadata ||
2827 itype == idx_decimal || itype == idx_bcd || itype >= idx_first_intl_string)
2828 {
2829 temporary_key* root_key = key;
2830 bool has_next;

Callers 3

composeMethod · 0.85
BTR_make_keyFunction · 0.85
BTR_make_null_keyFunction · 0.85

Calls 15

MOV_get_int128Function · 0.85
containsErrorCodeFunction · 0.85
MOV_get_dec128Function · 0.85
INTL_string_to_keyFunction · 0.85
MOV_get_stringFunction · 0.85
MOV_get_doubleFunction · 0.85
MOV_get_int64Function · 0.85
make_int64_keyFunction · 0.85
print_int64_keyFunction · 0.85
MOV_get_timestampFunction · 0.85
MOV_get_timestamp_tzFunction · 0.85
MOV_get_sql_dateFunction · 0.85

Tested by

no test coverage detected