Commit 2a8f49bf authored by marko's avatar marko

branches/zip: page_cur_insert_rec_low(): Replace page_zip_alloc()

with page_zip_available() in order to avoid an extra page_zip_compress().

page_zip_available(): Make the function public.

page0zip.ic: Sort the inline function declarations in order to avoid
forward references, which do not work on some compilers.
parent 03760f4c
...@@ -81,6 +81,22 @@ page_zip_validate( ...@@ -81,6 +81,22 @@ page_zip_validate(
__attribute__((nonnull)); __attribute__((nonnull));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
/**************************************************************************
Determine if enough space is available for a page_zip_write_rec() call
in the modification log. */
UNIV_INLINE
ibool
page_zip_available(
/*===============*/
/* out: TRUE if page_zip_write_rec()
will succeed */
const page_zip_des_t* page_zip,/* in: compressed page */
dict_index_t* index, /* in: index of the B-tree node */
ulint length, /* in: combined size of the record */
ulint create) /* in: nonzero=add the record to
the heap */
__attribute__((warn_unused_result, nonnull, pure));
/************************************************************************** /**************************************************************************
Ensure that enough space is available in the modification log. Ensure that enough space is available in the modification log.
If not, try to compress the page. */ If not, try to compress the page. */
......
...@@ -92,34 +92,6 @@ In summary, the compressed page looks like this: ...@@ -92,34 +92,6 @@ In summary, the compressed page looks like this:
/* 'deleted' flag */ /* 'deleted' flag */
#define PAGE_ZIP_DIR_SLOT_DEL 0x8000 #define PAGE_ZIP_DIR_SLOT_DEL 0x8000
/**************************************************************************
Determine if enough space is available for a page_zip_write_rec() call
in the modification log. */
UNIV_INLINE
ibool
page_zip_available(
/*===============*/
/* out: TRUE if page_zip_write_rec()
will succeed */
const page_zip_des_t* page_zip,/* in: compressed page */
dict_index_t* index, /* in: index of the B-tree node */
ulint length, /* in: combined size of the record */
ulint create) /* in: nonzero=add the record to
the heap */
__attribute__((warn_unused_result, nonnull, pure));
/**************************************************************************
Initialize a compressed page descriptor. */
UNIV_INLINE
void
page_zip_des_init(
/*==============*/
page_zip_des_t* page_zip) /* in/out: compressed page
descriptor */
{
memset(page_zip, 0, sizeof *page_zip);
}
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
/************************************************************************** /**************************************************************************
Validate a compressed page descriptor. */ Validate a compressed page descriptor. */
...@@ -142,47 +114,6 @@ page_zip_simple_validate( ...@@ -142,47 +114,6 @@ page_zip_simple_validate(
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
/**************************************************************************
Ensure that enough space is available in the modification log.
If not, try to compress the page. */
UNIV_INLINE
ibool
page_zip_alloc(
/*===========*/
/* out: TRUE if enough space is available */
page_zip_des_t* page_zip,/* in/out: compressed page;
will only be modified if compression is needed
and successful */
const page_t* page, /* in: uncompressed page */
dict_index_t* index, /* in: index of the B-tree node */
ulint length, /* in: combined size of the record */
ulint create, /* in: nonzero=add the record to the heap */
mtr_t* mtr) /* in: mini-transaction, or NULL */
{
ut_ad(page_is_comp((page_t*) page));
#ifdef UNIV_ZIP_DEBUG
ut_a(page_zip_validate(page_zip, page));
#endif /* UNIV_ZIP_DEBUG */
if (page_zip_available(page_zip, index, length, create)) {
return(TRUE);
}
if (page_zip->m_start == page_zip->m_end) {
/* The page has been freshly compressed, so
recompressing it will not help. */
return(FALSE);
}
if (!page_zip_compress(page_zip, page, index, mtr)) {
/* Unable to compress the page */
return(FALSE);
}
/* Check if there is enough space available after compression. */
return(page_zip_available(page_zip, index, length, create));
}
/************************************************************************** /**************************************************************************
Determine if the length of the page trailer. */ Determine if the length of the page trailer. */
UNIV_INLINE UNIV_INLINE
...@@ -264,6 +195,59 @@ page_zip_available( ...@@ -264,6 +195,59 @@ page_zip_available(
< page_zip->size)); < page_zip->size));
} }
/**************************************************************************
Initialize a compressed page descriptor. */
UNIV_INLINE
void
page_zip_des_init(
/*==============*/
page_zip_des_t* page_zip) /* in/out: compressed page
descriptor */
{
memset(page_zip, 0, sizeof *page_zip);
}
/**************************************************************************
Ensure that enough space is available in the modification log.
If not, try to compress the page. */
UNIV_INLINE
ibool
page_zip_alloc(
/*===========*/
/* out: TRUE if enough space is available */
page_zip_des_t* page_zip,/* in/out: compressed page;
will only be modified if compression is needed
and successful */
const page_t* page, /* in: uncompressed page */
dict_index_t* index, /* in: index of the B-tree node */
ulint length, /* in: combined size of the record */
ulint create, /* in: nonzero=add the record to the heap */
mtr_t* mtr) /* in: mini-transaction, or NULL */
{
ut_ad(page_is_comp((page_t*) page));
#ifdef UNIV_ZIP_DEBUG
ut_a(page_zip_validate(page_zip, page));
#endif /* UNIV_ZIP_DEBUG */
if (page_zip_available(page_zip, index, length, create)) {
return(TRUE);
}
if (page_zip->m_start == page_zip->m_end) {
/* The page has been freshly compressed, so
recompressing it will not help. */
return(FALSE);
}
if (!page_zip_compress(page_zip, page, index, mtr)) {
/* Unable to compress the page */
return(FALSE);
}
/* Check if there is enough space available after compression. */
return(page_zip_available(page_zip, index, length, create));
}
/************************************************************************** /**************************************************************************
Write a log record of writing to the uncompressed header portion of a page. */ Write a log record of writing to the uncompressed header portion of a page. */
......
...@@ -926,7 +926,7 @@ page_cur_insert_rec_low( ...@@ -926,7 +926,7 @@ page_cur_insert_rec_low(
/* 2. Try to find suitable space from page memory management */ /* 2. Try to find suitable space from page memory management */
if (UNIV_LIKELY_NULL(page_zip) if (UNIV_LIKELY_NULL(page_zip)
&& !page_zip_alloc(page_zip, page, index, rec_size, 1, mtr)) { && !page_zip_available(page_zip, index, rec_size, 1)) {
/* Try compressing the whole page afterwards. */ /* Try compressing the whole page afterwards. */
page_zip = NULL; page_zip = NULL;
......
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