mysql非叶子节点_MySQL:非叶子节点指针

这个指针为8字节:4(唯一定位字段个数)+4(page no)。函数为dict_index_build_node_ptr。仅此记录,后续研究

```

/**********************************************************************//**

Builds a node pointer out of a physical record and a page number.

@return own: node pointer */

dtuple_t*

dict_index_build_node_ptr(

/*======================*/

const dict_index_t*index,/*!< in: index */

const rec_t*rec,/*!< in: record for which to build node

pointer */

ulintpage_no,/*!< in: page number to put in node

pointer */

mem_heap_t*heap,/*!< in: memory heap where pointer

created */

ulintlevel)/*!< in: level of rec in tree:

0 means leaf level */

{

dtuple_t*tuple;

dfield_t*field;

byte*buf;

ulintn_unique;

if (dict_index_is_ibuf(index)) {

/* In a universal index tree, we take the whole record as

the node pointer if the record is on the leaf level,

on non-leaf levels we remove the last field, which

contains the page number of the child page */

ut_a(!dict_table_is_comp(index->table));

n_unique = rec_get_n_fields_old(rec);

if (level > 0) {

ut_a(n_unique > 1);

n_unique--;

}

} else {

n_unique = dict_index_get_n_unique_in_tree_nonleaf(index);// 唯一定位 到叶子节点的字段个数

}

tuple = dtuple_create(heap, n_unique + 1); //建立元组

/* When searching in the tree for the node pointer, we must not do

comparison on the last field, the page number field, as on upper

levels in the tree there may be identical node pointers with a

different page number; therefore, we set the n_fields_cmp to one

less: */

dtuple_set_n_fields_cmp(tuple, n_unique); //比较字段为 数据域

dict_index_copy_types(tuple, index, n_unique); //进行类型复制

buf = static_cast(mem_heap_alloc(heap, 4)); //分配内存

mach_write_to_4(buf, page_no);//写入 叶子节点page no

field = dtuple_get_nth_field(tuple, n_unique); //字段个数 能够唯一定位的字段个数

dfield_set_data(field, buf, 4);//写入字段个数

dtype_set(dfield_get_type(field), DATA_SYS_CHILD, DATA_NOT_NULL, 4);

rec_copy_prefix_to_dtuple(tuple, rec, index, n_unique, heap); //复制数据

dtuple_set_info_bits(tuple, dtuple_get_info_bits(tuple)

| REC_STATUS_NODE_PTR);

ut_ad(dtuple_check_typed(tuple));

return(tuple);

}

```

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7728585/viewspace-2699697/,如需转载,请注明出处,否则将追究法律责任。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值