函数 xdes_get_descriptor_with_space_hdr
获得区描述符 xdes entry 的offset
/********************************************************************//**
Gets pointer to a the extent descriptor of a page. The page where the extent
descriptor resides is x-locked. This function no longer extends the data
file.
@return pointer to the extent descriptor, NULL if the page does not
exist in the space or if the offset is >= the free limit */
UNIV_INLINE __attribute__((nonnull, warn_unused_result))
xdes_t*
xdes_get_descriptor_with_space_hdr(
/*===============================*/
fsp_header_t* sp_header, /*!< in/out: space header, x-latched
in mtr */
ulint space, /*!< in: space id */
ulint offset, /*!< in: page offset; if equal
to the free limit, we try to
add new extents to the space
free list */
mtr_t* mtr) /*!< in/out: mini-transaction */
{
ulint limit;
ulint size;
ulint zip_size;
ulint descr_page_no;
page_t* descr_page;
ut_ad(mtr_memo_contains(mtr, fil_space_get_latch(space, NULL),MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains_page(mtr, sp_header, MTR_MEMO_PAGE_X_FIX));
ut_ad(page_offset(sp_header) == FSP_HEADER_OFFSET);
/* Read free limit and space size */
limit = mach_read_from_4(sp_header + FSP_FREE_LIMIT);
size = mach_read_from_4(sp_header + FSP_SIZE);
zip_size = dict_table_flags_to_zip_size(mach_read_from_4(sp_header + FSP_SPACE_FLAGS));
if ((offset >= size) || (offset >= limit)) {
return(NULL);
}
/** *计算出xdes entry 所在的页号, * 0 % 16328 = 0 * 64 % 16328 = 64 * 128 % 16328 = 128 * 192 % 16328 = 192 *每个xdes页中含有256个xdes entry,每个xdesc 页是16K,给定一个offset,该值为0 可计算出它属于第几个xdes 页 */
descr_page_no = xdes_calc_descriptor_page(zip_size, offset);//详见) {
/* It is on the space header page */
descr_page = page_align(sp_header); //详见
} else { /** *如果descr_page_no非0,则根据这个编号,buf_pool->page_hash中查找 *查找条件为page->offset == descr_page_no,否则继续查找 */
buf_block_t* block;
block = buf_page_get(space, zip_size, descr_page_no,RW_X_LATCH, mtr);
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
descr_page = buf_block_get_frame(block);
}
//XDES_ADR_OFFSET 计算后是38+112=150字节,第index个XDES Entry入口
return(descr_page + XDES_ARR_OFFSET + XDES_SIZE * xdes_calc_descriptor_index(zip_size, offset));
}
#define XDES_ARR_OFFSET (FSP_HEADER_OFFSET + FSP_HEADER_SIZE) #define FSP_HEADER_OFFSET FIL_PAGE_DATA #define FIL_PAGE_DATA 38 /* File space header size */ #define FSP_HEADER_SIZE (32 + 5 * FLST_BASE_NODE_SIZE) /* The physical size of a list base node in bytes */ #define FLST_BASE_NODE_SIZE (4 + 2 * FIL_ADDR_SIZE) #define FIL_ADDR_SIZE 6 /* address size is 6 bytes */
http://blog.itpub.net/15480802/viewspace-777332/

#define XDES_SIZE \
(XDES_BITMAP + UT_BITS_IN_BYTES(FSP_EXTENT_SIZE * XDES_BITS_PER_PAGE))
(*+) + UT_BITS_IN_BYTES(*)
#define XDES_BITMAP (FLST_NODE_SIZE + 12)
#define FLST_NODE_SIZE (2 * FIL_ADDR_SIZE) /* The physical size of a list node in bytes */
#define FIL_ADDR_SIZE 6 /* address size is 6 bytes */
/** File space extent size (one megabyte) in pages */
#define FSP_EXTENT_SIZE (1 << (20 - UNIV_PAGE_SIZE_SHIFT))
#define UNIV_PAGE_SIZE_SHIFT 14
#define XDES_BITS_PER_PAGE 2 /* How many bits are there per page */
/** Determine how many bytes (groups of 8 bits) are needed to
store the given number of bits.
@param b in: bits
@return number of bytes (octets) needed to represent b */
#define UT_BITS_IN_BYTES(b) (((b) + 7) / 8)
/********************************************************************//**
Calculates the descriptor index within a descriptor page.
@return descriptor index */
UNIV_INLINE
ulint
xdes_calc_descriptor_index(
/*=======================*/
ulint zip_size, /*!< in: compressed page size in bytes;
0 for uncompressed pages */
ulint offset) /*!< in: page offset */
{
ut_ad(ut_is_2pow(zip_size));
if (!zip_size) {
return(ut_2pow_remainder(offset, UNIV_PAGE_SIZE)
/ FSP_EXTENT_SIZE);
} else {
return(ut_2pow_remainder(offset, zip_size) / FSP_EXTENT_SIZE);
}
}
面的大小 16K== ^
/* The universal page size of the database */
#define UNIV_PAGE_SIZE (1 << UNIV_PAGE_SIZE_SHIFT)
/* The 2-logarithm of UNIV_PAGE_SIZE: */
#define UNIV_PAGE_SIZE_SHIFT 14
/*************************************************************//**
Calculates fast the remainder of n/m when m is a power of two.
@param n in: numerator
@param m in: denominator, must be a power of two
@return the remainder of n/m
求余数,m必须为2的幂数
*/
#define ut_2pow_remainder(n, m) ((n) & ((m) - 1))
/********************************************************************//**
Calculates the page where the descriptor of a page resides.
@return descriptor page offset */
UNIV_INLINE
ulint
xdes_calc_descriptor_page(
/*======================*/
ulint zip_size, /*!< in: compressed page size in bytes;
0 for uncompressed pages */
ulint offset) /*!< in: page offset */
{
ut_ad(ut_is_2pow(zip_size));
if (!zip_size) { //计算出2^14=16384*N 不超过offset,但N为最大
return(ut_2pow_round(offset, UNIV_PAGE_SIZE));
} else {
ut_ad(zip_size > XDES_ARR_OFFSET + (zip_size / FSP_EXTENT_SIZE) * XDES_SIZE);
return(ut_2pow_round(offset, zip_size));
}
}
函数 xdes_get_descriptor_with_space_hdr的更多相关文章
- Python 小而美的函数
python提供了一些有趣且实用的函数,如any all zip,这些函数能够大幅简化我们得代码,可以更优雅的处理可迭代的对象,同时使用的时候也得注意一些情况 any any(iterable) ...
- 探究javascript对象和数组的异同,及函数变量缓存技巧
javascript中最经典也最受非议的一句话就是:javascript中一切皆是对象.这篇重点要提到的,就是任何jser都不陌生的Object和Array. 有段时间曾经很诧异,到底两种数据类型用来 ...
- JavaScript权威指南 - 函数
函数本身就是一段JavaScript代码,定义一次但可能被调用任意次.如果函数挂载在一个对象上,作为对象的一个属性,通常这种函数被称作对象的方法.用于初始化一个新创建的对象的函数被称作构造函数. 相对 ...
- C++对C的函数拓展
一,内联函数 1.内联函数的概念 C++中的const常量可以用来代替宏常数的定义,例如:用const int a = 10来替换# define a 10.那么C++中是否有什么解决方案来替代宏代码 ...
- 菜鸟Python学习笔记第一天:关于一些函数库的使用
2017年1月3日 星期二 大一学习一门新的计算机语言真的很难,有时候连函数拼写出错查错都能查半天,没办法,谁让我英语太渣. 关于计算机语言的学习我想还是从C语言学习开始为好,Python有很多语言的 ...
- javascript中的this与函数讲解
前言 javascript中没有块级作用域(es6以前),javascript中作用域分为函数作用域和全局作用域.并且,大家可以认为全局作用域其实就是Window函数的函数作用域,我们编写的js代码, ...
- 复杂的 Hash 函数组合有意义吗?
很久以前看到一篇文章,讲某个大网站储存用户口令时,会经过十分复杂的处理.怎么个复杂记不得了,大概就是先 Hash,结果加上一些特殊字符再 Hash,结果再加上些字符.再倒序.再怎么怎么的.再 Hash ...
- JS核心系列:浅谈函数的作用域
一.作用域(scope) 所谓作用域就是:变量在声明它们的函数体以及这个函数体嵌套的任意函数体内都是有定义的. function scope(){ var foo = "global&quo ...
- C++中的时间函数
C++获取时间函数众多,何时该用什么函数,拿到的是什么时间?该怎么用?很多人都会混淆. 本文是本人经历了几款游戏客户端和服务器开发后,对游戏中时间获取的一点总结. 最早学习游戏客户端时,为了获取最精确 ...
随机推荐
- what are Datatypes in SQLite supporting android
As said at Datatypes In SQLite Version 3: Datatypes In SQLite Version 3 Most SQL database engines (e ...
- Notes of the scrum meeting(2013/10/20)
软工项目组buaa_smile确定自由项目主题及实现功能的scrum meeting meeting time:7:30~9:00p.m.,October 20th,2013 meeting plac ...
- 一个inline-block的样式。
<span style="height: 31px; font-family: 宋体; font-weight: bold; color: rgb(160, 64, 0); text- ...
- android编程常见问题-程序在模拟器中不显示
新手编程常见问题: 问题表现:程序运行成功,但是在模拟器中不显示 解决办法:检查项目版本和模拟器版本是否匹配或兼容,如果不匹配,选择和模拟器版本一致 项目版本:右键-Properties-androi ...
- asp.net asp:TextBox控件绑定值后,获取不到新值问题解决方法
把Page_Load里绑定的代码放在 if(!IsPostBack){}里面后,即可获取到更新的值. 意思为第一次加载执行.
- eclipse中加放js文件报js语法错误解决办法
1) eclipse设置 window->preference-> JavaScript -> Validator->Errors/Warnings->E ...
- 【UVA】【11762】Race to 1(得到1)
数学期望/马尔可夫过程 DP/记忆化搜索 刘汝佳老师白书上的例题…… //UVA 11762 #include<vector> #include<cstdio> #includ ...
- C编程实现2的1000次方(使程序中的n=1000即可)
#include<stdio.h> #include<malloc.h> void double_(int n) { ,j,s,jw=; p=(int *)malloc(siz ...
- c#操作剪切板
C#定义了一个类System.Windows.Forms.Clipboard来简化剪切板操作,这个类有一个静态方法,主要有: Clear 清除剪切板中的所有数据: ContainsData,Conta ...
- JsRender系列demo(5) for else
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...