diff options
Diffstat (limited to 'storage/xtradb/include/page0zip.ic')
-rw-r--r-- | storage/xtradb/include/page0zip.ic | 103 |
1 files changed, 86 insertions, 17 deletions
diff --git a/storage/xtradb/include/page0zip.ic b/storage/xtradb/include/page0zip.ic index e26fa3e3d94..6c7d8cd32c7 100644 --- a/storage/xtradb/include/page0zip.ic +++ b/storage/xtradb/include/page0zip.ic @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 2005, 2013, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2012, Facebook Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -11,8 +12,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., -51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA *****************************************************************************/ @@ -29,6 +30,7 @@ Created June 2005 by Marko Makela #endif #include "page0zip.h" +#include "mtr0log.h" #include "page0page.h" /* The format of compressed pages is as follows. @@ -120,13 +122,13 @@ page_zip_get_size( { ulint size; - if (UNIV_UNLIKELY(!page_zip->ssize)) { + if (!page_zip->ssize) { return(0); } - size = (PAGE_ZIP_MIN_SIZE >> 1) << page_zip->ssize; + size = (UNIV_ZIP_SIZE_MIN >> 1) << page_zip->ssize; - ut_ad(size >= PAGE_ZIP_MIN_SIZE); + ut_ad(size >= UNIV_ZIP_SIZE_MIN); ut_ad(size <= UNIV_PAGE_SIZE); return(size); @@ -174,13 +176,13 @@ page_zip_rec_needs_ext( ut_ad(ut_is_2pow(zip_size)); ut_ad(comp || !zip_size); -#if UNIV_PAGE_SIZE > REC_MAX_DATA_SIZE - if (UNIV_UNLIKELY(rec_size >= REC_MAX_DATA_SIZE)) { +#if UNIV_PAGE_SIZE_MAX > REC_MAX_DATA_SIZE + if (rec_size >= REC_MAX_DATA_SIZE) { return(TRUE); } #endif - if (UNIV_UNLIKELY(zip_size)) { + if (zip_size) { ut_ad(comp); /* On a compressed page, there is a two-byte entry in the dense page directory for every record. But there @@ -209,7 +211,7 @@ page_zip_simple_validate( { ut_ad(page_zip); ut_ad(page_zip->data); - ut_ad(page_zip->ssize < PAGE_ZIP_NUM_SSIZE); + ut_ad(page_zip->ssize <= PAGE_ZIP_SSIZE_MAX); ut_ad(page_zip_get_size(page_zip) > PAGE_DATA + PAGE_ZIP_DIR_SLOT_SIZE); ut_ad(page_zip->m_start <= page_zip->m_end); @@ -236,11 +238,11 @@ page_zip_get_trailer_len( ut_ad(page_zip_simple_validate(page_zip)); UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip)); - if (UNIV_UNLIKELY(!page_is_leaf(page_zip->data))) { + if (!page_is_leaf(page_zip->data)) { uncompressed_size = PAGE_ZIP_DIR_SLOT_SIZE + REC_NODE_PTR_SIZE; ut_ad(!page_zip->n_blobs); - } else if (UNIV_UNLIKELY(is_clust)) { + } else if (is_clust) { uncompressed_size = PAGE_ZIP_DIR_SLOT_SIZE + DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN; } else { @@ -305,7 +307,7 @@ page_zip_available( space needed for identifying the record (encoded heap_no). */ length -= REC_N_NEW_EXTRA_BYTES - 2; - if (UNIV_UNLIKELY(create)) { + if (create > 0) { /* When a record is created, a pointer may be added to the dense directory. Likewise, space for the columns that will not be @@ -316,10 +318,8 @@ page_zip_available( trailer_len += PAGE_ZIP_DIR_SLOT_SIZE; } - return(UNIV_LIKELY(length - + trailer_len - + page_zip->m_end - < page_zip_get_size(page_zip))); + return(length + trailer_len + page_zip->m_end + < page_zip_get_size(page_zip)); } /**********************************************************************//** @@ -374,13 +374,82 @@ page_zip_write_header( /* The following would fail in page_cur_insert_rec_zip(). */ /* ut_ad(page_zip_validate(page_zip, str - pos)); */ - if (UNIV_LIKELY_NULL(mtr)) { + if (mtr) { #ifndef UNIV_HOTBACKUP page_zip_write_header_log(str, length, mtr); #endif /* !UNIV_HOTBACKUP */ } } +/**********************************************************************//** +Write a log record of compressing an index page without the data on the page. */ +UNIV_INLINE +void +page_zip_compress_write_log_no_data( +/*================================*/ + ulint level, /*!< in: compression level */ + const page_t* page, /*!< in: page that is compressed */ + dict_index_t* index, /*!< in: index */ + mtr_t* mtr) /*!< in: mtr */ +{ + byte* log_ptr = mlog_open_and_write_index( + mtr, page, index, MLOG_ZIP_PAGE_COMPRESS_NO_DATA, 1); + + if (log_ptr) { + mach_write_to_1(log_ptr, level); + mlog_close(mtr, log_ptr + 1); + } +} + +/**********************************************************************//** +Parses a log record of compressing an index page without the data. +@return end of log record or NULL */ +UNIV_INLINE +byte* +page_zip_parse_compress_no_data( +/*============================*/ + byte* ptr, /*!< in: buffer */ + byte* end_ptr, /*!< in: buffer end */ + page_t* page, /*!< in: uncompressed page */ + page_zip_des_t* page_zip, /*!< out: compressed page */ + dict_index_t* index) /*!< in: index */ +{ + ulint level; + if (end_ptr == ptr) { + return(NULL); + } + + level = mach_read_from_1(ptr); + + /* If page compression fails then there must be something wrong + because a compress log record is logged only if the compression + was successful. Crash in this case. */ + + if (page + && !page_zip_compress(page_zip, page, index, level, NULL)) { + ut_error; + } + + return(ptr + 1); +} + +/**********************************************************************//** +Reset the counters used for filling +INFORMATION_SCHEMA.innodb_cmp_per_index. */ +UNIV_INLINE +void +page_zip_reset_stat_per_index() +/*===========================*/ +{ + mutex_enter(&page_zip_stat_per_index_mutex); + + page_zip_stat_per_index.erase( + page_zip_stat_per_index.begin(), + page_zip_stat_per_index.end()); + + mutex_exit(&page_zip_stat_per_index_mutex); +} + #ifdef UNIV_MATERIALIZE # undef UNIV_INLINE # define UNIV_INLINE UNIV_INLINE_ORIGINAL |