mirror of
https://github.com/MariaDB/server.git
synced 2025-01-21 06:22:28 +01:00
branches/zip: page_cur_insert_rec_low(): Replace page_zip_dir_rewrite()
with page_zip_dir_insert(). Pass page_zip to rec_set_n_owned_new() and page_dir_slot_set_n_owned(). page_zip_dir_insert(): New function. Shift the dense page directory and write the inserted record there.
This commit is contained in:
parent
49c9bbd81e
commit
2c3b9102f8
4 changed files with 98 additions and 36 deletions
|
@ -223,16 +223,6 @@ page_zip_write_trx_id_and_roll_ptr(
|
|||
dulint roll_ptr)/* in: roll_ptr */
|
||||
__attribute__((nonnull));
|
||||
|
||||
/**************************************************************************
|
||||
Populate the dense page directory on the compressed page
|
||||
from the sparse directory on the uncompressed row_format=compact page. */
|
||||
void
|
||||
page_zip_dir_rewrite(
|
||||
/*=================*/
|
||||
page_zip_des_t* page_zip,/* out: dense directory on compressed page */
|
||||
const page_t* page) /* in: uncompressed page */
|
||||
__attribute__((nonnull));
|
||||
|
||||
/**************************************************************************
|
||||
Write the "deleted" flag of a record on a compressed page. The flag must
|
||||
already have been written on the uncompressed page. */
|
||||
|
@ -257,6 +247,20 @@ page_zip_rec_set_owned(
|
|||
ulint flag) /* in: the owned flag (nonzero=TRUE) */
|
||||
__attribute__((nonnull));
|
||||
|
||||
/**************************************************************************
|
||||
Insert a record to the dense page directory. */
|
||||
|
||||
void
|
||||
page_zip_dir_insert(
|
||||
/*================*/
|
||||
page_zip_des_t* page_zip,/* in/out: compressed page */
|
||||
const byte* prev_rec,/* in: record after which to insert */
|
||||
const byte* free_rec,/* in: record from which rec was
|
||||
allocated, or NULL */
|
||||
byte* rec, /* in: record to insert */
|
||||
dict_index_t* index, /* in: index of rec */
|
||||
const ulint* offsets);/* in: rec_get_offsets(rec) */
|
||||
|
||||
/**************************************************************************
|
||||
Shift the dense page directory and the array of BLOB pointers
|
||||
when a record is deleted. */
|
||||
|
|
|
@ -903,6 +903,8 @@ page_cur_insert_rec_low(
|
|||
ulint rec_size;
|
||||
byte* page; /* the relevant page */
|
||||
rec_t* last_insert; /* cursor position at previous insert */
|
||||
rec_t* free_rec; /* a free record that was reused,
|
||||
or NULL */
|
||||
rec_t* insert_rec; /* inserted record */
|
||||
ulint heap_no; /* heap number of the inserted record */
|
||||
rec_t* current_rec; /* current record after which the
|
||||
|
@ -932,10 +934,9 @@ page_cur_insert_rec_low(
|
|||
page_zip = NULL;
|
||||
}
|
||||
|
||||
insert_buf = page_header_get_ptr(page, PAGE_FREE);
|
||||
if (insert_buf) {
|
||||
free_rec = page_header_get_ptr(page, PAGE_FREE);
|
||||
if (UNIV_LIKELY_NULL(free_rec)) {
|
||||
/* Try to allocate from the head of the free list. */
|
||||
rec_t* free_rec = insert_buf;
|
||||
ulint foffsets_[REC_OFFS_NORMAL_SIZE];
|
||||
ulint* foffsets = foffsets_;
|
||||
mem_heap_t* heap = NULL;
|
||||
|
@ -953,7 +954,7 @@ too_small:
|
|||
goto use_heap;
|
||||
}
|
||||
|
||||
insert_buf -= rec_offs_extra_size(foffsets);
|
||||
insert_buf = free_rec - rec_offs_extra_size(foffsets);
|
||||
|
||||
if (page_is_comp(page)) {
|
||||
if (UNIV_LIKELY_NULL(page_zip)) {
|
||||
|
@ -997,6 +998,7 @@ too_small:
|
|||
}
|
||||
} else {
|
||||
use_heap:
|
||||
free_rec = NULL;
|
||||
insert_buf = page_mem_alloc_heap(
|
||||
page, page_zip, rec_size, &heap_no);
|
||||
|
||||
|
@ -1047,7 +1049,12 @@ use_heap:
|
|||
if (page_is_comp(page)) {
|
||||
rec_set_n_owned_new(insert_rec, NULL, 0);
|
||||
rec_set_heap_no_new(insert_rec, heap_no);
|
||||
if (UNIV_LIKELY_NULL(page_zip)) {
|
||||
page_zip_dir_insert(page_zip, current_rec, free_rec,
|
||||
insert_rec, index, offsets);
|
||||
}
|
||||
} else {
|
||||
ut_ad(!page_zip);
|
||||
rec_set_n_owned_old(insert_rec, 0);
|
||||
rec_set_heap_no_old(insert_rec, heap_no);
|
||||
}
|
||||
|
@ -1093,7 +1100,7 @@ use_heap:
|
|||
ulint n_owned;
|
||||
if (page_is_comp(page)) {
|
||||
n_owned = rec_get_n_owned_new(owner_rec);
|
||||
rec_set_n_owned_new(owner_rec, NULL, n_owned + 1);
|
||||
rec_set_n_owned_new(owner_rec, page_zip, n_owned + 1);
|
||||
} else {
|
||||
n_owned = rec_get_n_owned_old(owner_rec);
|
||||
rec_set_n_owned_old(owner_rec, n_owned + 1);
|
||||
|
@ -1110,9 +1117,6 @@ use_heap:
|
|||
}
|
||||
|
||||
if (UNIV_LIKELY_NULL(page_zip)) {
|
||||
/* TODO: something similar to page_zip_dir_delete() */
|
||||
page_zip_dir_rewrite(page_zip, page);
|
||||
|
||||
page_zip_write_rec(page_zip, insert_rec, index, offsets, 1);
|
||||
} else if (UNIV_LIKELY_NULL(page_zip_orig)) {
|
||||
ut_a(page_is_comp(page));
|
||||
|
|
|
@ -1308,14 +1308,12 @@ page_dir_split_slot(
|
|||
/* 3. We store the appropriate values to the new slot. */
|
||||
|
||||
page_dir_slot_set_rec(new_slot, rec);
|
||||
/* Pass page_zip==NULL here, because the caller will rewrite
|
||||
the dense page directory by invoking page_zip_dir_rewrite(). */
|
||||
page_dir_slot_set_n_owned(new_slot, NULL, 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
|
||||
original slot */
|
||||
|
||||
page_dir_slot_set_n_owned(slot, NULL, n_owned - (n_owned / 2));
|
||||
page_dir_slot_set_n_owned(slot, page_zip, n_owned - (n_owned / 2));
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
|
|
|
@ -2779,20 +2779,6 @@ page_zip_clear_rec(
|
|||
#endif /* UNIV_ZIP_DEBUG */
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
Populate the dense page directory on the compressed page
|
||||
from the sparse directory on the uncompressed row_format=compact page. */
|
||||
void
|
||||
page_zip_dir_rewrite(
|
||||
/*=================*/
|
||||
page_zip_des_t* page_zip,/* out: dense directory on compressed page */
|
||||
const page_t* page) /* in: uncompressed page */
|
||||
{
|
||||
ut_ad(page_zip_simple_validate(page_zip));
|
||||
|
||||
page_zip_dir_encode(page, page_zip->data + page_zip->size, NULL);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
Write the "deleted" flag of a record on a compressed page. The flag must
|
||||
already have been written on the uncompressed page. */
|
||||
|
@ -2835,6 +2821,76 @@ page_zip_rec_set_owned(
|
|||
}
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
Insert a record to the dense page directory. */
|
||||
|
||||
void
|
||||
page_zip_dir_insert(
|
||||
/*================*/
|
||||
page_zip_des_t* page_zip,/* in/out: compressed page */
|
||||
const byte* prev_rec,/* in: record after which to insert */
|
||||
const byte* free_rec,/* in: record from which rec was
|
||||
allocated, or NULL */
|
||||
byte* rec, /* in: record to insert */
|
||||
dict_index_t* index, /* in: index of rec */
|
||||
const ulint* offsets)/* in: rec_get_offsets(rec) */
|
||||
{
|
||||
ulint n_dense;
|
||||
byte* slot_rec;
|
||||
byte* slot_free;
|
||||
|
||||
ut_ad(rec_offs_validate(rec, index, offsets));
|
||||
ut_ad(rec_offs_comp(offsets));
|
||||
ut_ad(prev_rec != rec);
|
||||
ut_ad(page_rec_get_next((rec_t*) prev_rec) == rec);
|
||||
|
||||
if (page_rec_is_infimum(prev_rec)) {
|
||||
/* Use the first slot. */
|
||||
slot_rec = page_zip->data + page_zip->size;
|
||||
} else {
|
||||
slot_rec = page_zip_dir_find(page_zip,
|
||||
ut_align_offset(prev_rec, UNIV_PAGE_SIZE));
|
||||
ut_a(slot_rec);
|
||||
}
|
||||
|
||||
/* Read the old n_dense (n_heap may have been incremented).
|
||||
Subtract 2 for the infimum and supremum records. */
|
||||
n_dense = page_dir_get_n_heap(page_zip->data) - 3;
|
||||
|
||||
if (UNIV_LIKELY_NULL(free_rec)) {
|
||||
/* The record was allocated from the free list.
|
||||
Shift the dense directory only up to that slot.
|
||||
Note that in this case, n_dense is actually
|
||||
off by one, because page_cur_insert_rec_low()
|
||||
did not increment n_heap. */
|
||||
ut_ad(rec_get_heap_no_new(rec) < n_dense + 1
|
||||
+ 2/* infimum and supremum */);
|
||||
ut_ad(rec >= free_rec);
|
||||
slot_free = page_zip_dir_find(page_zip,
|
||||
ut_align_offset(free_rec, UNIV_PAGE_SIZE));
|
||||
ut_ad(slot_free);
|
||||
slot_free += PAGE_ZIP_DIR_SLOT_SIZE;
|
||||
} else {
|
||||
/* The record was allocated from the heap.
|
||||
Shift the entire dense directory. */
|
||||
ut_ad(rec_get_heap_no_new(rec) == n_dense
|
||||
+ 2/* infimum and supremum */);
|
||||
|
||||
/* Shift to the end of the dense page directory. */
|
||||
slot_free = page_zip->data + page_zip->size
|
||||
- PAGE_ZIP_DIR_SLOT_SIZE * n_dense;
|
||||
}
|
||||
|
||||
/* Shift the dense directory to allocate place for rec. */
|
||||
memmove(slot_free - PAGE_ZIP_DIR_SLOT_SIZE, slot_free,
|
||||
slot_rec - slot_free);
|
||||
|
||||
/* Write the entry for the inserted record.
|
||||
The "owned" and "deleted" flags must be zero. */
|
||||
mach_write_to_2(slot_rec - PAGE_ZIP_DIR_SLOT_SIZE,
|
||||
ut_align_offset(rec, UNIV_PAGE_SIZE));
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
Shift the dense page directory and the array of BLOB pointers
|
||||
when a record is deleted. */
|
||||
|
|
Loading…
Reference in a new issue