Commit 3ba94cbe authored by marko's avatar marko

branches/zip:

Implement page_zip_write_header().
Add page_zip parameter to btr_page_set_ functions.
Allow page_copy_rec_list_end() to be called with invalid new_page_zip
if the page has been newly created.
parent 88e6d686
...@@ -264,7 +264,7 @@ btr_page_create( ...@@ -264,7 +264,7 @@ btr_page_create(
UT_LIST_GET_FIRST(tree->tree_indexes)->table->comp); UT_LIST_GET_FIRST(tree->tree_indexes)->table->comp);
buf_block_align(page)->check_index_page_at_flush = TRUE; buf_block_align(page)->check_index_page_at_flush = TRUE;
btr_page_set_index_id(page, tree->id, mtr); btr_page_set_index_id(page, NULL, tree->id, mtr);
} }
/****************************************************************** /******************************************************************
...@@ -730,14 +730,14 @@ btr_create( ...@@ -730,14 +730,14 @@ btr_create(
buf_block_align(page)->check_index_page_at_flush = TRUE; buf_block_align(page)->check_index_page_at_flush = TRUE;
/* Set the index id of the page */ /* Set the index id of the page */
btr_page_set_index_id(page, index_id, mtr); btr_page_set_index_id(page, NULL, index_id, mtr);
/* Set the level of the new index page */ /* Set the level of the new index page */
btr_page_set_level(page, 0, mtr); btr_page_set_level(page, NULL, 0, mtr);
/* Set the next node and previous node fields */ /* Set the next node and previous node fields */
btr_page_set_next(page, FIL_NULL, mtr); btr_page_set_next(page, NULL, FIL_NULL, mtr);
btr_page_set_prev(page, FIL_NULL, mtr); btr_page_set_prev(page, NULL, FIL_NULL, mtr);
/* We reset the free bits for the page to allow creation of several /* We reset the free bits for the page to allow creation of several
trees in the same mtr, otherwise the latch on a bitmap page would trees in the same mtr, otherwise the latch on a bitmap page would
...@@ -1046,12 +1046,12 @@ btr_root_raise_and_insert( ...@@ -1046,12 +1046,12 @@ btr_root_raise_and_insert(
level = btr_page_get_level(root, mtr); level = btr_page_get_level(root, mtr);
/* Set the levels of the new index page and root page */ /* Set the levels of the new index page and root page */
btr_page_set_level(new_page, level, mtr); btr_page_set_level(new_page, NULL, level, mtr);
btr_page_set_level(root, level + 1, mtr); btr_page_set_level(root, NULL/* TODO */, level + 1, mtr);
/* Set the next node and previous node fields of new page */ /* Set the next node and previous node fields of new page */
btr_page_set_next(new_page, FIL_NULL, mtr); btr_page_set_next(new_page, NULL, FIL_NULL, mtr);
btr_page_set_prev(new_page, FIL_NULL, mtr); btr_page_set_prev(new_page, NULL, FIL_NULL, mtr);
/* Move the records from root to the new page */ /* Move the records from root to the new page */
...@@ -1480,6 +1480,7 @@ btr_attach_half_pages( ...@@ -1480,6 +1480,7 @@ btr_attach_half_pages(
/*==================*/ /*==================*/
dict_tree_t* tree, /* in: the index tree */ dict_tree_t* tree, /* in: the index tree */
page_t* page, /* in: page to be split */ page_t* page, /* in: page to be split */
/* TODO page_zip? */
rec_t* split_rec, /* in: first record on upper rec_t* split_rec, /* in: first record on upper
half page */ half page */
page_t* new_page, /* in: the new half page */ page_t* new_page, /* in: the new half page */
...@@ -1497,6 +1498,8 @@ btr_attach_half_pages( ...@@ -1497,6 +1498,8 @@ btr_attach_half_pages(
page_t* upper_page; page_t* upper_page;
ulint lower_page_no; ulint lower_page_no;
ulint upper_page_no; ulint upper_page_no;
page_zip_des_t* lower_page_zip;
page_zip_des_t* upper_page_zip;
dtuple_t* node_ptr_upper; dtuple_t* node_ptr_upper;
mem_heap_t* heap; mem_heap_t* heap;
...@@ -1523,7 +1526,7 @@ btr_attach_half_pages( ...@@ -1523,7 +1526,7 @@ btr_attach_half_pages(
/* Replace the address of the old child node (= page) with the /* Replace the address of the old child node (= page) with the
address of the new lower half */ address of the new lower half */
btr_node_ptr_set_child_page_no(node_ptr, btr_node_ptr_set_child_page_no(node_ptr/* TODO zip */,
rec_get_offsets(node_ptr, rec_get_offsets(node_ptr,
UT_LIST_GET_FIRST(tree->tree_indexes), UT_LIST_GET_FIRST(tree->tree_indexes),
NULL, ULINT_UNDEFINED, &heap), NULL, ULINT_UNDEFINED, &heap),
...@@ -1536,6 +1539,9 @@ btr_attach_half_pages( ...@@ -1536,6 +1539,9 @@ btr_attach_half_pages(
upper_page = new_page; upper_page = new_page;
} }
lower_page_zip = buf_block_get_page_zip(buf_block_align(lower_page));
upper_page_zip = buf_block_get_page_zip(buf_block_align(upper_page));
/* Get the level of the split pages */ /* Get the level of the split pages */
level = btr_page_get_level(page, mtr); level = btr_page_get_level(page, mtr);
...@@ -1566,7 +1572,9 @@ btr_attach_half_pages( ...@@ -1566,7 +1572,9 @@ btr_attach_half_pages(
prev_page = btr_page_get(space, prev_page_no, RW_X_LATCH, mtr); prev_page = btr_page_get(space, prev_page_no, RW_X_LATCH, mtr);
ut_a(page_is_comp(prev_page) == page_is_comp(page)); ut_a(page_is_comp(prev_page) == page_is_comp(page));
btr_page_set_next(prev_page, lower_page_no, mtr); btr_page_set_next(prev_page, buf_block_get_page_zip(
buf_block_align(prev_page)),
lower_page_no, mtr);
} }
if (next_page_no != FIL_NULL) { if (next_page_no != FIL_NULL) {
...@@ -1574,16 +1582,18 @@ btr_attach_half_pages( ...@@ -1574,16 +1582,18 @@ btr_attach_half_pages(
next_page = btr_page_get(space, next_page_no, RW_X_LATCH, mtr); next_page = btr_page_get(space, next_page_no, RW_X_LATCH, mtr);
ut_a(page_is_comp(next_page) == page_is_comp(page)); ut_a(page_is_comp(next_page) == page_is_comp(page));
btr_page_set_prev(next_page, upper_page_no, mtr); btr_page_set_prev(next_page, buf_block_get_page_zip(
buf_block_align(next_page)),
upper_page_no, mtr);
} }
btr_page_set_prev(lower_page, prev_page_no, mtr); btr_page_set_prev(lower_page, lower_page_zip, prev_page_no, mtr);
btr_page_set_next(lower_page, upper_page_no, mtr); btr_page_set_next(lower_page, lower_page_zip, upper_page_no, mtr);
btr_page_set_level(lower_page, level, mtr); btr_page_set_level(lower_page, lower_page_zip, level, mtr);
btr_page_set_prev(upper_page, lower_page_no, mtr); btr_page_set_prev(upper_page, upper_page_zip, lower_page_no, mtr);
btr_page_set_next(upper_page, next_page_no, mtr); btr_page_set_next(upper_page, upper_page_zip, next_page_no, mtr);
btr_page_set_level(upper_page, level, mtr); btr_page_set_level(upper_page, upper_page_zip, level, mtr);
} }
/***************************************************************** /*****************************************************************
...@@ -1852,7 +1862,9 @@ btr_level_list_remove( ...@@ -1852,7 +1862,9 @@ btr_level_list_remove(
prev_page = btr_page_get(space, prev_page_no, RW_X_LATCH, mtr); prev_page = btr_page_get(space, prev_page_no, RW_X_LATCH, mtr);
ut_a(page_is_comp(prev_page) == page_is_comp(page)); ut_a(page_is_comp(prev_page) == page_is_comp(page));
btr_page_set_next(prev_page, next_page_no, mtr); btr_page_set_next(prev_page, buf_block_get_page_zip(
buf_block_align(prev_page)),
next_page_no, mtr);
} }
if (next_page_no != FIL_NULL) { if (next_page_no != FIL_NULL) {
...@@ -1860,7 +1872,9 @@ btr_level_list_remove( ...@@ -1860,7 +1872,9 @@ btr_level_list_remove(
next_page = btr_page_get(space, next_page_no, RW_X_LATCH, mtr); next_page = btr_page_get(space, next_page_no, RW_X_LATCH, mtr);
ut_a(page_is_comp(next_page) == page_is_comp(page)); ut_a(page_is_comp(next_page) == page_is_comp(page));
btr_page_set_prev(next_page, prev_page_no, mtr); btr_page_set_prev(next_page, buf_block_get_page_zip(
buf_block_align(next_page)),
prev_page_no, mtr);
} }
} }
...@@ -2022,7 +2036,7 @@ btr_lift_page_up( ...@@ -2022,7 +2036,7 @@ btr_lift_page_up(
ut_error; ut_error;
} }
btr_page_set_level(father_page, page_level, mtr); btr_page_set_level(father_page, NULL, page_level, mtr);
if (UNIV_LIKELY_NULL(father_page_zip)) { if (UNIV_LIKELY_NULL(father_page_zip)) {
if (UNIV_UNLIKELY(!page_zip_compress( if (UNIV_UNLIKELY(!page_zip_compress(
...@@ -2075,7 +2089,6 @@ btr_compress( ...@@ -2075,7 +2089,6 @@ btr_compress(
ulint left_page_no; ulint left_page_no;
ulint right_page_no; ulint right_page_no;
page_t* merge_page; page_t* merge_page;
page_t* father_page;
ibool is_left; ibool is_left;
page_t* page; page_t* page;
rec_t* node_ptr; rec_t* node_ptr;
...@@ -2105,8 +2118,7 @@ btr_compress( ...@@ -2105,8 +2118,7 @@ btr_compress(
node_ptr = btr_page_get_father_node_ptr(tree, page, mtr); node_ptr = btr_page_get_father_node_ptr(tree, page, mtr);
ut_ad(!page_is_comp(page) ut_ad(!page_is_comp(page)
|| rec_get_status(node_ptr) == REC_STATUS_NODE_PTR); || rec_get_status(node_ptr) == REC_STATUS_NODE_PTR);
father_page = buf_frame_align(node_ptr); ut_a(page_is_comp(page) == page_rec_is_comp(node_ptr));
ut_a(page_is_comp(page) == page_is_comp(father_page));
/* Decide the page to which we try to merge and which will inherit /* Decide the page to which we try to merge and which will inherit
the locks */ the locks */
...@@ -2189,6 +2201,8 @@ btr_compress( ...@@ -2189,6 +2201,8 @@ btr_compress(
btr_node_ptr_delete(tree, merge_page, mtr); btr_node_ptr_delete(tree, merge_page, mtr);
} }
/* TODO: update page_zip of node_ptr */
/* Move records to the merge page */ /* Move records to the merge page */
if (is_left) { if (is_left) {
rec_t* orig_pred = page_rec_get_prev( rec_t* orig_pred = page_rec_get_prev(
...@@ -2255,12 +2269,14 @@ btr_discard_only_page_on_level( ...@@ -2255,12 +2269,14 @@ 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, page_level, mtr); btr_page_set_level(father_page, buf_block_get_page_zip(
buf_block_align(father_page)),
page_level, mtr);
/* Free the file page */ /* Free the file page */
btr_page_free(tree, page, mtr); btr_page_free(tree, page, mtr);
if (UNIV_UNLIKELY(buf_frame_get_page_no(father_page) if (UNIV_LIKELY(buf_frame_get_page_no(father_page)
== dict_tree_get_page(tree))) { == dict_tree_get_page(tree))) {
/* The father is the root page */ /* The father is the root page */
......
...@@ -42,10 +42,16 @@ void ...@@ -42,10 +42,16 @@ void
btr_page_set_index_id( btr_page_set_index_id(
/*==================*/ /*==================*/
page_t* page, /* in: page to be created */ page_t* page, /* in: page to be created */
page_zip_des_t* page_zip,/* in: compressed page, or NULL */
dulint id, /* in: index id */ dulint id, /* in: index id */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
mlog_write_dulint(page + PAGE_HEADER + PAGE_INDEX_ID, id, mtr); mlog_write_dulint(page + PAGE_HEADER + PAGE_INDEX_ID, id, mtr);
if (UNIV_LIKELY_NULL(page_zip)) {
page_zip_write_header(page_zip,
page + PAGE_HEADER + PAGE_INDEX_ID, 8);
}
} }
/****************************************************************** /******************************************************************
...@@ -102,6 +108,7 @@ void ...@@ -102,6 +108,7 @@ void
btr_page_set_level( btr_page_set_level(
/*===============*/ /*===============*/
page_t* page, /* in: index page */ page_t* page, /* in: index page */
page_zip_des_t* page_zip,/* in: compressed page, or NULL */
ulint level, /* in: level, leaf level == 0 */ ulint level, /* in: level, leaf level == 0 */
mtr_t* mtr) /* in: mini-transaction handle */ mtr_t* mtr) /* in: mini-transaction handle */
{ {
...@@ -110,6 +117,11 @@ btr_page_set_level( ...@@ -110,6 +117,11 @@ btr_page_set_level(
mlog_write_ulint(page + PAGE_HEADER + PAGE_LEVEL, level, mlog_write_ulint(page + PAGE_HEADER + PAGE_LEVEL, level,
MLOG_2BYTES, mtr); MLOG_2BYTES, mtr);
if (UNIV_LIKELY_NULL(page_zip)) {
page_zip_write_header(page_zip,
page + PAGE_HEADER + PAGE_LEVEL, 2);
}
} }
/************************************************************ /************************************************************
...@@ -138,12 +150,17 @@ void ...@@ -138,12 +150,17 @@ void
btr_page_set_next( btr_page_set_next(
/*==============*/ /*==============*/
page_t* page, /* in: index page */ page_t* page, /* in: index page */
page_zip_des_t* page_zip,/* in: compressed page, or NULL */
ulint next, /* in: next page number */ ulint next, /* in: next page number */
mtr_t* mtr) /* in: mini-transaction handle */ mtr_t* mtr) /* in: mini-transaction handle */
{ {
ut_ad(page && mtr); ut_ad(page && mtr);
mlog_write_ulint(page + FIL_PAGE_NEXT, next, MLOG_4BYTES, mtr); mlog_write_ulint(page + FIL_PAGE_NEXT, next, MLOG_4BYTES, mtr);
if (UNIV_LIKELY_NULL(page_zip)) {
page_zip_write_header(page_zip, page + FIL_PAGE_NEXT, 4);
}
} }
/************************************************************ /************************************************************
...@@ -168,12 +185,17 @@ void ...@@ -168,12 +185,17 @@ void
btr_page_set_prev( btr_page_set_prev(
/*==============*/ /*==============*/
page_t* page, /* in: index page */ page_t* page, /* in: index page */
page_zip_des_t* page_zip,/* in: compressed page, or NULL */
ulint prev, /* in: previous page number */ ulint prev, /* in: previous page number */
mtr_t* mtr) /* in: mini-transaction handle */ mtr_t* mtr) /* in: mini-transaction handle */
{ {
ut_ad(page && mtr); ut_ad(page && mtr);
mlog_write_ulint(page + FIL_PAGE_PREV, prev, MLOG_4BYTES, mtr); mlog_write_ulint(page + FIL_PAGE_PREV, prev, MLOG_4BYTES, mtr);
if (UNIV_LIKELY_NULL(page_zip)) {
page_zip_write_header(page_zip, page + FIL_PAGE_PREV, 4);
}
} }
/****************************************************************** /******************************************************************
......
...@@ -211,9 +211,10 @@ page_zip_write_trailer( ...@@ -211,9 +211,10 @@ page_zip_write_trailer(
pos = ut_align_offset(str, UNIV_PAGE_SIZE); pos = ut_align_offset(str, UNIV_PAGE_SIZE);
ut_ad(pos < PAGE_DATA);/* TODO */ ut_ad(pos > PAGE_DATA);
memcpy(page_zip + pos/* TODO */, str, length); memcpy(page_zip->data + page_zip->size - (UNIV_PAGE_SIZE - pos),
str, length);
ut_ad(page_zip_validate(page_zip, str - pos)); ut_ad(page_zip_validate(page_zip, str - pos));
} }
......
...@@ -604,12 +604,12 @@ page_copy_rec_list_end( ...@@ -604,12 +604,12 @@ page_copy_rec_list_end(
{ {
page_t* page; page_t* page;
ut_ad(!new_page_zip || page_zip_validate(new_page_zip, new_page));
if (page_dir_get_n_heap(new_page) == 2) { if (page_dir_get_n_heap(new_page) == 2) {
page_copy_rec_list_end_to_created_page( page_copy_rec_list_end_to_created_page(
new_page, rec, index, mtr); new_page, rec, index, mtr);
} else { } else {
ut_ad(!new_page_zip
|| page_zip_validate(new_page_zip, new_page));
page_copy_rec_list_end_no_locks(new_page, rec, index, mtr); page_copy_rec_list_end_no_locks(new_page, rec, index, mtr);
} }
......
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