mirror of
https://github.com/MariaDB/server.git
synced 2025-12-13 20:03:16 +03:00
branches/zip: Move some private functions from page0zip.ic and page0zip.h
to page0zip.c.
This commit is contained in:
@@ -84,67 +84,6 @@ page_zip_validate(
|
||||
__attribute__((nonnull));
|
||||
#endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */
|
||||
|
||||
/*****************************************************************
|
||||
Gets the size of the compressed page trailer (the dense page directory),
|
||||
including deleted records (the free list). */
|
||||
UNIV_INLINE
|
||||
ulint
|
||||
page_zip_dir_size(
|
||||
/*==============*/
|
||||
/* out: length of dense page
|
||||
directory, in bytes */
|
||||
const page_zip_des_t* page_zip) /* in: compressed page */
|
||||
__attribute__((pure));
|
||||
/*****************************************************************
|
||||
Gets the size of the compressed page trailer (the dense page directory),
|
||||
only including user records (excluding the free list). */
|
||||
UNIV_INLINE
|
||||
ulint
|
||||
page_zip_dir_user_size(
|
||||
/*===================*/
|
||||
/* out: length of dense page
|
||||
directory, in bytes */
|
||||
const page_zip_des_t* page_zip) /* in: compressed page */
|
||||
__attribute__((pure));
|
||||
|
||||
/*****************************************************************
|
||||
Find the slot of the given non-free record in the dense page directory. */
|
||||
UNIV_INLINE
|
||||
byte*
|
||||
page_zip_dir_find(
|
||||
/*==============*/
|
||||
/* out: dense directory slot,
|
||||
or NULL if record not found */
|
||||
page_zip_des_t* page_zip, /* in: compressed page */
|
||||
ulint offset) /* in: offset of user record */
|
||||
__attribute__((pure));
|
||||
/*****************************************************************
|
||||
Find the slot of the given free record in the dense page directory. */
|
||||
UNIV_INLINE
|
||||
byte*
|
||||
page_zip_dir_find_free(
|
||||
/*===================*/
|
||||
/* out: dense directory slot,
|
||||
or NULL if record not found */
|
||||
page_zip_des_t* page_zip, /* in: compressed page */
|
||||
ulint offset) /* in: offset of user record */
|
||||
__attribute__((pure));
|
||||
/*****************************************************************
|
||||
Read a given slot in the dense page directory. */
|
||||
UNIV_INLINE
|
||||
ulint
|
||||
page_zip_dir_get(
|
||||
/*=============*/
|
||||
/* out: record offset
|
||||
on the uncompressed page,
|
||||
possibly ORed with
|
||||
PAGE_ZIP_DIR_SLOT_DEL or
|
||||
PAGE_ZIP_DIR_SLOT_OWNED */
|
||||
const page_zip_des_t* page_zip, /* in: compressed page */
|
||||
ulint slot) /* in: slot
|
||||
(0=first user record) */
|
||||
__attribute__((pure));
|
||||
|
||||
/**************************************************************************
|
||||
Ensure that enough space is available in the modification log.
|
||||
If not, try to compress the page. */
|
||||
|
||||
@@ -140,122 +140,6 @@ page_zip_simple_validate(
|
||||
}
|
||||
#endif /* UNIV_DEBUG */
|
||||
|
||||
/*****************************************************************
|
||||
Gets the size of the compressed page trailer (the dense page directory),
|
||||
including deleted records (the free list). */
|
||||
UNIV_INLINE
|
||||
ulint
|
||||
page_zip_dir_size(
|
||||
/*==============*/
|
||||
/* out: length of dense page
|
||||
directory, in bytes */
|
||||
const page_zip_des_t* page_zip) /* in: compressed page */
|
||||
{
|
||||
/* 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) - 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). */
|
||||
UNIV_INLINE
|
||||
ulint
|
||||
page_zip_dir_user_size(
|
||||
/*===================*/
|
||||
/* out: length of dense page
|
||||
directory comprising existing
|
||||
records, in bytes */
|
||||
const page_zip_des_t* page_zip) /* in: compressed page */
|
||||
{
|
||||
ulint size = PAGE_ZIP_DIR_SLOT_SIZE
|
||||
* page_get_n_recs((page_t*) page_zip->data);
|
||||
ut_ad(size < page_zip_dir_size(page_zip));
|
||||
return(size);
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
Find the slot of the given non-free record in the dense page directory. */
|
||||
UNIV_INLINE
|
||||
byte*
|
||||
page_zip_dir_find(
|
||||
/*==============*/
|
||||
/* out: dense directory slot,
|
||||
or NULL if record not found */
|
||||
page_zip_des_t* page_zip, /* in: compressed page */
|
||||
ulint offset) /* in: offset of user record */
|
||||
{
|
||||
byte* slot;
|
||||
byte* end;
|
||||
|
||||
ut_ad(page_zip_simple_validate(page_zip));
|
||||
|
||||
end = page_zip->data + page_zip->size - PAGE_ZIP_DIR_SLOT_SIZE;
|
||||
slot = end - page_zip_dir_user_size(page_zip);
|
||||
|
||||
for (; slot < end; slot += PAGE_ZIP_DIR_SLOT_SIZE) {
|
||||
if ((mach_read_from_2(slot) & PAGE_ZIP_DIR_SLOT_MASK)
|
||||
== offset) {
|
||||
return(slot);
|
||||
}
|
||||
}
|
||||
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
Find the slot of the given free record in the dense page directory. */
|
||||
UNIV_INLINE
|
||||
byte*
|
||||
page_zip_dir_find_free(
|
||||
/*===================*/
|
||||
/* out: dense directory slot,
|
||||
or NULL if record not found */
|
||||
page_zip_des_t* page_zip, /* in: compressed page */
|
||||
ulint offset) /* in: offset of user record */
|
||||
{
|
||||
byte* slot;
|
||||
byte* end;
|
||||
|
||||
ut_ad(page_zip_simple_validate(page_zip));
|
||||
|
||||
slot = end = page_zip->data + page_zip->size;
|
||||
slot -= page_zip_dir_size(page_zip);
|
||||
end -= PAGE_ZIP_DIR_SLOT_SIZE + page_zip_dir_user_size(page_zip);
|
||||
|
||||
for (; slot < end; slot += PAGE_ZIP_DIR_SLOT_SIZE) {
|
||||
if ((mach_read_from_2(slot) & PAGE_ZIP_DIR_SLOT_MASK)
|
||||
== offset) {
|
||||
return(slot);
|
||||
}
|
||||
}
|
||||
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
Read a given slot in the dense page directory. */
|
||||
UNIV_INLINE
|
||||
ulint
|
||||
page_zip_dir_get(
|
||||
/*=============*/
|
||||
/* out: record offset
|
||||
on the uncompressed page,
|
||||
possibly ORed with
|
||||
PAGE_ZIP_DIR_SLOT_DEL or
|
||||
PAGE_ZIP_DIR_SLOT_OWNED */
|
||||
const page_zip_des_t* page_zip, /* in: compressed page */
|
||||
ulint slot) /* in: slot
|
||||
(0=first user record) */
|
||||
{
|
||||
ut_ad(page_zip_simple_validate(page_zip));
|
||||
ut_ad(slot < page_zip_dir_size(page_zip) / PAGE_ZIP_DIR_SLOT_SIZE);
|
||||
return(mach_read_from_2(page_zip->data + page_zip->size
|
||||
- PAGE_ZIP_DIR_SLOT_SIZE * (slot + 1)));
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
Ensure that enough space is available in the modification log.
|
||||
If not, try to compress the page. */
|
||||
|
||||
116
page/page0zip.c
116
page/page0zip.c
@@ -43,6 +43,122 @@ static const byte supremum_extra_data[] = {
|
||||
0x65, 0x6d, 0x75, 0x6d /* "supremum" */
|
||||
};
|
||||
|
||||
/*****************************************************************
|
||||
Gets the size of the compressed page trailer (the dense page directory),
|
||||
including deleted records (the free list). */
|
||||
UNIV_INLINE
|
||||
ulint
|
||||
page_zip_dir_size(
|
||||
/*==============*/
|
||||
/* out: length of dense page
|
||||
directory, in bytes */
|
||||
const page_zip_des_t* page_zip) /* in: compressed page */
|
||||
{
|
||||
/* 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) - 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). */
|
||||
UNIV_INLINE
|
||||
ulint
|
||||
page_zip_dir_user_size(
|
||||
/*===================*/
|
||||
/* out: length of dense page
|
||||
directory comprising existing
|
||||
records, in bytes */
|
||||
const page_zip_des_t* page_zip) /* in: compressed page */
|
||||
{
|
||||
ulint size = PAGE_ZIP_DIR_SLOT_SIZE
|
||||
* page_get_n_recs((page_t*) page_zip->data);
|
||||
ut_ad(size < page_zip_dir_size(page_zip));
|
||||
return(size);
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
Find the slot of the given non-free record in the dense page directory. */
|
||||
UNIV_INLINE
|
||||
byte*
|
||||
page_zip_dir_find(
|
||||
/*==============*/
|
||||
/* out: dense directory slot,
|
||||
or NULL if record not found */
|
||||
page_zip_des_t* page_zip, /* in: compressed page */
|
||||
ulint offset) /* in: offset of user record */
|
||||
{
|
||||
byte* slot;
|
||||
byte* end;
|
||||
|
||||
ut_ad(page_zip_simple_validate(page_zip));
|
||||
|
||||
end = page_zip->data + page_zip->size - PAGE_ZIP_DIR_SLOT_SIZE;
|
||||
slot = end - page_zip_dir_user_size(page_zip);
|
||||
|
||||
for (; slot < end; slot += PAGE_ZIP_DIR_SLOT_SIZE) {
|
||||
if ((mach_read_from_2(slot) & PAGE_ZIP_DIR_SLOT_MASK)
|
||||
== offset) {
|
||||
return(slot);
|
||||
}
|
||||
}
|
||||
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
Find the slot of the given free record in the dense page directory. */
|
||||
UNIV_INLINE
|
||||
byte*
|
||||
page_zip_dir_find_free(
|
||||
/*===================*/
|
||||
/* out: dense directory slot,
|
||||
or NULL if record not found */
|
||||
page_zip_des_t* page_zip, /* in: compressed page */
|
||||
ulint offset) /* in: offset of user record */
|
||||
{
|
||||
byte* slot;
|
||||
byte* end;
|
||||
|
||||
ut_ad(page_zip_simple_validate(page_zip));
|
||||
|
||||
slot = end = page_zip->data + page_zip->size;
|
||||
slot -= page_zip_dir_size(page_zip);
|
||||
end -= PAGE_ZIP_DIR_SLOT_SIZE + page_zip_dir_user_size(page_zip);
|
||||
|
||||
for (; slot < end; slot += PAGE_ZIP_DIR_SLOT_SIZE) {
|
||||
if ((mach_read_from_2(slot) & PAGE_ZIP_DIR_SLOT_MASK)
|
||||
== offset) {
|
||||
return(slot);
|
||||
}
|
||||
}
|
||||
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
Read a given slot in the dense page directory. */
|
||||
UNIV_INLINE
|
||||
ulint
|
||||
page_zip_dir_get(
|
||||
/*=============*/
|
||||
/* out: record offset
|
||||
on the uncompressed page,
|
||||
possibly ORed with
|
||||
PAGE_ZIP_DIR_SLOT_DEL or
|
||||
PAGE_ZIP_DIR_SLOT_OWNED */
|
||||
const page_zip_des_t* page_zip, /* in: compressed page */
|
||||
ulint slot) /* in: slot
|
||||
(0=first user record) */
|
||||
{
|
||||
ut_ad(page_zip_simple_validate(page_zip));
|
||||
ut_ad(slot < page_zip_dir_size(page_zip) / PAGE_ZIP_DIR_SLOT_SIZE);
|
||||
return(mach_read_from_2(page_zip->data + page_zip->size
|
||||
- PAGE_ZIP_DIR_SLOT_SIZE * (slot + 1)));
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
Encode the length of a fixed-length column. */
|
||||
static
|
||||
|
||||
Reference in New Issue
Block a user