Commit 0fa8df75 authored by marko's avatar marko

branches/zip: Eliminate some more buf_block_align() calls.

ibuf_update_free_bits_low(), ibuf_update_free_bits_for_two_pages_low(),
ibuf_set_free_bits_low(): Replace page_t with buf_block_t.
parent 138ee610
...@@ -1683,6 +1683,7 @@ btr_page_split_and_insert( ...@@ -1683,6 +1683,7 @@ btr_page_split_and_insert(
ulint n_ext, /* in: number of elements in vec */ ulint n_ext, /* in: number of elements in vec */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
buf_block_t* block;
page_t* page; page_t* page;
page_zip_des_t* page_zip; page_zip_des_t* page_zip;
ulint page_no; ulint page_no;
...@@ -1692,8 +1693,9 @@ btr_page_split_and_insert( ...@@ -1692,8 +1693,9 @@ btr_page_split_and_insert(
page_t* new_page; page_t* new_page;
page_zip_des_t* new_page_zip; page_zip_des_t* new_page_zip;
rec_t* split_rec; rec_t* split_rec;
page_t* left_page; buf_block_t* left_block;
page_t* right_page; buf_block_t* right_block;
buf_block_t* insert_block;
page_t* insert_page; page_t* insert_page;
page_zip_des_t* insert_page_zip; page_zip_des_t* insert_page_zip;
page_cur_t* page_cursor; page_cur_t* page_cursor;
...@@ -1720,8 +1722,9 @@ btr_page_split_and_insert( ...@@ -1720,8 +1722,9 @@ btr_page_split_and_insert(
ut_ad(rw_lock_own(dict_index_get_lock(cursor->index), RW_LOCK_EX)); ut_ad(rw_lock_own(dict_index_get_lock(cursor->index), RW_LOCK_EX));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
page = btr_cur_get_page(cursor); block = buf_block_align(btr_cur_get_rec(cursor));
page_zip = buf_frame_get_page_zip(page); page = buf_block_get_frame(block);
page_zip = buf_block_get_page_zip(block);
ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX));
ut_ad(page_get_n_recs(page) >= 1); ut_ad(page_get_n_recs(page) >= 1);
...@@ -1832,10 +1835,10 @@ btr_page_split_and_insert( ...@@ -1832,10 +1835,10 @@ btr_page_split_and_insert(
page_zip, mtr); page_zip, mtr);
} }
left_page = new_page; left_block = new_block;
right_page = page; right_block = block;
lock_update_split_left(right_page, left_page); lock_update_split_left(page, new_page);
} else { } else {
/* fputs("Split right\n", stderr); */ /* fputs("Split right\n", stderr); */
...@@ -1861,10 +1864,10 @@ btr_page_split_and_insert( ...@@ -1861,10 +1864,10 @@ btr_page_split_and_insert(
page_zip, mtr); page_zip, mtr);
} }
left_page = page; left_block = block;
right_page = new_page; right_block = new_block;
lock_update_split_right(right_page, left_page); lock_update_split_right(new_page, page);
} }
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
...@@ -1881,12 +1884,13 @@ btr_page_split_and_insert( ...@@ -1881,12 +1884,13 @@ btr_page_split_and_insert(
page where the tuple should be inserted */ page where the tuple should be inserted */
if (insert_left) { if (insert_left) {
insert_page = left_page; insert_block = left_block;
} else { } else {
insert_page = right_page; insert_block = right_block;
} }
insert_page_zip = buf_frame_get_page_zip(insert_page); insert_page = buf_block_get_frame(insert_block);
insert_page_zip = buf_block_get_page_zip(insert_block);
/* 7. Reposition the cursor for insert and try insertion */ /* 7. Reposition the cursor for insert and try insertion */
page_cursor = btr_cur_get_page_cur(cursor); page_cursor = btr_cur_get_page_cur(cursor);
...@@ -1907,11 +1911,11 @@ btr_page_split_and_insert( ...@@ -1907,11 +1911,11 @@ btr_page_split_and_insert(
left and right pages in the same mtr */ left and right pages in the same mtr */
ibuf_update_free_bits_for_two_pages_low(cursor->index, ibuf_update_free_bits_for_two_pages_low(cursor->index,
left_page, left_block,
right_page, mtr); right_block, mtr);
/* fprintf(stderr, "Split and insert done %lu %lu\n", /* fprintf(stderr, "Split and insert done %lu %lu\n",
page_get_page_no(left_page), page_get_page_no(buf_block_get_frame(left_block)),
page_get_page_no(right_page)); */ page_get_page_no(buf_block_get_frame(right_block))); */
mem_heap_free(heap); mem_heap_free(heap);
return(rec); return(rec);
} }
...@@ -1948,16 +1952,16 @@ btr_page_split_and_insert( ...@@ -1948,16 +1952,16 @@ btr_page_split_and_insert(
/* Insert fit on the page: update the free bits for the /* Insert fit on the page: update the free bits for the
left and right pages in the same mtr */ left and right pages in the same mtr */
ibuf_update_free_bits_for_two_pages_low(cursor->index, left_page, ibuf_update_free_bits_for_two_pages_low(cursor->index, left_block,
right_page, mtr); right_block, mtr);
#if 0 #if 0
fprintf(stderr, "Split and insert done %lu %lu\n", fprintf(stderr, "Split and insert done %lu %lu\n",
page_get_page_no(left_page), buf_block_get_page_no(left_block),
page_get_page_no(right_page)); buf_block_get_page_no(right_block));
#endif #endif
ut_ad(page_validate(left_page, cursor->index)); ut_ad(page_validate(buf_block_get_frame(left_block), cursor->index));
ut_ad(page_validate(right_page, cursor->index)); ut_ad(page_validate(buf_block_get_frame(left_block), cursor->index));
mem_heap_free(heap); mem_heap_free(heap);
return(rec); return(rec);
...@@ -1974,9 +1978,7 @@ btr_level_list_remove( ...@@ -1974,9 +1978,7 @@ btr_level_list_remove(
{ {
ulint space; ulint space;
ulint prev_page_no; ulint prev_page_no;
page_t* prev_page;
ulint next_page_no; ulint next_page_no;
page_t* next_page;
ut_ad(page && mtr); ut_ad(page && mtr);
ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX));
...@@ -1989,28 +1991,34 @@ btr_level_list_remove( ...@@ -1989,28 +1991,34 @@ btr_level_list_remove(
/* Update page links of the level */ /* Update page links of the level */
if (prev_page_no != FIL_NULL) { if (prev_page_no != FIL_NULL) {
buf_block_t* prev_block
prev_page = btr_page_get(space, prev_page_no, RW_X_LATCH, mtr); = btr_block_get(space, prev_page_no, RW_X_LATCH, mtr);
page_t* prev_page
= buf_block_get_frame(prev_block);
#ifdef UNIV_BTR_DEBUG #ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(prev_page) == page_is_comp(page)); ut_a(page_is_comp(prev_page) == page_is_comp(page));
ut_a(btr_page_get_next(prev_page, mtr) ut_a(btr_page_get_next(prev_page, mtr)
== page_get_page_no(page)); == page_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */ #endif /* UNIV_BTR_DEBUG */
btr_page_set_next(prev_page, buf_frame_get_page_zip(prev_page), btr_page_set_next(prev_page,
buf_block_get_page_zip(prev_block),
next_page_no, mtr); next_page_no, mtr);
} }
if (next_page_no != FIL_NULL) { if (next_page_no != FIL_NULL) {
buf_block_t* next_block
next_page = btr_page_get(space, next_page_no, RW_X_LATCH, mtr); = btr_block_get(space, next_page_no, RW_X_LATCH, mtr);
page_t* next_page
= buf_block_get_frame(next_block);
#ifdef UNIV_BTR_DEBUG #ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(next_page) == page_is_comp(page)); ut_a(page_is_comp(next_page) == page_is_comp(page));
ut_a(btr_page_get_prev(next_page, mtr) ut_a(btr_page_get_prev(next_page, mtr)
== page_get_page_no(page)); == page_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */ #endif /* UNIV_BTR_DEBUG */
btr_page_set_prev(next_page, buf_frame_get_page_zip(next_page), btr_page_set_prev(next_page,
buf_block_get_page_zip(next_block),
prev_page_no, mtr); prev_page_no, mtr);
} }
} }
...@@ -2172,7 +2180,7 @@ btr_lift_page_up( ...@@ -2172,7 +2180,7 @@ btr_lift_page_up(
/* Copy the page byte for byte. */ /* Copy the page byte for byte. */
page_zip_copy(father_page_zip, father_page, page_zip_copy(father_page_zip, father_page,
buf_frame_get_page_zip(page), buf_block_get_page_zip(block),
page, index, mtr); page, index, mtr);
} }
...@@ -2433,17 +2441,18 @@ void ...@@ -2433,17 +2441,18 @@ void
btr_discard_only_page_on_level( btr_discard_only_page_on_level(
/*===========================*/ /*===========================*/
dict_index_t* index, /* in: index tree */ dict_index_t* index, /* in: index tree */
page_t* page, /* in: page which is the only on its level */ buf_block_t* block, /* in: page which is the only on its level */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
buf_block_t* father_block; buf_block_t* father_block;
page_t* father_page; page_t* father_page;
page_t* page = buf_block_get_frame(block);
ulint page_level; ulint page_level;
ut_ad(btr_page_get_prev(page, mtr) == FIL_NULL); ut_ad(btr_page_get_prev(page, mtr) == FIL_NULL);
ut_ad(btr_page_get_next(page, mtr) == FIL_NULL); ut_ad(btr_page_get_next(page, mtr) == FIL_NULL);
ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
btr_search_drop_page_hash_index(buf_block_align(page)); btr_search_drop_page_hash_index(block);
father_block = buf_block_align( father_block = buf_block_align(
btr_page_get_father_node_ptr(index, page, mtr)); btr_page_get_father_node_ptr(index, page, mtr));
...@@ -2453,7 +2462,7 @@ btr_discard_only_page_on_level( ...@@ -2453,7 +2462,7 @@ btr_discard_only_page_on_level(
lock_update_discard(page_get_supremum_rec(father_page), page); lock_update_discard(page_get_supremum_rec(father_page), page);
btr_page_set_level(father_page, buf_frame_get_page_zip(father_page), btr_page_set_level(father_page, buf_block_get_page_zip(father_block),
page_level, mtr); page_level, mtr);
/* Free the file page */ /* Free the file page */
...@@ -2472,7 +2481,7 @@ btr_discard_only_page_on_level( ...@@ -2472,7 +2481,7 @@ btr_discard_only_page_on_level(
} else { } else {
ut_ad(page_get_n_recs(father_page) == 1); ut_ad(page_get_n_recs(father_page) == 1);
btr_discard_only_page_on_level(index, father_page, mtr); btr_discard_only_page_on_level(index, father_block, mtr);
} }
} }
...@@ -2493,10 +2502,12 @@ btr_discard_page( ...@@ -2493,10 +2502,12 @@ btr_discard_page(
ulint left_page_no; ulint left_page_no;
ulint right_page_no; ulint right_page_no;
page_t* merge_page; page_t* merge_page;
buf_block_t* block;
page_t* page; page_t* page;
rec_t* node_ptr; rec_t* node_ptr;
page = btr_cur_get_page(cursor); block = buf_block_align(btr_cur_get_rec(cursor));
page = buf_block_get_frame(block);
index = btr_cur_get_index(cursor); index = btr_cur_get_index(cursor);
ut_ad(dict_index_get_page(index) != page_get_page_no(page)); ut_ad(dict_index_get_page(index) != page_get_page_no(page));
...@@ -2525,7 +2536,7 @@ btr_discard_page( ...@@ -2525,7 +2536,7 @@ btr_discard_page(
== page_get_page_no(page)); == page_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */ #endif /* UNIV_BTR_DEBUG */
} else { } else {
btr_discard_only_page_on_level(index, page, mtr); btr_discard_only_page_on_level(index, block, mtr);
return; return;
} }
......
...@@ -2618,7 +2618,7 @@ btr_cur_optimistic_delete( ...@@ -2618,7 +2618,7 @@ btr_cur_optimistic_delete(
successor of the deleted record */ successor of the deleted record */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
page_t* page; buf_block_t* block;
ulint max_ins_size; ulint max_ins_size;
rec_t* rec; rec_t* rec;
mem_heap_t* heap = NULL; mem_heap_t* heap = NULL;
...@@ -2631,9 +2631,9 @@ btr_cur_optimistic_delete( ...@@ -2631,9 +2631,9 @@ btr_cur_optimistic_delete(
MTR_MEMO_PAGE_X_FIX)); MTR_MEMO_PAGE_X_FIX));
/* This is intended only for leaf page deletions */ /* This is intended only for leaf page deletions */
page = btr_cur_get_page(cursor); block = buf_block_align(btr_cur_get_rec(cursor));
ut_ad(page_is_leaf(page)); ut_ad(page_is_leaf(buf_block_get_frame(block)));
rec = btr_cur_get_rec(cursor); rec = btr_cur_get_rec(cursor);
offsets = rec_get_offsets(rec, cursor->index, offsets, offsets = rec_get_offsets(rec, cursor->index, offsets,
...@@ -2645,7 +2645,8 @@ btr_cur_optimistic_delete( ...@@ -2645,7 +2645,8 @@ btr_cur_optimistic_delete(
if (no_compress_needed) { if (no_compress_needed) {
page_zip_des_t* page_zip; page_t* page = buf_block_get_frame(block);
page_zip_des_t* page_zip= buf_block_get_page_zip(block);
lock_update_delete(rec); lock_update_delete(rec);
...@@ -2653,7 +2654,6 @@ btr_cur_optimistic_delete( ...@@ -2653,7 +2654,6 @@ btr_cur_optimistic_delete(
max_ins_size = page_get_max_insert_size_after_reorganize( max_ins_size = page_get_max_insert_size_after_reorganize(
page, 1); page, 1);
page_zip = buf_frame_get_page_zip(btr_cur_get_rec(cursor));
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(!page_zip || page_zip_validate(page_zip, page)); ut_a(!page_zip || page_zip_validate(page_zip, page));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
...@@ -2663,7 +2663,7 @@ btr_cur_optimistic_delete( ...@@ -2663,7 +2663,7 @@ btr_cur_optimistic_delete(
ut_a(!page_zip || page_zip_validate(page_zip, page)); ut_a(!page_zip || page_zip_validate(page_zip, page));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
ibuf_update_free_bits_low(cursor->index, page, max_ins_size, ibuf_update_free_bits_low(cursor->index, block, max_ins_size,
mtr); mtr);
} }
......
...@@ -784,11 +784,12 @@ UNIV_INLINE ...@@ -784,11 +784,12 @@ UNIV_INLINE
void void
ibuf_set_free_bits_low( ibuf_set_free_bits_low(
/*===================*/ /*===================*/
ulint type, /* in: index type */ ulint type, /* in: index type */
page_t* page, /* in: index page; free bit is set if the index is buf_block_t* block, /* in: index page; free bits are set if
non-clustered and page level is 0 */ the index is non-clustered and page
ulint val, /* in: value to set: < 4 */ level is 0 */
mtr_t* mtr) /* in: mtr */ ulint val, /* in: value to set: < 4 */
mtr_t* mtr) /* in: mtr */
{ {
page_t* bitmap_page; page_t* bitmap_page;
ulint space; ulint space;
...@@ -800,24 +801,24 @@ ibuf_set_free_bits_low( ...@@ -800,24 +801,24 @@ ibuf_set_free_bits_low(
return; return;
} }
if (!page_is_leaf(page)) { if (!page_is_leaf(buf_block_get_frame(block))) {
return; return;
} }
space = page_get_space_id(page); space = buf_block_get_space(block);
page_no = page_get_page_no(page); page_no = buf_block_get_page_no(block);
zip_size = fil_space_get_zip_size(space); zip_size = buf_block_get_zip_size(block);
bitmap_page = ibuf_bitmap_get_map_page(space, page_no, zip_size, mtr); bitmap_page = ibuf_bitmap_get_map_page(space, page_no, zip_size, mtr);
#ifdef UNIV_IBUF_DEBUG #ifdef UNIV_IBUF_DEBUG
# if 0 # if 0
fprintf(stderr, fprintf(stderr,
"Setting page no %lu free bits to %lu should be %lu\n", "Setting page no %lu free bits to %lu should be %lu\n",
page_get_page_no(page), val, page_get_page_no(page), val,
ibuf_index_page_calc_free(page)); ibuf_index_page_calc_free(buf_block_get_frame(block)));
# endif # endif
ut_a(val <= ibuf_index_page_calc_free(page)); ut_a(val <= ibuf_index_page_calc_free(buf_block_get_frame(block)));
#endif /* UNIV_IBUF_DEBUG */ #endif /* UNIV_IBUF_DEBUG */
ibuf_bitmap_page_set_bits(bitmap_page, page_no, zip_size, ibuf_bitmap_page_set_bits(bitmap_page, page_no, zip_size,
IBUF_BITMAP_FREE, val, mtr); IBUF_BITMAP_FREE, val, mtr);
...@@ -926,7 +927,7 @@ void ...@@ -926,7 +927,7 @@ void
ibuf_update_free_bits_low( ibuf_update_free_bits_low(
/*======================*/ /*======================*/
dict_index_t* index, /* in: index */ dict_index_t* index, /* in: index */
page_t* page, /* in: index page */ buf_block_t* block, /* in: index page */
ulint max_ins_size, /* in: value of maximum insert size ulint max_ins_size, /* in: value of maximum insert size
with reorganize before the latest with reorganize before the latest
operation performed to the page */ operation performed to the page */
...@@ -937,10 +938,10 @@ ibuf_update_free_bits_low( ...@@ -937,10 +938,10 @@ ibuf_update_free_bits_low(
before = ibuf_index_page_calc_free_bits(max_ins_size); before = ibuf_index_page_calc_free_bits(max_ins_size);
after = ibuf_index_page_calc_free(page); after = ibuf_index_page_calc_free(buf_block_get_frame(block));
if (before != after) { if (before != after) {
ibuf_set_free_bits_low(index->type, page, after, mtr); ibuf_set_free_bits_low(index->type, block, after, mtr);
} }
} }
...@@ -953,8 +954,8 @@ void ...@@ -953,8 +954,8 @@ void
ibuf_update_free_bits_for_two_pages_low( ibuf_update_free_bits_for_two_pages_low(
/*====================================*/ /*====================================*/
dict_index_t* index, /* in: index */ dict_index_t* index, /* in: index */
page_t* page1, /* in: index page */ buf_block_t* block1, /* in: index page */
page_t* page2, /* in: index page */ buf_block_t* block2, /* in: index page */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
ulint state; ulint state;
...@@ -965,13 +966,13 @@ ibuf_update_free_bits_for_two_pages_low( ...@@ -965,13 +966,13 @@ ibuf_update_free_bits_for_two_pages_low(
mutex_enter(&ibuf_bitmap_mutex); mutex_enter(&ibuf_bitmap_mutex);
state = ibuf_index_page_calc_free(page1); state = ibuf_index_page_calc_free(buf_block_get_frame(block1));
ibuf_set_free_bits_low(index->type, page1, state, mtr); ibuf_set_free_bits_low(index->type, block1, state, mtr);
state = ibuf_index_page_calc_free(page2); state = ibuf_index_page_calc_free(buf_block_get_frame(block2));
ibuf_set_free_bits_low(index->type, page2, state, mtr); ibuf_set_free_bits_low(index->type, block2, state, mtr);
mutex_exit(&ibuf_bitmap_mutex); mutex_exit(&ibuf_bitmap_mutex);
} }
......
...@@ -97,7 +97,7 @@ void ...@@ -97,7 +97,7 @@ void
ibuf_update_free_bits_low( ibuf_update_free_bits_low(
/*======================*/ /*======================*/
dict_index_t* index, /* in: index */ dict_index_t* index, /* in: index */
page_t* page, /* in: index page */ buf_block_t* block, /* in: index page */
ulint max_ins_size, /* in: value of maximum insert size ulint max_ins_size, /* in: value of maximum insert size
with reorganize before the latest with reorganize before the latest
operation performed to the page */ operation performed to the page */
...@@ -111,8 +111,8 @@ void ...@@ -111,8 +111,8 @@ void
ibuf_update_free_bits_for_two_pages_low( ibuf_update_free_bits_for_two_pages_low(
/*====================================*/ /*====================================*/
dict_index_t* index, /* in: index */ dict_index_t* index, /* in: index */
page_t* page1, /* in: index page */ buf_block_t* block1, /* in: index page */
page_t* page2, /* in: index page */ buf_block_t* block2, /* in: index page */
mtr_t* mtr); /* in: mtr */ mtr_t* mtr); /* in: mtr */
/************************************************************************** /**************************************************************************
A basic partial test if an insert to the insert buffer could be possible and A basic partial test if an insert to the insert buffer could be possible and
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment