函数 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++获取时间函数众多,何时该用什么函数,拿到的是什么时间?该怎么用?很多人都会混淆. 本文是本人经历了几款游戏客户端和服务器开发后,对游戏中时间获取的一点总结. 最早学习游戏客户端时,为了获取最精确 ...
随机推荐
- 视频FMS服务器带宽成本分析
一.现状 调查了一下,主要有两种主流方式,WebRTC或者Flash. 1. WebRTC(不支持IE浏览器,已排除):网页实时通信(英语:Web Real-Time Communication)的缩 ...
- 3157: 国王奇遇记 & 3516: 国王奇遇记加强版 - BZOJ
果然我数学不行啊,题解君: http://www.cnblogs.com/zhuohan123/p/3726933.html const h=; var fac,facinv,powm,s:..]of ...
- 【技术贴】解决MySql连接不上 ip远程连接Host is not allowed to conn
落雨 如果你想连接远程IP的mysql的时候发生这个错误: ERROR 1130: Host '192.168.1.3' is not allowed to connect to this MySQL ...
- nginx模块开发(18)—日志分析
1.日志简介 nginx日志主要有两种:访问日志和错误日志.访问日志主要记录客户端访问nginx的每一个请求,格式可以自定义:错误日志主要记录客户端访问nginx出错时的日志,格式不支持自定义.两种日 ...
- [转载]Spring Autowire自动装配介绍
转自: http://www.cnblogs.com/zhishan/p/3190757.html 在应用中,我们常常使用<ref>标签为JavaBean注入它依赖的对象.但是对于一个大型 ...
- ZOJ1232 Adventure of Super Mario spfa上的dp
很早之前听说有一种dp是在图上的dp,然后是在跑SPFA的时候进行dp,所以特地找了一题关于在SPFA的时候dp的. 题意:1~a是村庄 a+1~a+b是城堡,存在m条无向边.求由a+b->1的 ...
- POJ3250Bad Hair Day
http://poj.org/problem?id=3250 题意 : n个牛排成一列向右看,牛 i 能看到牛 j 的头顶,当且仅当牛 j 在牛 i 的右边并且牛 i 与牛 j 之间的所有牛均比牛 ...
- hdu 4599 Dice 概率DP
思路: 1.求f[n];dp[i]表示i个连续相同时的期望 则 dp[0]=1+dp[1] dp[1]=1+(5dp[1]+dp[2])/6 …… dp[i]=1+(5dp[1 ...
- [SQL Server系] -- 视图
1:定义 从用户角度来看,一个视图是从一个特定的角度来查看数据库中的数据. 从数据库系统内部来看,一个视图是由SELECT语句组成的查询定义的虚拟表. 从数据库系统内部来看,视图是由一张或多张表中的数 ...
- httpclient发送multipart/form-data类型参数和用MultipartRequest接收参数
一.利用HttpClient发送基于Content-Type="multipart/form-data"形式的表单 package com.test.httpclient; imp ...