Commit 897d28ca authored by marko's avatar marko

branches/zip: Remove the possibility to relocate reallocated records

on a compressed page.

page_zip_get_n_relocated(), page_zip_set_n_relocated(),
page_zip_get_relocated(): Remove.

page0zip.c, page0zip.ic: Remove all references to n_relocated.

page_cur_insert_rec_low(): On pages that are compressed,
never relocate records that are allocated from the free list.
parent 942ec176
......@@ -72,14 +72,10 @@ In summary, the compressed page looks like this:
- indexed by heap_no
- DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN if page_is_leaf(page_zip->data)
- REC_NODE_PTR_SIZE otherwise
(8) Original origins of records that have been relocated since
the page was compressed, in ascending order, 16 bits per entry
(9) dense page directory, stored backwards
(8) dense page directory, stored backwards
- n_dense = n_heap - 2
- existing records in ascending collation order
- deleted records (free list) in link order
(10) Number of records that have been relocated
since the page was compressed (16 bits), cf. (7)
*/
/* Start offset of the area that will be compressed */
......@@ -144,75 +140,9 @@ page_zip_simple_validate(
}
#endif /* UNIV_DEBUG */
/*****************************************************************
Gets the number of records that have been relocated, that is,
allocated from the free list since the page was compressed,
such that extra_size has grown. */
UNIV_INLINE
ulint
page_zip_get_n_relocated(
/*=====================*/
/* out: number of records
that have been relocated */
const page_zip_des_t* page_zip) /* in: compressed page */
{
return(mach_read_from_2(page_zip->data
+ page_zip->size - PAGE_ZIP_DIR_SLOT_SIZE));
}
/*****************************************************************
Sets the number of records that have been relocated, that is,
allocated from the free list since the page was compressed,
such that extra_size has grown. */
UNIV_INLINE
void
page_zip_set_n_relocated(
/*=====================*/
const page_zip_des_t* page_zip, /* in: compressed page */
ulint n_relocated) /* in: number of records
that have been relocated */
{
mach_write_to_2(page_zip->data
+ page_zip->size - PAGE_ZIP_DIR_SLOT_SIZE,
n_relocated);
}
/*****************************************************************
Gets original offset of a record that has been relocated, that is,
allocated from the free list since the page was compressed,
such that extra_size has grown. */
UNIV_INLINE
ulint
page_zip_get_relocated(
/*===================*/
/* out: original offset
of the record */
const page_zip_des_t* page_zip, /* in: compressed page */
ulint i) /* in: ith record */
{
#ifdef UNIV_DEBUG
ulint n = page_zip_get_n_relocated(page_zip);
#endif /* UNIV_DEBUG */
ulint offset;
ut_ad(i < n);
/* Below, we subtract 2 from n_heap for the page infimum and supremum,
but add 1 for n_relocated, and index by i + 1 */
offset = mach_read_from_2(page_zip->data
+ page_zip->size - PAGE_ZIP_DIR_SLOT_SIZE
* (page_dir_get_n_heap(page_zip->data) + i));
ut_ad(offset >= PAGE_ZIP_START);
ut_ad(offset < page_zip->size - PAGE_ZIP_DIR_SLOT_SIZE
* (page_dir_get_n_heap(page_zip->data) + n - 1));
return(offset);
}
/*****************************************************************
Gets the size of the compressed page trailer (the dense page directory),
including deleted records (the free list) and n_relocated. */
including deleted records (the free list). */
UNIV_INLINE
ulint
page_zip_dir_size(
......@@ -221,17 +151,16 @@ page_zip_dir_size(
directory, in bytes */
const page_zip_des_t* page_zip) /* in: compressed page */
{
/* Exclude the page infimum and supremum from the record count.
Add 1 slot for n_relocated. */
/* Exclude the page infimum and supremum from the record count. */
ulint size = PAGE_ZIP_DIR_SLOT_SIZE
* (page_dir_get_n_heap((page_t*) page_zip->data) - 1);
* (page_dir_get_n_heap((page_t*) page_zip->data) - 2);
ut_ad(page_zip->m_end + size < page_zip->size);
return(size);
}
/*****************************************************************
Gets the size of the compressed page trailer (the dense page directory),
only including user records (excluding the free list and n_relocated). */
only including user records (excluding the free list). */
UNIV_INLINE
ulint
page_zip_dir_user_size(
......@@ -323,9 +252,8 @@ page_zip_dir_get(
{
ut_ad(page_zip_simple_validate(page_zip));
ut_ad(slot < page_zip_dir_size(page_zip) / PAGE_ZIP_DIR_SLOT_SIZE);
/* Add 1 for n_relocated */
return(mach_read_from_2(page_zip->data + page_zip->size
- PAGE_ZIP_DIR_SLOT_SIZE * (slot + 2)));
- PAGE_ZIP_DIR_SLOT_SIZE * (slot + 1)));
}
/*****************************************************************
Write a given slot in the dense page directory. */
......@@ -340,9 +268,8 @@ page_zip_dir_set(
PAGE_ZIP_DIR_SLOT_OWNED */
{
ut_ad(page_zip_simple_validate(page_zip));
/* Add 1 for n_relocated */
mach_write_to_2(page_zip->data + page_zip->size
- PAGE_ZIP_DIR_SLOT_SIZE * (slot + 2),
- PAGE_ZIP_DIR_SLOT_SIZE * (slot + 1),
offs);
}
......@@ -427,7 +354,7 @@ page_zip_available(
if (UNIV_UNLIKELY(create)) {
/* When a record is created, a pointer may be added to
the dense directory or to the list of relocated records.
the dense directory.
Likewise, space for the columns that will not be
compressed will be allocated from the page trailer.
Also the BLOB pointers will be allocated from there, but
......
......@@ -949,13 +949,13 @@ page_cur_insert_rec_low(
if (page_is_comp(page)) {
if (UNIV_LIKELY_NULL(page_zip)) {
/* On compressed pages, records from
the free list may only be relocated so
that extra_size will not decrease. */
/* On compressed pages, do not
relocate records from the free list.
If extra_size would grow, use the heap. */
lint extra_size_diff
= rec_offs_extra_size(offsets)
- rec_offs_extra_size(foffsets);
/* TODO: compare to original extra_size */
if (UNIV_UNLIKELY(extra_size_diff < 0)) {
/* Add an offset to the extra_size. */
if (rec_offs_size(foffsets)
......@@ -965,12 +965,11 @@ page_cur_insert_rec_low(
}
insert_buf -= extra_size_diff;
}
} else if (UNIV_UNLIKELY(extra_size_diff)) {
/* Do not allow extra_size to grow */
/* TODO: update to the relocation log
* add when extra_size grows for the first time
* remove when extra_size shrinks to original
*/
goto use_heap;
}
}
heap_no = rec_get_heap_no_new(free_rec);
......
......@@ -376,9 +376,9 @@ page_zip_compress(
c_stream.next_out = buf;
/* Subtract the space reserved for uncompressed data. */
/* Page header, n_relocated, end marker of modification log */
/* Page header, end marker of modification log */
c_stream.avail_out = page_zip->size
- (PAGE_DATA + 2 * PAGE_ZIP_DIR_SLOT_SIZE);
- (PAGE_DATA + PAGE_ZIP_DIR_SLOT_SIZE);
/* Dense page directory and uncompressed columns, if any */
if (page_is_leaf(page)) {
trx_id_col = dict_index_get_sys_col_pos(index, DATA_TRX_ID);
......@@ -413,7 +413,6 @@ page_zip_compress(
ut_ad(!c_stream.avail_in);
/* TODO: do not write to page_zip->data until deflateEnd() */
page_zip_set_n_relocated(page_zip, 0);
page_zip_dir_encode(page, page_zip, recs);
c_stream.next_in = (byte*) page + PAGE_ZIP_START;
......@@ -1163,10 +1162,6 @@ page_zip_decompress(
rec_t** recsc; /* cursor to dense page directory */
ulint heap_status;/* heap_no and status bits */
ulint n_dense;/* number of user records on the page */
ulint reloc = 0;/* index to page_zip_get_relocated() */
ulint orig = ULINT_UNDEFINED;
/* page_zip_get_relocated(reloc),
or ULINT_UNDEFINED */
ulint trx_id_col = ULINT_UNDEFINED;
mem_heap_t* heap;
ulint* offsets = NULL;
......@@ -1288,36 +1283,12 @@ page_zip_decompress(
*offsets = n;
}
if (page_zip_get_n_relocated(page_zip)) {
orig = page_zip_get_relocated(page_zip, reloc);
reloc++;
}
page_zip->n_blobs = 0;
while (n_dense--) {
byte* const last = d_stream.next_out;
rec_t* rec = *recsc++;
/* Was the record relocated? */
if (UNIV_UNLIKELY(orig
< ut_align_offset(rec, UNIV_PAGE_SIZE))) {
/* The record was relocated since the page was
compressed. Get the original offset. */
rec = page + orig;
/* Get the offset of the next relocated record. */
if (reloc < page_zip_get_n_relocated(page_zip)) {
orig = page_zip_get_relocated(page_zip, reloc);
ut_ad(ut_align_offset(rec, UNIV_PAGE_SIZE)
< orig);
reloc++;
} else {
/* End of list */
orig = ULINT_UNDEFINED;
}
}
d_stream.avail_out = rec - REC_N_NEW_EXTRA_BYTES - last;
ut_ad(d_stream.avail_out < UNIV_PAGE_SIZE
......@@ -1568,8 +1539,7 @@ page_zip_decompress(
/* Copy the uncompressed fields. */
storage = page_zip->data + page_zip->size
- (n_dense + 1 + page_zip_get_n_relocated(page_zip))
* PAGE_ZIP_DIR_SLOT_SIZE;
- (n_dense + 1) * PAGE_ZIP_DIR_SLOT_SIZE;
externs = storage - n_dense * (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN);
page_zip->n_blobs = 0;
recsc = recs;
......@@ -1720,8 +1690,7 @@ page_zip_write_rec(
/* Write the data bytes. Store the uncompressed bytes separately. */
storage = page_zip->data + page_zip->size
- (page_dir_get_n_heap(page) - 1
+ page_zip_get_n_relocated(page_zip))
- (page_dir_get_n_heap(page) - 1)
* PAGE_ZIP_DIR_SLOT_SIZE;
if (page_is_leaf(page)) {
......
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