Commit dbfea3e9 authored by marko's avatar marko

branches/zip:

Add page_zip parameter to page_dir_slot_set_rec().
Improve the documentation of the page_zip parameters in page0page.
Add function page_trailer_get_len().
parent 9e21c7fe
...@@ -171,7 +171,8 @@ void ...@@ -171,7 +171,8 @@ void
page_header_set_field( page_header_set_field(
/*==================*/ /*==================*/
page_t* page, /* in/out: page */ page_t* page, /* in/out: page */
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */ page_zip_des_t* page_zip,/* in/out: compressed page whose
uncompressed part will be updated, or NULL */
ulint field, /* in: PAGE_N_DIR_SLOTS, ... */ ulint field, /* in: PAGE_N_DIR_SLOTS, ... */
ulint val); /* in: value */ ulint val); /* in: value */
/***************************************************************** /*****************************************************************
...@@ -190,7 +191,8 @@ void ...@@ -190,7 +191,8 @@ void
page_header_set_ptr( page_header_set_ptr(
/*================*/ /*================*/
page_t* page, /* in/out: page */ page_t* page, /* in/out: page */
page_zip_des_t* page_zip,/* in: compressed page, or NULL */ page_zip_des_t* page_zip,/* in: compressed page whose
uncompressed part will be updated, or NULL */
ulint field, /* in/out: PAGE_FREE, ... */ ulint field, /* in/out: PAGE_FREE, ... */
const byte* ptr); /* in: pointer or NULL*/ const byte* ptr); /* in: pointer or NULL*/
/***************************************************************** /*****************************************************************
...@@ -272,6 +274,14 @@ page_rec_get_n_recs_before( ...@@ -272,6 +274,14 @@ page_rec_get_n_recs_before(
/* out: number of records */ /* out: number of records */
rec_t* rec); /* in: the physical record */ rec_t* rec); /* in: the physical record */
/***************************************************************** /*****************************************************************
Gets the size of the page trailer. */
UNIV_INLINE
ulint
page_trailer_get_len(
/*=================*/
/* out: length of page trailer, in bytes */
const page_t* page); /* in: index page */
/*****************************************************************
Gets the number of records in the heap. */ Gets the number of records in the heap. */
UNIV_INLINE UNIV_INLINE
ulint ulint
...@@ -286,7 +296,8 @@ void ...@@ -286,7 +296,8 @@ void
page_dir_set_n_heap( page_dir_set_n_heap(
/*================*/ /*================*/
page_t* page, /* in/out: index page */ page_t* page, /* in/out: index page */
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */ page_zip_des_t* page_zip,/* in/out: compressed page whose
uncompressed part will be updated, or NULL */
ulint n_heap);/* in: number of records */ ulint n_heap);/* in: number of records */
/***************************************************************** /*****************************************************************
Gets the number of dir slots in directory. */ Gets the number of dir slots in directory. */
...@@ -303,7 +314,8 @@ void ...@@ -303,7 +314,8 @@ void
page_dir_set_n_slots( page_dir_set_n_slots(
/*=================*/ /*=================*/
page_t* page, /* in/out: page */ page_t* page, /* in/out: page */
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */ page_zip_des_t* page_zip,/* in/out: compressed page whose
uncompressed part will be updated, or NULL */
ulint n_slots);/* in: number of slots */ ulint n_slots);/* in: number of slots */
/***************************************************************** /*****************************************************************
Gets pointer to nth directory slot. */ Gets pointer to nth directory slot. */
...@@ -337,6 +349,8 @@ void ...@@ -337,6 +349,8 @@ void
page_dir_slot_set_rec( page_dir_slot_set_rec(
/*==================*/ /*==================*/
page_dir_slot_t* slot, /* in: directory slot */ page_dir_slot_t* slot, /* in: directory slot */
page_zip_des_t* page_zip,/* in/out: compressed page whose
uncompressed part will be updated, or NULL */
rec_t* rec); /* in: record on the page */ rec_t* rec); /* in: record on the page */
/******************************************************************* /*******************************************************************
Gets the number of records owned by a directory slot. */ Gets the number of records owned by a directory slot. */
......
...@@ -68,7 +68,8 @@ void ...@@ -68,7 +68,8 @@ void
page_header_set_field( page_header_set_field(
/*==================*/ /*==================*/
page_t* page, /* in/out: page */ page_t* page, /* in/out: page */
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */ page_zip_des_t* page_zip,/* in/out: compressed page whose
uncompressed part will be updated, or NULL */
ulint field, /* in: PAGE_N_DIR_SLOTS, ... */ ulint field, /* in: PAGE_N_DIR_SLOTS, ... */
ulint val) /* in: value */ ulint val) /* in: value */
{ {
...@@ -119,7 +120,8 @@ void ...@@ -119,7 +120,8 @@ void
page_header_set_ptr( page_header_set_ptr(
/*================*/ /*================*/
page_t* page, /* in: page */ page_t* page, /* in: page */
page_zip_des_t* page_zip,/* in: compressed page, or NULL */ page_zip_des_t* page_zip,/* in: compressed page whose
uncompressed part will be updated, or NULL */
ulint field, /* in: PAGE_FREE, ... */ ulint field, /* in: PAGE_FREE, ... */
const byte* ptr) /* in: pointer or NULL*/ const byte* ptr) /* in: pointer or NULL*/
{ {
...@@ -419,12 +421,27 @@ void ...@@ -419,12 +421,27 @@ void
page_dir_set_n_slots( page_dir_set_n_slots(
/*=================*/ /*=================*/
page_t* page, /* in/out: page */ page_t* page, /* in/out: page */
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */ page_zip_des_t* page_zip,/* in/out: compressed page whose
uncompressed part will be updated, or NULL */
ulint n_slots)/* in: number of slots */ ulint n_slots)/* in: number of slots */
{ {
page_header_set_field(page, page_zip, PAGE_N_DIR_SLOTS, n_slots); page_header_set_field(page, page_zip, PAGE_N_DIR_SLOTS, n_slots);
} }
/*****************************************************************
Gets the size of the page trailer. */
UNIV_INLINE
ulint
page_trailer_get_len(
/*=================*/
/* out: length of page trailer, in bytes */
const page_t* page) /* in: index page */
{
return(page + UNIV_PAGE_SIZE
- page_dir_get_nth_slot((page_t*) page,
page_dir_get_n_slots((page_t*) page) - 1));
}
/***************************************************************** /*****************************************************************
Gets the number of records in the heap. */ Gets the number of records in the heap. */
UNIV_INLINE UNIV_INLINE
...@@ -444,7 +461,8 @@ void ...@@ -444,7 +461,8 @@ void
page_dir_set_n_heap( page_dir_set_n_heap(
/*================*/ /*================*/
page_t* page, /* in/out: index page */ page_t* page, /* in/out: index page */
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */ page_zip_des_t* page_zip,/* in/out: compressed page whose
uncompressed part will be updated, or NULL */
ulint n_heap) /* in: number of records */ ulint n_heap) /* in: number of records */
{ {
ut_ad(n_heap < 0x8000); ut_ad(n_heap < 0x8000);
...@@ -509,11 +527,17 @@ void ...@@ -509,11 +527,17 @@ void
page_dir_slot_set_rec( page_dir_slot_set_rec(
/*==================*/ /*==================*/
page_dir_slot_t* slot, /* in: directory slot */ page_dir_slot_t* slot, /* in: directory slot */
page_zip_des_t* page_zip,/* in/out: compressed page whose
uncompressed part will be updated, or NULL */
rec_t* rec) /* in: record on the page */ rec_t* rec) /* in: record on the page */
{ {
ut_ad(page_rec_check(rec)); ut_ad(page_rec_check(rec));
mach_write_to_2(slot, ut_align_offset(rec, UNIV_PAGE_SIZE)); mach_write_to_2(slot, ut_align_offset(rec, UNIV_PAGE_SIZE));
if (UNIV_LIKELY_NULL(page_zip)) {
page_zip_write_trailer(page_zip, slot, 2);
}
} }
/******************************************************************* /*******************************************************************
......
...@@ -212,6 +212,8 @@ page_zip_write_trailer( ...@@ -212,6 +212,8 @@ 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); ut_ad(pos > PAGE_DATA);
ut_ad(pos < UNIV_PAGE_SIZE
- page_trailer_get_len(buf_block_align((byte*) str)));
memcpy(page_zip->data + page_zip->size - (UNIV_PAGE_SIZE - pos), memcpy(page_zip->data + page_zip->size - (UNIV_PAGE_SIZE - pos),
str, length); str, length);
......
...@@ -1244,7 +1244,7 @@ page_copy_rec_list_end_to_created_page( ...@@ -1244,7 +1244,7 @@ page_copy_rec_list_end_to_created_page(
slot = page_dir_get_nth_slot(new_page, slot_index); slot = page_dir_get_nth_slot(new_page, slot_index);
page_dir_slot_set_rec(slot, insert_rec); page_dir_slot_set_rec(slot, NULL, insert_rec);
page_dir_slot_set_n_owned(slot, NULL, count); page_dir_slot_set_n_owned(slot, NULL, count);
count = 0; count = 0;
...@@ -1297,7 +1297,7 @@ page_copy_rec_list_end_to_created_page( ...@@ -1297,7 +1297,7 @@ page_copy_rec_list_end_to_created_page(
slot = page_dir_get_nth_slot(new_page, 1 + slot_index); slot = page_dir_get_nth_slot(new_page, 1 + slot_index);
page_dir_slot_set_rec(slot, page_get_supremum_rec(new_page)); page_dir_slot_set_rec(slot, NULL, page_get_supremum_rec(new_page));
page_dir_slot_set_n_owned(slot, NULL, count + 1); page_dir_slot_set_n_owned(slot, NULL, count + 1);
page_dir_set_n_slots(new_page, NULL, 2 + slot_index); page_dir_set_n_slots(new_page, NULL, 2 + slot_index);
...@@ -1482,7 +1482,7 @@ page_cur_delete_rec( ...@@ -1482,7 +1482,7 @@ page_cur_delete_rec(
ut_ad(cur_n_owned > 1); ut_ad(cur_n_owned > 1);
if (current_rec == page_dir_slot_get_rec(cur_dir_slot)) { if (current_rec == page_dir_slot_get_rec(cur_dir_slot)) {
page_dir_slot_set_rec(cur_dir_slot, prev_rec); page_dir_slot_set_rec(cur_dir_slot, page_zip, prev_rec);
} }
/* 5. Update the number of owned records of the slot */ /* 5. Update the number of owned records of the slot */
......
...@@ -485,10 +485,10 @@ page_create( ...@@ -485,10 +485,10 @@ page_create(
/* Set the slots to point to infimum and supremum. */ /* Set the slots to point to infimum and supremum. */
slot = page_dir_get_nth_slot(page, 0); slot = page_dir_get_nth_slot(page, 0);
page_dir_slot_set_rec(slot, infimum_rec); page_dir_slot_set_rec(slot, NULL, infimum_rec);
slot = page_dir_get_nth_slot(page, 1); slot = page_dir_get_nth_slot(page, 1);
page_dir_slot_set_rec(slot, supremum_rec); page_dir_slot_set_rec(slot, NULL, supremum_rec);
/* Set the next pointers in infimum and supremum */ /* Set the next pointers in infimum and supremum */
...@@ -928,7 +928,8 @@ page_delete_rec_list_end( ...@@ -928,7 +928,8 @@ page_delete_rec_list_end(
slot_index = page_dir_find_owner_slot(rec2); slot_index = page_dir_find_owner_slot(rec2);
slot = page_dir_get_nth_slot(page, slot_index); slot = page_dir_get_nth_slot(page, slot_index);
page_dir_slot_set_rec(slot, page_get_supremum_rec(page)); page_dir_slot_set_rec(slot, page_zip_temp,
page_get_supremum_rec(page));
page_dir_slot_set_n_owned(slot, page_zip_temp, n_owned); page_dir_slot_set_n_owned(slot, page_zip_temp, n_owned);
page_dir_set_n_slots(page, page_zip_temp, slot_index + 1); page_dir_set_n_slots(page, page_zip_temp, slot_index + 1);
...@@ -1119,7 +1120,8 @@ page_dir_delete_slot( ...@@ -1119,7 +1120,8 @@ page_dir_delete_slot(
for (i = slot_no + 1; i < n_slots; i++) { for (i = slot_no + 1; i < n_slots; i++) {
rec_t* rec; rec_t* rec;
rec = page_dir_slot_get_rec(page_dir_get_nth_slot(page, i)); rec = page_dir_slot_get_rec(page_dir_get_nth_slot(page, i));
page_dir_slot_set_rec(page_dir_get_nth_slot(page, i), rec); page_dir_slot_set_rec(page_dir_get_nth_slot(page, i),
page_zip, rec);
} }
/* 4. Update the page header */ /* 4. Update the page header */
...@@ -1163,14 +1165,7 @@ page_dir_add_slots( ...@@ -1163,14 +1165,7 @@ page_dir_add_slots(
rec = page_dir_slot_get_rec(slot); rec = page_dir_slot_get_rec(slot);
slot = page_dir_get_nth_slot(page, i + n); slot = page_dir_get_nth_slot(page, i + n);
page_dir_slot_set_rec(slot, rec); page_dir_slot_set_rec(slot, page_zip, rec);
}
if (UNIV_LIKELY_NULL(page_zip)) {
/* TODO: test this */
page_zip_write_trailer(page_zip,
page_dir_get_nth_slot(page, n_slots + n - 1),
(n_slots + n - start) * PAGE_DIR_SLOT_SIZE);
} }
} }
...@@ -1227,7 +1222,7 @@ page_dir_split_slot( ...@@ -1227,7 +1222,7 @@ page_dir_split_slot(
/* 3. We store the appropriate values to the new slot. */ /* 3. We store the appropriate values to the new slot. */
page_dir_slot_set_rec(new_slot, rec); page_dir_slot_set_rec(new_slot, page_zip, rec);
page_dir_slot_set_n_owned(new_slot, page_zip, n_owned / 2); page_dir_slot_set_n_owned(new_slot, page_zip, n_owned / 2);
/* 4. Finally, we update the number of records field of the /* 4. Finally, we update the number of records field of the
...@@ -1293,13 +1288,13 @@ page_dir_balance_slot( ...@@ -1293,13 +1288,13 @@ page_dir_balance_slot(
rec_set_n_owned_new(old_rec, page_zip, 0); rec_set_n_owned_new(old_rec, page_zip, 0);
rec_set_n_owned_new(new_rec, page_zip, n_owned + 1); rec_set_n_owned_new(new_rec, page_zip, n_owned + 1);
page_dir_slot_set_rec(slot, new_rec); page_dir_slot_set_rec(slot, page_zip, new_rec);
} else { } else {
new_rec = rec_get_next_ptr(old_rec, FALSE); new_rec = rec_get_next_ptr(old_rec, FALSE);
rec_set_n_owned_old(old_rec, 0); rec_set_n_owned_old(old_rec, 0);
rec_set_n_owned_old(new_rec, n_owned + 1); rec_set_n_owned_old(new_rec, n_owned + 1);
page_dir_slot_set_rec(slot, new_rec); page_dir_slot_set_rec(slot, page_zip, new_rec);
} }
page_dir_slot_set_n_owned(up_slot, page_zip, up_n_owned -1); page_dir_slot_set_n_owned(up_slot, page_zip, up_n_owned -1);
......
...@@ -44,9 +44,7 @@ page_zip_compress( ...@@ -44,9 +44,7 @@ page_zip_compress(
buf = mem_alloc(page_zip->size - PAGE_DATA); buf = mem_alloc(page_zip->size - PAGE_DATA);
/* Determine the length of the page trailer. */ /* Determine the length of the page trailer. */
trailer_len = page + UNIV_PAGE_SIZE trailer_len = page_trailer_get_len(page);
- page_dir_get_nth_slot((page_t*) page,
page_dir_get_n_slots((page_t*) page) - 1);
ut_ad(trailer_len < UNIV_PAGE_SIZE - PAGE_DATA); ut_ad(trailer_len < UNIV_PAGE_SIZE - PAGE_DATA);
/* Compress the data payload. */ /* Compress the data payload. */
......
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