30 #if defined(sun) || defined(HPUX) 31 #include <sys/types.h> 32 #include <netinet/in.h> 57 #define EHASH_BALANCE_FACTOR 4 67 #define EHASH_OVERFLOW_RATE 0.9 79 #define EHASH_UNDERFLOW_RATE 0.4 88 #define EHASH_OVERFLOW_THRESHOLD (EHASH_OVERFLOW_RATE * DB_PAGESIZE) 89 #define EHASH_UNDERFLOW_THRESHOLD (EHASH_UNDERFLOW_RATE * DB_PAGESIZE) 92 #define EHASH_HASH_KEY_BITS (sizeof(EHASH_HASH_KEY) * 8) 95 #define EHASH_SHORT_BITS (sizeof(short) * 8) 151 #define EHASH_LONG_STRING_PREFIX_SIZE 10 154 #define EHASH_DIR_HEADER_SIZE \ 155 ((ssize_t) (((sizeof(EHASH_DIR_HEADER) + sizeof(int) - 1 ) / sizeof(int) ) * sizeof(int))) 158 #define EHASH_MAX_STRING_SIZE \ 159 (DB_PAGESIZE - (SSIZEOF(EHASH_BUCKET_HEADER) + 16)) 162 #define EHASH_NUM_FIRST_PAGES \ 163 ((DB_PAGESIZE - EHASH_DIR_HEADER_SIZE) / SSIZEOF (EHASH_DIR_RECORD)) 166 #define EHASH_LAST_OFFSET_IN_FIRST_PAGE \ 167 (EHASH_DIR_HEADER_SIZE + (EHASH_NUM_FIRST_PAGES - 1) * sizeof(EHASH_DIR_RECORD)) 170 #define EHASH_NUM_NON_FIRST_PAGES \ 171 (DB_PAGESIZE / sizeof(EHASH_DIR_RECORD)) 174 #define EHASH_LAST_OFFSET_IN_NON_FIRST_PAGE \ 175 ((EHASH_NUM_NON_FIRST_PAGES - 1) * sizeof(EHASH_DIR_RECORD)) 191 #define GETBITS(value, pos, n) \ 192 ( ((value) >> ( EHASH_HASH_KEY_BITS - (pos) - (n) + 1)) & (~(~0UL << (n))) ) 207 #define FIND_OFFSET(hash_key, depth) (GETBITS((hash_key), 1, (depth))) 221 #define GETBIT(word, pos) (GETBITS((word), (pos), 1)) 234 #define SETBIT(word, pos) ( (word) | (1 << (EHASH_HASH_KEY_BITS - (pos))) ) 247 #define CLEARBIT(word, pos) ( (word) & ~(1 << (EHASH_HASH_KEY_BITS - (pos))) ) 249 #if defined (ENABLE_UNUSED_FUNCTION) 250 static int ehash_ansi_sql_strncmp (
const char *s,
const char *t,
int max);
254 #if defined (ENABLE_UNUSED_FUNCTION) 255 static int ehash_compare_overflow (
THREAD_ENTRY * thread_p,
const VPID * ovf_vpid,
char *key,
int *comp_result);
262 OID * class_oid,
int attr_id,
bool istmp);
268 VPID * existing_ovf_vpid);
271 VPID * existing_ovf_vpid);
276 void *key,
int *old_local_depth,
int *new_local_depth,
VPID * sib_vpid,
280 VPID * buc_vpid,
bool is_temp);
290 #if defined (ENABLE_UNUSED_FUNCTION) 302 OID * assoc_value,
int *out_apply_error,
int (*apply_function) (
THREAD_ENTRY * thread_p,
303 void *key,
void *data,
304 void *args),
void *args);
307 VPID * buc_vpid,
VPID * sib_vpid,
int num_recs,
int loc,
PGSLOTID first_slotid,
308 int *out_new_local_depth,
bool is_temp);
312 VPID * buc_vpid,
PAGE_PTR buc_pgptr,
int location,
int lock_type,
313 int *old_local_depth,
VPID * sib_vpid,
PAGE_PTR * out_sib_pgptr,
314 PGSLOTID * out_first_slotid,
int *out_num_recs,
int *out_loc);
320 PGSLOTID first_slotid,
int *old_local_depth,
int *new_local_depth);
326 int *out_compare_result);
332 bool is_temp,
OID * value_ptr,
VPID * existing_ovf_vpid);
339 OID * value_ptr,
VPID * existing_ovf_vpid);
343 #if defined (ENABLE_UNUSED_FUNCTION) 349 #if defined(EHINSERTION_ORDER) 350 static void eh_dump_key (
DB_TYPE key_type,
void *key,
OID * value_ptr);
386 offset = *out_offset_p;
402 *out_page_no_p = page_no;
403 *out_offset_p = offset;
406 #if defined (ENABLE_UNUSED_FUNCTION) 419 ehash_ansi_sql_strncmp (
const char *s,
const char *t,
int max)
423 for (i = 0; (*s == *t) && (i < max); s++, t++, i++)
460 return (*(
unsigned const char *) s < *(
unsigned const char *) t) ? -1 : +1;
476 recdes_p->
type = type;
488 return recdes_p->
data;
507 #if defined (ENABLE_UNUSED_FUNCTION) 524 ehash_compare_overflow (
THREAD_ENTRY * thread_p,
const VPID * ovf_vpid_p,
char *key_p,
int *out_comp_result)
582 ovf_vpid_p = (
VPID *) (recdes_p->
data + sizeof (
OID));
600 bucket_p = recdes_p->
data +
sizeof (
OID) +
sizeof (
VPID);
613 return ovf_recdes.
data;
639 alignment = *(
char *) args;
642 depth = *((
char *) args + offset);
643 offset +=
sizeof (
depth);
645 is_temp = *(
bool *) ((
char *) args + offset);
665 bucket_recdes.
data = (
char *) &bucket_header;
673 success =
spage_insert (thread_p, page_p, &bucket_recdes, &slot_id);
712 bool is_temp = *(
bool *) args;
740 #if defined(EHINSERTION_ORDER) 749 eh_dump_key (
DB_TYPE key_type,
void *key,
OID * value_ptr)
751 int hour, minute, second, month, day, year;
757 fprintf (stdout,
"key:%s", (
char *) key);
761 fprintf (stdout,
"key:%d|%d|%d", ((
OID *) key)->volid, ((
OID *) key)->pageid, ((
OID *) key)->slotid);
765 fprintf (stdout,
"key:%f", *(
double *) key);
769 fprintf (stdout,
"key:%f", *(
float *) key);
773 fprintf (stdout,
"key:%d", *(
int *) key);
777 fprintf (stdout,
"key:%lld", (
long long) (*(
DB_BIGINT *) key));
781 fprintf (stdout,
"key:%d", *(
short *) key);
786 fprintf (stdout,
"key:%2d/%2d/%4d", month, day, year);
791 fprintf (stdout,
"key:%3d:%3d:%3d", hour, minute, second);
796 fprintf (stdout,
"key:%d", *(
DB_UTIME *) key);
815 fprintf (stdout,
"key:%f type %d", d, ((
DB_MONETARY *) key)->type);
824 fprintf (stdout,
" OID associated value:%5d,%5d,%5d\n", value_ptr->
volid, value_ptr->
pageid, value_ptr->
slotid);
865 int attr_id,
bool is_tmp)
867 return ehash_create_helper (thread_p, ehid_p, key_type, exp_num_entries, class_oid_p, attr_id, is_tmp);
888 key_size =
sizeof (
OID);
891 #if defined (ENABLE_UNUSED_FUNCTION) 893 key_size =
sizeof (double);
897 key_size =
sizeof (float);
901 key_size =
sizeof (int);
909 key_size =
sizeof (short);
953 int attr_id,
bool is_tmp)
962 char init_bucket_data[3];
980 if (class_oid_p !=
NULL)
998 if (exp_num_entries < 0)
1001 exp_bucket_pages = 1;
1007 exp_bucket_pages = exp_num_entries * (20 +
sizeof (
OID) + 4);
1011 exp_bucket_pages = exp_num_entries * (key_size +
sizeof (
OID) + 4);
1018 if (SSIZEOF (value.
pageid) >= key_size)
1020 alignment =
sizeof (value.
pageid);
1024 alignment = (char) key_size;
1029 if (alignment > SSIZEOF (
int))
1031 alignment =
sizeof (int);
1047 init_bucket_data[1] = 0;
1048 init_bucket_data[2] = is_tmp;
1058 if (exp_num_entries < 0)
1092 if (dir_page_p ==
NULL)
1102 dir_header_p->
depth = 0;
1264 if (dir_page_p ==
NULL)
1298 if (dir_offset != 0)
1302 if (dir_page_p ==
NULL)
1323 int *out_location_p)
1331 if (dir_root_page_p ==
NULL)
1342 *out_hash_key_p = hash_key;
1349 *out_location_p = location;
1358 return dir_root_page_p;
1383 if (ehid_p ==
NULL || key_p ==
NULL)
1391 if (dir_root_page_p ==
NULL)
1405 if (bucket_page_p ==
NULL)
1427 if (dir_root_page_p)
1457 if (ehid_p ==
NULL || key_p ==
NULL)
1469 VPID * existing_ovf_vpid_p)
1474 char init_bucket_data[3];
1480 found_depth =
ehash_find_depth (thread_p, ehid_p, location, &null_vpid, &null_vpid);
1481 if (found_depth == 0)
1486 init_bucket_data[0] = dir_header_p->
alignment;
1487 init_bucket_data[1] = dir_header_p->
depth - found_depth;
1488 init_bucket_data[2] = is_temp;
1494 bucket_vpid_p, &bucket_page_p);
1501 if (bucket_page_p ==
NULL)
1523 dir_header_p->
key_type, key_p, value_p, existing_ovf_vpid_p);
1540 VPID * bucket_vpid,
bool is_temp)
1545 int old_local_depth;
1546 int new_local_depth;
1554 ehash_split_bucket (thread_p, dir_header_p, bucket_page_p, key_p, &old_local_depth, &new_local_depth,
1555 &sibling_vpid, is_temp);
1556 if (sibling_page_p ==
NULL)
1567 *out_new_bit_p =
GETBIT (hash_key, new_local_depth);
1573 if (new_local_depth > dir_header_p->
depth)
1587 if ((new_local_depth - old_local_depth) > 1)
1601 hash_key =
CLEARBIT (hash_key, new_local_depth);
1614 hash_key =
SETBIT (hash_key, new_local_depth);
1629 return sibling_page_p;
1636 VPID * existing_ovf_vpid_p)
1646 if (bucket_page_p ==
NULL)
1653 dir_header_p->
key_type, key_p, value_p, existing_ovf_vpid_p);
1663 ehash_extend_bucket (thread_p, ehid_p, dir_root_page_p, dir_header_p, bucket_page_p, key_p, hash_key, &new_bit,
1664 bucket_vpid_p, is_temp);
1665 if (sibling_page_p ==
NULL)
1679 target_bucket_page_p = sibling_page_p;
1683 target_bucket_page_p = bucket_page_p;
1688 dir_header_p->
key_type, key_p, value_p, existing_ovf_vpid_p);
1708 VPID * existing_ovf_vpid_p)
1717 bool is_temp =
false;
1728 &bucket_vpid, &hash_key, &location);
1729 if (dir_root_page_p ==
NULL)
1736 #if defined(EHINSERTION_ORDER) 1738 eh_dump_key (dir_header_p->
key_type, key_p, value_p);
1746 #if defined (ENABLE_UNUSED_FUNCTION) 1757 if (ehash_create_overflow_file (thread_p, ehid_p, dir_root_page_p, dir_header_p, file_type) !=
NO_ERROR)
1778 (thread_p, ehid_p, dir_root_page_p, dir_header_p, &bucket_vpid, location, hash_key, is_temp, key_p,
1779 value_p, existing_ovf_vpid_p) !=
NO_ERROR)
1790 hash_key, lock_type, is_temp, value_p, existing_ovf_vpid_p);
1831 VPID * existing_ovf_vpid_p)
1833 char *bucket_record_p;
1835 RECDES old_bucket_recdes;
1837 #if defined (ENABLE_UNUSED_FUNCTION) 1846 bool is_replaced_oid =
false;
1849 if (
ehash_locate_slot (thread_p, bucket_page_p, key_type, key_p, &slot_no) ==
true)
1856 bucket_record_p = (
char *) old_bucket_recdes.
data;
1862 is_replaced_oid =
true;
1869 memcpy (bucket_recdes.
data, bucket_record_p, bucket_recdes.
length);
1884 #if defined (ENABLE_UNUSED_FUNCTION) 1903 record_p = bucket_recdes.
data;
1904 record_p +=
sizeof (
OID);
1906 if (existing_ovf_vpid_p !=
NULL)
1912 *(
VPID *) record_p = *existing_ovf_vpid_p;
1925 *(
VPID *) record_p = ovf_vpid;
1931 success =
spage_insert_at (thread_p, bucket_page_p, slot_no, &bucket_recdes);
1937 #if defined (ENABLE_UNUSED_FUNCTION) 1968 log_record_p = log_recdes.
data;
1974 memcpy (log_record_p, bucket_recdes.
data, bucket_recdes.
length);
1978 if (is_replaced_oid)
1997 if (is_replaced_oid)
2007 (
int) (old_bucket_recdes.
data - bucket_page_p), sizeof (
OID), old_bucket_recdes.
data);
2027 log_record_p = log_recdes.
data;
2031 *(
short *) log_record_p = bucket_recdes.
type;
2032 log_record_p += sizeof (
short);
2035 memcpy (log_record_p, bucket_recdes.
data, bucket_recdes.
length);
2044 if (bucket_recdes.
data)
2049 if (log_recdes.
data)
2066 record_p = recdes_p->
data;
2074 #if defined (ENABLE_UNUSED_FUNCTION) 2079 record_p +=
sizeof (
VPID);
2082 memcpy (record_p, (
char *) key_p, key_size);
2083 record_p += key_size;
2087 *(
OID *) record_p = *(
OID *) key_p;
2089 #if defined (ENABLE_UNUSED_FUNCTION) 2095 *(
float *) record_p = *(
float *) key_p;
2099 *(
int *) record_p = *(
int *) key_p;
2107 *(
short *) record_p = *(
short *) key_p;
2168 bool is_long_str =
false;
2172 key_size = (short)
strlen ((
char *) key_p) + 1;
2175 assert (key_size <= 256);
2177 #if defined (ENABLE_UNUSED_FUNCTION) 2186 record_size =
sizeof (
OID) + key_size;
2188 #if defined (ENABLE_UNUSED_FUNCTION) 2192 record_size +=
sizeof (
VPID);
2203 record_size =
sizeof (
OID) + key_size;
2216 int *out_compare_result_p)
2219 #if defined (ENABLE_UNUSED_FUNCTION) 2230 #if defined (ENABLE_UNUSED_FUNCTION) 2234 ovf_vpid_p = (
VPID *) bucket_record_p;
2235 bucket_record_p +=
sizeof (
VPID);
2238 if (!compare_result)
2256 compare_result =
ansisql_strcmp ((
char *) key_p, bucket_record_p);
2263 #if defined (ENABLE_UNUSED_FUNCTION) 2278 compare_result = -1;
2283 f1 = *((
float *) key_p);
2284 f2 = *((
float *) bucket_record_p);
2296 compare_result = -1;
2301 compare_result = *(
int *) key_p - *(
int *) bucket_record_p;
2318 compare_result = -1;
2323 compare_result = *(
short *) key_p - *(
short *) bucket_record_p;
2327 compare_result = *(
DB_DATE *) key_p - *(
DB_DATE *) bucket_record_p;
2331 compare_result = *(
DB_TIME *) key_p - *(
DB_TIME *) bucket_record_p;
2344 compare_result = -1;
2352 compare_result = -1;
2378 compare_result = -1;
2388 *out_compare_result_p = compare_result;
2394 void *key_p,
PGSLOTID * out_position_p)
2396 char *bucket_record_p;
2407 middle = (high + low) >> 1;
2415 bucket_record_p = (
char *) recdes.
data;
2416 bucket_record_p += sizeof (
OID);
2423 if (compare_result == 0)
2425 *out_position_p = middle;
2429 if (compare_result < 0)
2438 while (high >= low);
2442 *out_position_p = middle;
2447 *out_position_p = middle + 1;
2489 *out_position_p = 1;
2493 *out_position_p = first_slot_id + 1;
2504 char *bucket_record_p;
2505 #if defined (ENABLE_UNUSED_FUNCTION) 2509 #if defined (ENABLE_UNUSED_FUNCTION) 2516 whole_key_p = ehash_compose_overflow (thread_p, recdes_p);
2517 if (whole_key_p ==
NULL)
2521 hash_key =
ehash_hash (whole_key_p, key_type);
2527 bucket_record_p = (
char *) recdes_p->
data;
2528 bucket_record_p += sizeof (
OID);
2529 hash_key =
ehash_hash (bucket_record_p, key_type);
2532 *out_hash_key_p = hash_key;
2539 int *out_old_local_depth_p,
int *out_new_local_depth_p)
2543 unsigned int difference = 0, check_bit = 0;
2553 for (slot_id = first_slot_id + 1; slot_id < num_recs; slot_id++)
2566 difference = (first_hash_key ^ next_hash_key) | difference;
2567 if (difference & check_bit)
2574 bit_position = *out_old_local_depth_p + 1;
2579 if (difference & check_bit)
2591 *out_new_local_depth_p = bit_position;
2606 for (slot_id = i = first_slot_id + 1; i < num_recs; i++)
2620 success =
spage_insert (thread_p, sibling_page_p, &recdes, &sibling_slot_id);
2625 "Unable to move the record from the bucket to empty sibling bucket. Slotted page module" 2626 " refuses to insert a short size record to an empty page. This should never happen.");
2632 (void)
spage_delete (thread_p, bucket_page_p, slot_id);
2677 int *out_old_local_depth_p,
int *out_new_local_depth_p,
VPID * sibling_vpid_p,
bool is_temp)
2685 char init_bucket_data[3];
2705 *out_old_local_depth_p = bucket_header_p->
local_depth;
2708 first_slot_id, out_old_local_depth_p, out_new_local_depth_p) !=
NO_ERROR)
2714 init_bucket_data[0] = dir_header_p->
alignment;
2715 init_bucket_data[1] = *out_new_local_depth_p;
2716 init_bucket_data[2] = is_temp;
2725 if (sibling_page_p ==
NULL)
2732 first_slot_id, sibling_page_p) !=
NO_ERROR)
2759 return sibling_page_p;
2802 int old_dir_nth_page;
2806 int new_dir_nth_page;
2811 if (dir_header_page_p ==
NULL)
2825 old_ptrs = 1 << dir_header_p->
depth;
2826 exp_times = 1 << (new_depth - dir_header_p->
depth);
2828 new_ptrs = old_ptrs * exp_times;
2829 end_offset = old_ptrs - 1;
2833 if (check_pages != old_pages)
2843 new_end_offset = new_ptrs - 1;
2845 needed_pages = new_pages - old_pages;
2846 if (needed_pages > 0)
2863 old_dir_nth_page = old_pages;
2866 if (old_dir_page_p ==
NULL)
2871 old_dir_offset = end_offset;
2874 new_dir_nth_page = new_pages;
2877 if (new_dir_page_p ==
NULL)
2883 new_dir_offset = new_end_offset;
2885 if (new_dir_nth_page <= old_pages && !is_temp)
2895 for (j = old_ptrs; j > 0; j--)
2897 if (old_dir_offset < 0)
2909 if (old_dir_page_p ==
NULL)
2921 if (old_dir_nth_page)
2934 for (i = 1; i <= exp_times; i++)
2936 if (new_dir_offset < 0)
2953 if (new_dir_page_p ==
NULL)
2960 if (new_dir_nth_page <= old_pages && !is_temp)
2968 if (new_dir_nth_page != 0)
2980 if ((
char *) new_dir_page_p + new_dir_offset != (
char *) old_dir_page_p + old_dir_offset)
2982 memcpy ((
char *) new_dir_page_p + new_dir_offset, (
char *) old_dir_page_p + old_dir_offset,
2997 dir_header_p->
depth = new_depth;
3016 if (new_ptrs / npages > EHASH_BALANCE_FACTOR || npages_ehash > npages_bucket)
3019 "WARNING: Ext. Hash EHID=%d|%d|%d is unbalanced.\n Num_bucket_pages = %d, " 3020 "num_dir_pages = %d,\n num_dir_pointers = %d, directory_depth = %d.\n" 3021 " You may want to consider another hash function.\n", ehid_p->
vfid.
volid,
3023 new_ptrs, dir_header_p->
depth);
3060 VPID * bucket_vpid_p,
bool is_temp)
3067 int first_page, last_page;
3068 int first_ptr_offset, last_ptr_offset;
3069 int start_offset, end_offset;
3073 unsigned int set_bits;
3074 unsigned int clear_bits;
3076 repetition.
vpid = *bucket_vpid_p;
3090 diff = dir_header.
depth - local_depth;
3094 for (set_bits = 0, i = 0; i <
diff; i++)
3096 set_bits = 2 * set_bits + 1;
3098 clear_bits = ~set_bits;
3100 first_ptr_offset = location & clear_bits;
3101 last_ptr_offset = location | set_bits;
3109 first_ptr_offset = location;
3111 last_page = first_page;
3112 last_ptr_offset = first_ptr_offset;
3116 for (i = first_page; i <= last_page; i++)
3124 if (i == first_page)
3126 start_offset = first_ptr_offset;
3143 bef_length = end_offset - start_offset;
3154 for (j = 0; j < repetition.
count; j++)
3187 char check_depth = 2;
3188 bool is_stop =
false;
3199 while ((check_depth <= dir_header.
depth) && !is_stop)
3208 for (i = 1; i < check_depth - 1; i++)
3215 loc = location &
clear;
3229 iterations = 1 << (check_depth - 2);
3231 for (i = 0; i < iterations; i++)
3233 rel_loc = loc | (i << 1);
3235 if (page_no != prev_page_no)
3243 prev_page_no = page_no;
3262 return (check_depth - 1);
3267 VPID * bucket_vpid_p,
PAGE_PTR bucket_page_p,
int location,
int lock_type,
3268 int *out_old_local_depth_p,
VPID * sibling_vpid_p,
PAGE_PTR * out_sibling_page_p,
3269 PGSLOTID * out_first_slot_id_p,
int *out_num_records_p,
int *out_location_p)
3292 *out_old_local_depth_p = bucket_header_p->
local_depth;
3324 if (
VPID_EQ (sibling_vpid_p, bucket_vpid_p))
3334 if (sibling_page_p ==
NULL)
3341 recdes.
data = (
char *) &sibling_bucket_header;
3363 if (num_records > 1)
3384 *out_sibling_page_p = sibling_page_p;
3385 *out_first_slot_id_p = first_slot_id;
3386 *out_num_records_p = num_records;
3387 *out_location_p = loc;
3422 char *log_undo_record_p;
3423 char *log_redo_record_p;
3426 int old_local_depth;
3431 bool is_long_str =
false;
3432 bool is_temp =
false;
3436 if (ehid_p ==
NULL || key_p ==
NULL)
3450 if (dir_root_page_p ==
NULL)
3466 if (bucket_page_p ==
NULL)
3496 log_undo_record_p = log_recdes_undo.
data;
3502 memcpy (log_undo_record_p, bucket_recdes.
data, bucket_recdes.
length);
3512 log_redo_record_p = log_recdes_redo.
data;
3515 *(
short *) log_redo_record_p = bucket_recdes.
type;
3516 log_redo_record_p += sizeof (
short);
3519 memcpy (log_redo_record_p, bucket_recdes.
data, bucket_recdes.
length);
3521 #if defined (ENABLE_UNUSED_FUNCTION) 3525 ovf_vpid = *(
VPID *) (bucket_recdes.
data + sizeof (
OID));
3534 (void)
spage_delete (thread_p, bucket_page_p, slot_no);
3565 log_recdes_undo.
length, log_recdes_undo.
data);
3568 log_recdes_redo.
length, log_recdes_redo.
data);
3584 (thread_p, ehid_p, dir_header_p, &bucket_vpid, bucket_page_p, location,
S_LOCK, &old_local_depth,
3612 i = dir_header_p->
depth;
3618 if ((dir_header_p->
depth - i) > 1)
3628 int redo_inc, undo_inc, offset;
3642 sizeof (
int), &undo_inc, &redo_inc);
3649 VPID * bucket_vpid_p,
VPID * sibling_vpid_p,
int num_records,
int location,
3650 PGSLOTID first_slot_id,
int *out_new_local_depth_p,
bool is_temp)
3654 char *bucket_record_p;
3656 bool is_record_exist;
3667 for (slot_id = 1; slot_id < num_records; slot_id++)
3670 bucket_record_p = (
char *) recdes.
data;
3671 bucket_record_p += sizeof (
OID);
3673 #if defined (ENABLE_UNUSED_FUNCTION) 3676 bucket_record_p = ehash_compose_overflow (thread_p, &recdes);
3677 if (bucket_record_p ==
NULL)
3686 if (is_record_exist ==
false)
3688 success =
spage_insert_at (thread_p, sibling_page_p, new_slot_id, &recdes);
3692 #if defined (ENABLE_UNUSED_FUNCTION) 3704 #if defined (ENABLE_UNUSED_FUNCTION) 3713 #if defined (ENABLE_UNUSED_FUNCTION) 3721 found_depth =
ehash_find_depth (thread_p, ehid_p, location, bucket_vpid_p, sibling_vpid_p);
3722 if (found_depth == 0)
3729 *out_new_local_depth_p = sibling_bucket_header.
local_depth;
3732 recdes.
data = (
char *) &sibling_bucket_header;
3735 (void)
spage_update (thread_p, sibling_page_p, first_slot_id, &recdes);
3772 int old_local_depth, new_local_depth;
3779 int num_records, sibling_location;
3783 &hash_key, &location);
3784 if (dir_root_page_p ==
NULL)
3790 if (bucket_vpid.
pageid != NULL_PAGEID)
3793 if (bucket_page_p ==
NULL)
3824 &old_local_depth, &sibling_vpid, &sibling_page_p, &first_slot_id, &num_records,
3827 switch (check_result)
3886 if (
ehash_merge_permanent (thread_p, ehid_p, dir_root_page_p, dir_header_p, bucket_page_p, sibling_page_p,
3887 &bucket_vpid, &sibling_vpid, num_records, sibling_location, first_slot_id,
3888 &new_local_depth, is_temp) !=
NO_ERROR)
3990 int old_dir_nth_page;
3995 int new_dir_nth_page;
3999 if (dir_header_p ==
NULL)
4004 if (dir_header_p->
depth < new_depth)
4008 dir_header_p->
depth);
4014 old_ptrs = 1 << dir_header_p->
depth;
4015 times = 1 << (dir_header_p->
depth - new_depth);
4028 new_ptrs = old_ptrs / times;
4030 end_offset = old_ptrs - 1;
4033 if (check_pages != old_pages)
4045 if (old_dir_page_p ==
NULL)
4050 new_dir_nth_page = 0;
4051 new_dir_page_p = (
PAGE_PTR) dir_header_p;
4059 dir_header_p->
depth = new_depth;
4062 for (i = 1; i < new_ptrs; i++)
4067 old_dir_offset = i * times;
4070 if (old_dir_nth_page != prev_pg_no)
4074 prev_pg_no = old_dir_nth_page;
4079 if (old_dir_page_p ==
NULL)
4107 if (new_dir_page_p ==
NULL)
4123 memcpy ((
char *) new_dir_page_p + new_dir_offset, (
char *) old_dir_page_p + old_dir_offset,
4138 new_end_offset = new_ptrs - 1;
4151 char copy_psekey[12];
4160 char *new_key_p =
NULL;
4162 length = (int)
strlen (key_p);
4169 for (p = key_p + length - 1;
char_isspace (*p) && (p > key_p); p--)
4173 length = (int) (p - key_p + 1);
4174 key_p = new_key_p = (
char *) malloc (length + 1);
4179 memcpy (key_p, original_key_p, length);
4180 *(
char *) (key_p + length) =
'\0';
4187 for (i = 1; i <= times; i++)
4189 memcpy (&Int, key_p,
sizeof (
int));
4198 for (i = 1; i <= remaining; i++)
4201 Int = (int) *key_p++ << i;
4217 hash_key = hash_key + (byte << (8 * (
sizeof (
EHASH_HASH_KEY) - 1)));
4219 hash_key = hash_key + (byte << (8 * (
sizeof (
EHASH_HASH_KEY) - 2)));
4221 hash_key = hash_key + (byte << (8 * (
sizeof (
EHASH_HASH_KEY) - 3)));
4225 key_p = (
char *) ©_psekey;
4228 Char += (char) *key_p++;
4232 return hash_key + Char;
4243 for (i = 0; i <
sizeof (double) /
sizeof (
int); i++)
4245 memcpy (&Int, key_p,
sizeof (
int));
4246 hash_key +=
htonl (Int);
4247 key_p +=
sizeof (int);
4252 key_p = (
char *) &hash_key;
4255 Char ^= (char) *key_p++;
4259 memcpy (&hash_key, &Char,
sizeof (
char));
4264 #if defined (ENABLE_UNUSED_FUNCTION) 4266 ehash_hash_four_bytes_type (
char *key_p)
4270 unsigned short Short, *Short2;
4273 Short =
ntohs (*(
unsigned short *) key_p);
4274 Short2 = (
unsigned short *) key_p;
4277 Short +=
ntohs (*Short2);
4283 key_p = (
char *) &hash_key;
4286 Char += (char) *key_p++;
4290 memcpy (&hash_key, &Char,
sizeof (
char));
4296 ehash_hash_two_bytes_type (
char *key_p)
4300 unsigned short Short;
4303 Short =
ntohs (*(
unsigned short *) key_p);
4309 key_p = (
char *) &hash_key;
4312 Char += (char) *key_p++;
4316 memcpy (&hash_key, &Char,
sizeof (
char));
4341 char *key = (
char *) original_key_p;
4354 #if defined (ENABLE_UNUSED_FUNCTION) 4360 key = (
char *) &(((
DB_MONETARY *) original_key_p)->amount);
4372 hash_key = ehash_hash_four_bytes_type (key);
4376 hash_key = ehash_hash_two_bytes_type (key);
4403 eh_size (
EHID * ehid,
int *num_bucket_pages,
int *num_dir_pages)
4415 if (dir_pgptr ==
NULL)
4417 *num_bucket_pages = -1;
4418 *num_dir_pages = -1;
4424 *num_bucket_pages = file_get_numpages (&dir_header->
bucket_file);
4425 *num_dir_pages = file_get_numpages (&ehid->
vfid);
4430 *num_bucket_pages += file_get_numpages (&dir_header->
overflow_file);
4435 return (*num_bucket_pages + *num_dir_pages);
4459 eh_count (
EHID * ehid)
4480 if (dir_pgptr ==
NULL)
4486 numpages = file_get_numpages (&dir_header->
bucket_file);
4489 for (buc_pg_no = 0; buc_pg_no < numpages; buc_pg_no++)
4494 if (buc_pgptr ==
NULL)
4519 eh_depth (
EHID * ehid)
4532 if (dir_pgptr ==
NULL)
4538 depth = dir_header->
depth;
4559 eh_capacity (
THREAD_ENTRY * thread_p,
EHID * ehid,
int *num_recs,
int *avg_reclength,
int *num_bucket_pages,
4560 int *num_dir_pages,
int *dir_depth,
int *avg_freespace_per_page,
int *avg_overhead_per_page)
4570 *num_bucket_pages = 0;
4573 *avg_freespace_per_page = 0;
4575 *avg_overhead_per_page = 0;
4583 if (dir_pgptr ==
NULL)
4589 *num_dir_pages = file_get_numpages (&ehid->
vfid);
4590 *dir_depth = dir_header->
depth;
4592 *num_bucket_pages = file_get_numpages (&dir_header->
bucket_file);
4593 if (*num_bucket_pages == -1)
4598 for (buc_pg_no = 0; buc_pg_no < *num_bucket_pages; buc_pg_no++)
4601 if (buc_pgptr ==
NULL)
4610 for (slotid = 0; slotid < num_slots; slotid++)
4629 if (dir_pgptr !=
NULL)
4634 if (buc_pgptr !=
NULL)
4640 *num_bucket_pages = -1;
4641 *num_dir_pages = -1;
4643 *avg_freespace_per_page = -1;
4644 *avg_reclength = -1;
4645 *avg_overhead_per_page = -1;
4653 OID * assoc_value_p,
int *out_apply_error,
int (*apply_function) (
THREAD_ENTRY * thread_p,
void *key,
4654 void *data,
void *args),
void *args)
4656 #if defined (ENABLE_UNUSED_FUNCTION) 4659 char *str_next_key_p, *temp_p;
4663 void *key_p = &next_key;
4668 #if defined (ENABLE_UNUSED_FUNCTION) 4672 long_str = ehash_compose_overflow (thread_p, recdes_p);
4673 if (long_str ==
NULL)
4686 str_next_key_p = (
char *) malloc (key_size);
4687 if (str_next_key_p ==
NULL)
4693 temp_p = str_next_key_p;
4694 for (i = 0; i < key_size; i++)
4696 *temp_p++ = *bucket_record_p++;
4699 key_p = str_next_key_p;
4705 memcpy (&next_key, bucket_record_p,
sizeof (
OID));
4707 #if defined (ENABLE_UNUSED_FUNCTION) 4713 *((
float *) &next_key) = *(
float *) bucket_record_p;
4717 *((
int *) &next_key) = *(
int *) bucket_record_p;
4725 *((
short *) &next_key) = *(
short *) bucket_record_p;
4756 *out_apply_error = (*apply_function) (thread_p, key_p, assoc_value_p, args);
4776 int (*apply_function) (
THREAD_ENTRY * thread_p,
void *key,
void *data,
void *args),
void *args)
4779 int num_pages, bucket_page_no, num_records;
4781 char *bucket_record_p;
4793 if (dir_page_p ==
NULL)
4805 for (bucket_page_no = 0; apply_error_code ==
NO_ERROR && bucket_page_no < num_pages; bucket_page_no++)
4809 if (bucket_page_p ==
NULL)
4820 for (slot_id = first_slot_id + 1; apply_error_code ==
NO_ERROR && slot_id < num_records; slot_id++)
4823 bucket_record_p = (
char *) recdes.
data;
4827 &apply_error_code, apply_function, args) !=
NO_ERROR)
4839 return apply_error_code;
4866 PAGE_PTR dir_page_p, dir_root_page_p;
4880 if (dir_root_page_p ==
NULL)
4894 num_ptrs = 1 << dir_header_p->
depth;
4895 end_offset = num_ptrs - 1;
4899 if (check_pages != num_pages)
4909 printf (
"*********************************************************\n");
4910 printf (
"* DIRECTORY *\n");
4912 printf (
"* Depth : %d *\n", dir_header_p->
depth);
4913 printf (
"* Key type : ");
4918 printf (
" string *\n");
4922 printf (
" OID *\n");
4924 #if defined (ENABLE_UNUSED_FUNCTION) 4926 printf (
" double *\n");
4930 printf (
" float *\n");
4934 printf (
" int *\n");
4938 printf (
" BIGINT *\n");
4942 printf (
" short *\n");
4946 printf (
" date *\n");
4950 printf (
" time *\n");
4954 printf (
" utime *\n");
4958 printf (
" datetime *\n");
4962 printf (
" monetary *\n");
4975 printf (
"* LOCAL DEPTH COUNTERS *\n");
4981 fprintf (stdout,
" buckets with local depth %d *\n", i);
4986 printf (
"* POINTERS *\n");
4996 if (dir_page_p ==
NULL)
5002 for (i = 0; i < num_ptrs; i++)
5015 if (dir_page_p ==
NULL)
5028 printf (
"* Dir loc : %d points to bucket page id: NULL *\n", dir_ptr_no);
5032 printf (
"* Dir loc : %d points to vol:%d bucket pgid: %d *\n", dir_ptr_no,
5044 printf (
"*********************************************************\n");
5055 for (bucket_page_no = 0; bucket_page_no <= num_pages; bucket_page_no++)
5058 if (bucket_page_p ==
NULL)
5073 #if defined(ENABLE_UNUSED_FUNCTION) 5092 if (dir_root_page_p ==
NULL)
5106 if (bucket_page_p ==
NULL)
5132 char *bucket_record_p;
5134 PGSLOTID slot_id, first_slot_id = -1;
5139 #if defined (ENABLE_UNUSED_FUNCTION) 5141 int hour, minute, second, millisecond, month, day, year;
5148 printf (
"************************************************************\n");
5149 printf (
"* local_depth : %d *\n", bucket_header_p->
local_depth);
5150 printf (
"* no. records : %d *\n",
5153 printf (
"* No Key Assoc Value *\n");
5154 printf (
"* ==== ===================== ================== *\n");
5158 for (slot_id = 1; slot_id < num_records; slot_id++)
5160 printf (
"* %2d", slot_id);
5163 bucket_record_p = (
char *) recdes.
data;
5170 #if defined (ENABLE_UNUSED_FUNCTION) 5173 ovf_vpid_p = (
VPID *) bucket_record_p;
5174 bucket_record_p +=
sizeof (
VPID);
5179 putchar (*(bucket_record_p++));
5181 printf (
" ovf: %4d | %1d ", ovf_vpid_p->
pageid, ovf_vpid_p->
volid);
5187 printf (
" %s", bucket_record_p);
5188 for (i = 0; i < (29 - key_size); i++)
5196 printf (
" (%5d,%5d,%5d) ", ((
OID *) bucket_record_p)->volid, ((
OID *) bucket_record_p)->pageid,
5197 ((
OID *) bucket_record_p)->slotid);
5199 #if defined (ENABLE_UNUSED_FUNCTION) 5202 printf (
" %20f ", d);
5206 printf (
" %20f ", *(
float *) bucket_record_p);
5210 printf (
" %14d ", *(
int *) bucket_record_p);
5214 printf (
" %19lld ", (
long long) (*(
DB_BIGINT *) bucket_record_p));
5218 printf (
" %14d ", *(
short *) bucket_record_p);
5223 fprintf (stdout,
" %2d/%2d/%4d ", month, day, year);
5228 fprintf (stdout,
" %2d:%2d:%2d ", hour, minute, second);
5239 printf (
" %2d:%2d:%2d %2d/%2d/%4d ", hour, minute, second, month, day, year);
5246 printf (
" %2d:%2d:%2d.%03d %2d/%2d/%4d ", hour, minute, second, millisecond, month, day, year);
5251 printf (
" %14f type %d ", d, ((
DB_MONETARY *) bucket_record_p)->type);
5259 printf (
"(%5d,%5d,%5d) *\n", assoc_value.
volid, assoc_value.
pageid, assoc_value.
slotid);
5263 printf (
"*********************************************************\n");
5286 xeh_find (
EHID * ehid,
void *value,
OID * oid)
5321 const char *record_p;
5325 record_p = recv_p->
data;
5327 alignment = *(
char *) record_p;
5328 record_p +=
sizeof (char);
5340 bucket_recdes.
data = (
char *) &bucket_header;
5388 slot_id = recv_p->
offset;
5389 recdes.
type = *(
short *) (recv_p->
data);
5390 recdes.
data = (
char *) (recv_p->
data) +
sizeof (short);
5422 char *record_p = (
char *) recv_p->
data;
5423 #
if defined (ENABLE_UNUSED_FUNCTION)
5424 short record_type = recv_p->
offset;
5428 record_p +=
sizeof (
OID);
5430 #if defined (ENABLE_UNUSED_FUNCTION) 5443 long_str = ehash_compose_overflow (thread_p, &recdes);
5445 if (long_str ==
NULL)
5480 slot_id = recv_p->
offset;
5481 recdes.
type = *(
short *) (recv_p->
data);
5482 recdes.
data = (
char *) (recv_p->
data) +
sizeof (short);
5491 && (memcmp (existing_recdes.
data, recdes.
data, recdes.
length) == 0))
5517 char *record_p = (
char *) recv_p->
data;
5519 #
if defined (ENABLE_UNUSED_FUNCTION)
5520 short record_type = recv_p->
offset;
5527 #if defined (ENABLE_UNUSED_FUNCTION) 5540 long_str = ehash_compose_overflow (thread_p, &recdes);
5541 if (long_str ==
NULL)
5596 char *log_redo_record_p;
5602 if (dir_root_page_p ==
NULL)
5618 if (bucket_page_p ==
NULL)
5655 log_redo_record_p = log_recdes_redo.
data;
5658 *(
short *) log_redo_record_p = bucket_recdes.
type;
5659 log_redo_record_p += sizeof (
short);
5662 memcpy (log_redo_record_p, bucket_recdes.
data, bucket_recdes.
length);
5666 log_recdes_redo.
length, log_recdes_redo.
data);
5672 (void)
spage_delete (thread_p, bucket_page_p, slot_no);
5702 inc_cnt = *(
int *) recv_p->
data;
5704 *(
int *) ((
char *) recv_p->
pgptr + recv_p->
offset) += inc_cnt;
5732 for (i = 0; i < repetition.
count; i++)
5752 record_p +=
sizeof (
PAGEID);
5755 record_p +=
sizeof (
VOLID);
5767 record_p += sizeof (
PAGEID);
5770 record_p += sizeof (
VOLID);
5782 record_p +=
sizeof (
PAGEID);
5785 record_p +=
sizeof (
FILEID);
5797 record_p += sizeof (
PAGEID);
5800 record_p += sizeof (
FILEID);
static void ehash_free_recdes(RECDES *recdes)
int file_destroy(THREAD_ENTRY *thread_p, const VFID *vfid, bool is_temp)
int ehash_rv_init_bucket_redo(THREAD_ENTRY *thread_p, LOG_RCV *recv_p)
static EHASH_RESULT ehash_insert_to_bucket(THREAD_ENTRY *thread_p, EHID *ehid, VFID *ovf_file, bool is_temp, PAGE_PTR buc_pgptr, DB_TYPE key_type, void *key_ptr, OID *value_ptr, VPID *existing_ovf_vpid)
struct db_datetime DB_DATETIME
int file_numerable_find_nth(THREAD_ENTRY *thread_p, const VFID *vfid, int nth, bool auto_alloc, FILE_INIT_PAGE_FUNC f_init, void *f_init_args, VPID *vpid_nth)
int ehash_rv_init_dir_redo(THREAD_ENTRY *thread_p, LOG_RCV *recv_p)
#define ER_EH_ROOT_CORRUPTED
static int ehash_compare_key(THREAD_ENTRY *thread_p, char *bucrec_ptr, DB_TYPE key_type, void *key, INT16 rec_type, int *out_compare_result)
static int ehash_connect_bucket(THREAD_ENTRY *thread_p, EHID *ehid, int local_depth, EHASH_HASH_KEY hash_key, VPID *buc_vpid, bool is_temp)
#define GETBIT(word, pos)
#define EHASH_LAST_OFFSET_IN_FIRST_PAGE
void log_append_undoredo_data2(THREAD_ENTRY *thread_p, LOG_RCVINDEX rcvindex, const VFID *vfid, PAGE_PTR pgptr, PGLENGTH offset, int undo_length, int redo_length, const void *undo_data, const void *redo_data)
int file_init_temp_page_type(THREAD_ENTRY *thread_p, PAGE_PTR page, void *args)
static char ehash_find_depth(THREAD_ENTRY *thread_p, EHID *ehid, int location, VPID *vpid, VPID *sib_vpid)
unsigned int mht_1strhash(const void *key, const unsigned int ht_size)
static PAGE_PTR ehash_extend_bucket(THREAD_ENTRY *thread_p, EHID *ehid, PAGE_PTR dir_Rpgptr, EHASH_DIR_HEADER *dir_header, PAGE_PTR buc_pgptr, void *key, EHASH_HASH_KEY hash_key, int *new_bit, VPID *buc_vpid, bool is_temp)
int file_dealloc(THREAD_ENTRY *thread_p, const VFID *vfid, const VPID *vpid, FILE_TYPE file_type_hint)
#define EHASH_MAX_STRING_SIZE
int spage_insert(THREAD_ENTRY *thread_p, PAGE_PTR page_p, RECDES *record_descriptor_p, PGSLOTID *out_slot_id_p)
unsigned int htonl(unsigned int from)
int file_alloc_multiple(THREAD_ENTRY *thread_p, const VFID *vfid, FILE_INIT_PAGE_FUNC f_init, void *f_init_args, int npages, VPID *vpids_out)
int file_numerable_truncate(THREAD_ENTRY *thread_p, const VFID *vfid, DKNPAGES npages)
static PAGE_PTR ehash_split_bucket(THREAD_ENTRY *thread_p, EHASH_DIR_HEADER *dir_header, PAGE_PTR buc_pgptr, void *key, int *old_local_depth, int *new_local_depth, VPID *sib_vpid, bool is_temp)
void spage_initialize(THREAD_ENTRY *thread_p, PAGE_PTR page_p, INT16 slot_type, unsigned short alignment, bool is_saving)
int db_datetime_decode(const DB_DATETIME *datetime, int *month, int *day, int *year, int *hour, int *minute, int *second, int *millisecond)
static PAGE_PTR ehash_fix_ehid_page(THREAD_ENTRY *thread_p, EHID *ehid, PGBUF_LATCH_MODE latch_mode)
int ehash_rv_insert_redo(THREAD_ENTRY *thread_p, LOG_RCV *recv_p)
static int ehash_find_first_bit_position(THREAD_ENTRY *thread_p, EHASH_DIR_HEADER *dir_header, PAGE_PTR buc_pgptr, EHASH_BUCKET_HEADER *buc_header, void *key, int num_recs, PGSLOTID first_slotid, int *old_local_depth, int *new_local_depth)
struct db_monetary DB_MONETARY
static int ehash_rv_delete(THREAD_ENTRY *thread_p, EHID *ehid, void *key)
#define pgbuf_unfix(thread_p, pgptr)
EHID * xehash_create(THREAD_ENTRY *thread_p, EHID *ehid_p, DB_TYPE key_type, int exp_num_entries, OID *class_oid_p, int attr_id, bool is_tmp)
int ansisql_strcmp(const char *s, const char *t)
static void ehash_dir_locate(int *out_page_no_p, int *out_offset_p)
#define EHASH_HASH_KEY_BITS
#define ASSERT_ERROR_AND_SET(error_code)
static int ehash_get_pseudo_key(THREAD_ENTRY *thread_p, RECDES *recdes, DB_TYPE key_type, EHASH_HASH_KEY *out_hash_key)
#define FIND_OFFSET(hash_key, depth)
#define assert_release(e)
void pgbuf_set_dirty(THREAD_ENTRY *thread_p, PAGE_PTR pgptr, bool free_page)
SCAN_CODE overflow_get(THREAD_ENTRY *thread_p, const VPID *ovf_vpid, RECDES *recdes, MVCC_SNAPSHOT *mvcc_snapshot)
void log_append_undo_data2(THREAD_ENTRY *thread_p, LOG_RCVINDEX rcvindex, const VFID *vfid, PAGE_PTR pgptr, PGLENGTH offset, int length, const void *data)
void log_sysop_start(THREAD_ENTRY *thread_p)
void ehash_dump(THREAD_ENTRY *thread_p, EHID *ehid_p)
#define OID_SET_NULL(oidp)
unsigned int EHASH_HASH_KEY
static void ehash_adjust_local_depth(THREAD_ENTRY *thread_p, EHID *ehid, PAGE_PTR dir_Rpgptr, EHASH_DIR_HEADER *dir_header, int depth, int delta, bool is_temp)
static char * ehash_allocate_recdes(RECDES *recdes, int size, short type)
int do_merge(PARSER_CONTEXT *parser, PT_NODE *statement)
#define er_log_debug(...)
int ehash_rv_connect_bucket_redo(THREAD_ENTRY *thread_p, LOG_RCV *recv_p)
static EHID * ehash_create_helper(THREAD_ENTRY *thread_p, EHID *ehid, DB_TYPE key_type, int exp_num_entries, OID *class_oid, int attr_id, bool istmp)
#define COPY_OID(dest_oid_ptr, src_oid_ptr)
int file_create_ehash_dir(THREAD_ENTRY *thread_p, int npages, bool is_tmp, FILE_EHASH_DES *des_ehash, VFID *vfid)
SCAN_CODE spage_get_record(THREAD_ENTRY *thread_p, PAGE_PTR page_p, PGSLOTID slot_id, RECDES *record_descriptor_p, int is_peeking)
#define ER_EH_INVALID_KEY_TYPE
static void * ehash_insert_helper(THREAD_ENTRY *thread_p, EHID *ehid, void *key, OID *value_ptr, int lock_type, VPID *existing_ovf_vpid)
#define EHASH_NUM_NON_FIRST_PAGES
#define DONT_SAFEGUARD_RVSPACE
#define VFID_ISNULL(vfid_ptr)
int ehash_rv_init_dir_new_page_redo(THREAD_ENTRY *thread_p, LOG_RCV *rcv)
static short ehash_get_key_size(DB_TYPE key_type)
#define pgbuf_unfix_and_init(thread_p, pgptr)
static bool ehash_binary_search_bucket(THREAD_ENTRY *thread_p, PAGE_PTR buc_pgptr, PGSLOTID num_record, DB_TYPE key_type, void *key, PGSLOTID *position)
int spage_get_record_length(THREAD_ENTRY *thread_p, PAGE_PTR page_p, PGSLOTID slot_id)
int spage_update(THREAD_ENTRY *thread_p, PAGE_PTR page_p, PGSLOTID slot_id, const RECDES *record_descriptor_p)
void log_append_redo_data2(THREAD_ENTRY *thread_p, LOG_RCVINDEX rcvindex, const VFID *vfid, PAGE_PTR pgptr, PGLENGTH offset, int length, const void *data)
static int ehash_insert_to_bucket_after_create(THREAD_ENTRY *thread_p, EHID *ehid, PAGE_PTR dir_Rpgptr, EHASH_DIR_HEADER *dir_header, VPID *buc_vpid, int location, EHASH_HASH_KEY hash_key, bool is_temp, void *key, OID *value_ptr, VPID *existing_ovf_vpid)
#define EHASH_LAST_OFFSET_IN_NON_FIRST_PAGE
void er_set(int severity, const char *file_name, const int line_no, int err_id, int num_args,...)
int spage_max_space_for_new_record(THREAD_ENTRY *thread_p, PAGE_PTR page_p)
int ehash_rv_increment(THREAD_ENTRY *thread_p, LOG_RCV *recv_p)
int log_rv_copy_char(THREAD_ENTRY *thread_p, LOG_RCV *rcv)
struct ehash_bucket_header EHASH_BUCKET_HEADER
static int ehash_distribute_records_into_two_bucket(THREAD_ENTRY *thread_p, EHASH_DIR_HEADER *dir_header, PAGE_PTR buc_pgptr, EHASH_BUCKET_HEADER *buc_header, int num_recs, PGSLOTID first_slotid, PAGE_PTR sib_pgptr)
bool pgbuf_check_page_ptype(THREAD_ENTRY *thread_p, PAGE_PTR pgptr, PAGE_TYPE ptype)
int ehash_rv_insert_undo(THREAD_ENTRY *thread_p, LOG_RCV *recv_p)
int file_get_num_user_pages(THREAD_ENTRY *thread_p, const VFID *vfid, int *n_user_pages_out)
#define EHASH_DIR_HEADER_SIZE
#define ER_OUT_OF_VIRTUAL_MEMORY
static EHASH_RESULT ehash_check_merge_possible(THREAD_ENTRY *thread_p, EHID *ehid, EHASH_DIR_HEADER *dir_header, VPID *buc_vpid, PAGE_PTR buc_pgptr, int location, int lock_type, int *old_local_depth, VPID *sib_vpid, PAGE_PTR *out_sib_pgptr, PGSLOTID *out_first_slotid, int *out_num_recs, int *out_loc)
#define ER_EH_UNKNOWN_EXT_HASH
unsigned int mht_3strhash(const void *key, const unsigned int ht_size)
static PAGE_PTR ehash_fix_nth_page(THREAD_ENTRY *thread_p, const VFID *vfid, int offset, PGBUF_LATCH_MODE mode)
void * ehash_insert(THREAD_ENTRY *thread_p, EHID *ehid_p, void *key_p, OID *value_p)
static enum scanner_mode mode
#define VPID_EQ(vpid_ptr1, vpid_ptr2)
static PAGE_PTR ehash_find_bucket_vpid_with_hash(THREAD_ENTRY *thread_p, EHID *ehid, void *key, PGBUF_LATCH_MODE root_latch, PGBUF_LATCH_MODE bucket_latch, VPID *out_vpid, EHASH_HASH_KEY *out_hash_key, int *out_location)
static int ehash_write_key_to_record(RECDES *recdes, DB_TYPE key_type, void *key_ptr, short key_size, OID *value_ptr, bool long_str)
static EHASH_HASH_KEY ehash_hash_eight_bytes_type(char *key)
#define GETBITS(value, pos, n)
static void ehash_dump_bucket(THREAD_ENTRY *thread_p, PAGE_PTR buc_pgptr, DB_TYPE key_type)
int file_alloc(THREAD_ENTRY *thread_p, const VFID *vfid, FILE_INIT_PAGE_FUNC f_init, void *f_init_args, VPID *vpid_out, PAGE_PTR *page_out)
PGNSLOTS spage_number_of_records(PAGE_PTR page_p)
static EHASH_HASH_KEY ehash_hash(void *orig_key, DB_TYPE key_type)
#define EHASH_LONG_STRING_PREFIX_SIZE
int ehash_map(THREAD_ENTRY *thread_p, EHID *ehid_p, int(*apply_function)(THREAD_ENTRY *thread_p, void *key, void *data, void *args), void *args)
struct ehash_dir_record EHASH_DIR_RECORD
static bool ehash_locate_slot(THREAD_ENTRY *thread_p, PAGE_PTR page, DB_TYPE key_type, void *key, PGSLOTID *position)
#define pgbuf_fix(thread_p, vpid, fetch_mode, requestmode, condition)
static void ehash_shrink_directory_if_need(THREAD_ENTRY *thread_p, EHID *ehid, EHASH_DIR_HEADER *dir_header, bool is_temp)
#define CEIL_PTVDIV(dividend, divisor)
int db_timestamp_decode_ses(const DB_TIMESTAMP *utime, DB_DATE *date, DB_TIME *timeval)
void * ehash_delete(THREAD_ENTRY *thread_p, EHID *ehid_p, void *key_p)
#define VFID_COPY(vfid_ptr1, vfid_ptr2)
void log_sysop_abort(THREAD_ENTRY *thread_p)
static int ehash_merge_permanent(THREAD_ENTRY *thread_p, EHID *ehid, PAGE_PTR dir_Rpgptr, EHASH_DIR_HEADER *dir_header, PAGE_PTR buc_pgptr, PAGE_PTR sib_pgptr, VPID *buc_vpid, VPID *sib_vpid, int num_recs, int loc, PGSLOTID first_slotid, int *out_new_local_depth, bool is_temp)
static void error(const char *msg)
int file_init_page_type(THREAD_ENTRY *thread_p, PAGE_PTR page, void *args)
#define VPID_ISNULL(vpid_ptr)
int xehash_destroy(THREAD_ENTRY *thread_p, EHID *ehid_p)
void file_postpone_destroy(THREAD_ENTRY *thread_p, const VFID *vfid)
PGSLOTID spage_delete(THREAD_ENTRY *thread_p, PAGE_PTR page_p, PGSLOTID slot_id)
static void ehash_shrink_directory(THREAD_ENTRY *thread_p, EHID *ehid, int new_depth, bool is_temp)
#define EHASH_UNDERFLOW_THRESHOLD
int file_create_ehash(THREAD_ENTRY *thread_p, int npages, bool is_tmp, FILE_EHASH_DES *des_ehash, VFID *vfid)
unsigned short ntohs(unsigned short from)
static void ehash_merge(THREAD_ENTRY *thread_p, EHID *ehid, void *key, bool is_temp)
static int ehash_initialize_bucket_new_page(THREAD_ENTRY *thread_p, PAGE_PTR page_p, void *alignment_depth)
#define free_and_init(ptr)
static int ehash_compose_record(DB_TYPE key_type, void *key_ptr, OID *value_ptr, RECDES *recdes)
static char * ehash_read_ehid_from_record(char *rec_p, EHID *ehid_p)
int oid_compare(const void *a, const void *b)
int ehash_rv_delete_undo(THREAD_ENTRY *thread_p, LOG_RCV *recv_p)
#define OR_MOVE_DOUBLE(src, dst)
void pgbuf_set_page_ptype(THREAD_ENTRY *thread_p, PAGE_PTR pgptr, PAGE_TYPE ptype)
#define EHASH_OVERFLOW_THRESHOLD
static int ehash_initialize_dir_new_page(THREAD_ENTRY *thread_p, PAGE_PTR page_p, void *args)
void log_sysop_commit(THREAD_ENTRY *thread_p)
static char * ehash_write_ehid_to_record(char *rec_p, EHID *ehid_p)
SCAN_CODE spage_next_record(PAGE_PTR page_p, PGSLOTID *out_slot_id_p, RECDES *record_descriptor_p, int is_peeking)
int spage_get_free_space(THREAD_ENTRY *thread_p, PAGE_PTR page_p)
EH_SEARCH ehash_search(THREAD_ENTRY *thread_p, EHID *ehid_p, void *key_p, OID *value_p)
int spage_slot_size(void)
void db_date_decode(const DB_DATE *date, int *monthp, int *dayp, int *yearp)
static char * ehash_write_oid_to_record(char *rec_p, OID *oid_p)
#define ER_EH_UNKNOWN_KEY
unsigned int mht_2strhash(const void *key, const unsigned int ht_size)
int ehash_rv_delete_redo(THREAD_ENTRY *thread_p, LOG_RCV *recv_p)
static int ehash_apply_each(THREAD_ENTRY *thread_p, EHID *ehid, RECDES *recdes, DB_TYPE key_type, char *bucrec_ptr, OID *assoc_value, int *out_apply_error, int(*apply_function)(THREAD_ENTRY *thread_p, void *key, void *data, void *args), void *args)
static EHASH_RESULT ehash_insert_bucket_after_extend_if_need(THREAD_ENTRY *thread_p, EHID *ehid, PAGE_PTR dir_Rpgptr, EHASH_DIR_HEADER *dir_header, VPID *buc_vpid, void *key, EHASH_HASH_KEY hash_key, int lock_type, bool is_temp, OID *value_ptr, VPID *existing_ovf_vpid)
static PAGE_PTR ehash_fix_old_page(THREAD_ENTRY *thread_p, const VFID *vfid, const VPID *vpid, PGBUF_LATCH_MODE mode)
#define EHASH_NUM_FIRST_PAGES
static char * ehash_read_oid_from_record(char *rec_p, OID *oid_p)
void db_time_decode(DB_TIME *timeval, int *hourp, int *minutep, int *secondp)
int overflow_get_length(THREAD_ENTRY *thread_p, const VPID *ovf_vpid)
int overflow_insert(THREAD_ENTRY *thread_p, const VFID *ovf_vfid, VPID *ovf_vpid, RECDES *recdes, FILE_TYPE file_type)
#define VPID_SET_NULL(vpid_ptr)
static int ehash_expand_directory(THREAD_ENTRY *thread_p, EHID *ehid, int new_depth, bool is_temp)
int file_is_temp(THREAD_ENTRY *thread_p, const VFID *vfid, bool *is_temp)
static int ehash_find_bucket_vpid(THREAD_ENTRY *thread_p, EHID *ehid, EHASH_DIR_HEADER *dir_header, int location, PGBUF_LATCH_MODE latch, VPID *out_vpid)
#define VFID_SET_NULL(vfid_ptr)
static EHASH_HASH_KEY ehash_hash_string_type(char *key, char *orig_key)
#define CLEARBIT(word, pos)
int spage_insert_at(THREAD_ENTRY *thread_p, PAGE_PTR page_p, PGSLOTID slot_id, RECDES *record_descriptor_p)
const VPID * overflow_delete(THREAD_ENTRY *thread_p, const VFID *ovf_vfid, const VPID *ovf_vpid)
int spage_insert_for_recovery(THREAD_ENTRY *thread_p, PAGE_PTR page_p, PGSLOTID slot_id, RECDES *record_descriptor_p)
void clear(cub_regex_object *®ex, char *&pattern)