函数xdes_find_bit
使用方法
free = xdes_find_bit(descr, XDES_FREE_BIT, TRUE,hint % FSP_EXTENT_SIZE, mtr);
/**********************************************************************//** Looks for a descriptor bit having the desired value. Starts from hint and scans upward; at the end of the extent the search is wrapped to the start of the extent. @return bit index of the bit, ULINT_UNDEFINED if not found */ UNIV_INLINE ulint xdes_find_bit( /*==========*/ xdes_t* descr, /*!< in: descriptor */ ulint bit, /*!< in: XDES_FREE_BIT or XDES_CLEAN_BIT */ // 0 or 1 ibool val, /*!< in: desired bit value */ ulint hint, /*!< in: hint of which bit position would be desirable */ mtr_t* mtr) /*!< in: mtr */ { ulint i; ut_ad(descr && mtr); ut_ad(val <= TRUE); ut_ad(hint < FSP_EXTENT_SIZE); ut_ad(mtr_memo_contains_page(mtr, descr, MTR_MEMO_PAGE_X_FIX)); for (i = hint; i < FSP_EXTENT_SIZE; i++) { //宏 #define FSP_EXTENT_SIZE (1 << (20 - UNIV_PAGE_SIZE_SHIFT)) 为1<<(20-14) if (val == xdes_get_bit(descr, bit, i, mtr)) { return(i); } } ; i < hint; i++) { if (val == xdes_get_bit(descr, bit, i, mtr)) { return(i); } } return(ULINT_UNDEFINED); }
/**********************************************************************//** Gets a descriptor bit of a page. @return TRUE if free */ UNIV_INLINE ibool xdes_get_bit( /*=========*/ const xdes_t* descr, /*!< in: descriptor */ ulint bit, /*!< in: XDES_FREE_BIT or XDES_CLEAN_BIT */ // 0 or 1 ulint offset, /*!< in: page offset within extent: 0 ... FSP_EXTENT_SIZE - 1 */ mtr_t* mtr) /*!< in: mtr */ { ulint index; ulint byte_index; ulint bit_index; ut_ad(mtr_memo_contains_page(mtr, descr, MTR_MEMO_PAGE_X_FIX)); ut_ad((bit == XDES_FREE_BIT) || (bit == XDES_CLEAN_BIT)); ut_ad(offset < FSP_EXTENT_SIZE); index = bit + XDES_BITS_PER_PAGE * offset; //#define XDES_BITS_PER_PAGE 2 /* How many bits are there per page */ byte_index = index / ; bit_index = index % ; /** *descr 是 XDES Entry的入口地址 *descr + 24 即XDES Entry中XDES BITMAP的入口地址 * *#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 */ */ return(ut_bit_get_nth(mtr_read_ulint(descr + XDES_BITMAP + byte_index,MLOG_1BYTE, mtr),bit_index)); }
/********************************************************//** Reads 1 - 4 bytes from a file page buffered in the buffer pool. @return value read */ UNIV_INTERN ulint mtr_read_ulint( /*===========*/ const byte* ptr, /*!< in: pointer from where to read */ ulint type, /*!< in: MLOG_1BYTE, MLOG_2BYTES, MLOG_4BYTES */ mtr_t* mtr __attribute__((unused))) /*!< in: mini-transaction handle */ { ut_ad(mtr->state == MTR_ACTIVE); ut_ad(mtr_memo_contains_page(mtr, ptr, MTR_MEMO_PAGE_S_FIX) || mtr_memo_contains_page(mtr, ptr, MTR_MEMO_PAGE_X_FIX)); if (type == MLOG_1BYTE) { return(mach_read_from_1(ptr)); } else if (type == MLOG_2BYTES) { return(mach_read_from_2(ptr)); } else { ut_ad(type == MLOG_4BYTES); return(mach_read_from_4(ptr)); } }
/********************************************************//** The following function is used to fetch data from one byte. @return ulint integer, >= 0, < 256 */ UNIV_INLINE ulint mach_read_from_1( /*=============*/ const byte* b) /*!< in: pointer to byte */ { ut_ad(b); ])); }
/*****************************************************************//** Gets the nth bit of a ulint. @return TRUE if nth bit is 1; 0th bit is defined to be the least significant */ UNIV_INLINE ibool ut_bit_get_nth( /*===========*/ ulint a, /*!< in: ulint */ ulint n) /*!< in: nth bit requested */ { ut_ad(n < * sizeof(ulint)); #if TRUE != 1 # error "TRUE != 1" #endif & (a >> n)); }
/*****************************************************************//** Sets the nth bit of a ulint. @return the ulint with the bit set as requested */ UNIV_INLINE ulint ut_bit_set_nth( /*===========*/ ulint a, /*!< in: ulint */ ulint n, /*!< in: nth bit requested */ ibool val) /*!< in: value for the bit to set */ { ut_ad(n < * sizeof(ulint)); #if TRUE != 1 # error "TRUE != 1" #endif if (val) { /** *n的值此时为 index%8 为 7 ,6 ,5,4,3,2,1,0 来决定属于哪一个 *假设在第5个,1 << 5 的二进制为 100000 最大的1的下标为5 */ << n) | a); } else { << n) & a); } }
函数xdes_find_bit的更多相关文章
- 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++获取时间函数众多,何时该用什么函数,拿到的是什么时间?该怎么用?很多人都会混淆. 本文是本人经历了几款游戏客户端和服务器开发后,对游戏中时间获取的一点总结. 最早学习游戏客户端时,为了获取最精确 ...
随机推荐
- 19_高级映射:一对多查询(使用resultMap)
[需求] 查询订单以及订单明细的信息. 确定主查询表:订单表orders 确定关联查询表:订单明细表 orderdetail 在一对一查询的基础上添加订单明细表关联即可. [分析] 使用resultM ...
- [算法] get_lucky_price price
int get_lucky_price(int price, const vector & number) 题意大概是给你一个数price,比如1000,然后有unlucky_num,有{1, ...
- JDK1.8 HashMap中put源码分析
一.存储结构 在JDK1.8之前,HashMap采用桶+链表实现,本质就是采用数组+单向链表组合型的数据结构.它之所以有相当快的查询速度主要是因为它是通过计算散列码来决定存储的位置.Hash ...
- Django部署问题
1.Debug=True页面正常显示. 2.Debug=False,页面500错误. 3.解决500,配置setting.py,令ALLOWED_HOSTS = ['*'],可解决访问问题,但静态文件 ...
- 支付宝api教程,支付宝根据交易号自动充值
最近公司要用php做一个网站支付宝自动充值的功能,具体就是客户把钱直接转到公司的支付宝账号里,然后在我们网站上填写上交易号,我们网站程序自动获取交易信息,自动给网站的账户充值. 我的具体想法就是利用支 ...
- grunt学习
有些时候,项目中的静态资源,比如图片占用的文件有点大,影响加载的速度,所以会选择grunt对其进行压缩打包.对于grunt其他的用法,还在继续学习中,先记录下关于grunt的一些学习. grunt是一 ...
- ECshop网店系统百万级商品量性能优化-加快首页访问速度
如果ECshop的商品数达到几万,十几万的时候,如果首页没有缓存,第一次访问的时候,你会发现其慢无比,原因就是清空了Cache后或者没有Cache的情况下,ECshop会Bulid一些Cache数据, ...
- 原生js在IE7下 向dom添加节点的一个bug, (本例为添加hidden input)
需求是要用js向dom结构增加1个hidden用来存放要post到服务器的数据 var aspnetForm = document.getElementById("aspnetForm&qu ...
- <a>作Form表单提</a>
1. Form表单<%using (Html.BeginForm("AddRoles", "RoleManage", FormMethod.Post, n ...
- java学习--抽象类与接口
一.抽象 在使用抽象类时需要注意几点: 1.抽象类不能被实例化,实例化的工作应该交由它的子类来完成,它只需要有一个引用即可. 2.抽象方法必须由子类来进行重写. 3.只要包含一个抽象方法的抽象类,该方 ...