用于在B树上查找给定码值,如果该码值存在,就返回TRUE,该函数首先将指针指向含有正确叶子节点页面的缓 冲区存取块,然后,在缓冲区存取控制块中又设置了正确的入口项地址, 最后还保存遍历B树时所访问过的所有节点的页号和LSN
实作中修正了一个错误,对BTree * & 与BTree *用得比较混乱,所以一致的改成BTree &处理,目前基本弄通了
bool ReadBt(BTree & tree, Key & searchKey, TCHAR Purpose, LeafPtr leafptr, PathPtr pathptr)
{
PAGEID Nextint = tree.root;
int Depth_C = 1;
int Right_Pos = 0;
BUFFER_ACC_CBP left_leg, right_leg; //分解蟹行操作
BUFFER_ACC_CBP result_node; //结果节点的CB地址
bool OutCome;
while( Depth_C < height )
{
OutCome = bufferfix( nextint, sh_sem, & right_leg); //页面入缓,并设置信号量
pathptr->SearchPath[Depth_C].hereiwas = nextint;
pathptr->SearchPath[Depth_C].lsn_seen = right_leg.pageaddr->safe_up_to; //保存页面LSN
path_ptr->SearchPath[Depth_C].x_sem_set = FALSE;
if ( Depth_C > 1)
OutCome = bufferunfix(left_leg);
right_pos = PageSearch(right_leg->pageaddr, searchkey); //获得入口项索引
nextint = (right_leg->pageaddr)->oneentry[right_pos].thatway;
left_leg = right_leg; //将Rigth做为当前要处理的节点
Depth_C ++; //处理下一层
}
if ( purpose = 'R' )
OutCome = bufferfix( nextint, sh_sem, &right_leg);
else
OutCome = bufferfix( nextint, ex_sem, &right_leg);
outcome = bufferunfix(left_leg);
leafptr->result_node = right_leg;
/**//*
将查找参数所在的叶子页地址,以及与查找参数相对应的入口项索引量靠近的索引,传给接收结 果的参数
*/
right_leg->index = pagesearch(right_leg->pageaddr, searchKey);
return (getValue(right_leg->pageaddr, right_leg->index) == searchkey); //根据判断结 果设置返回值
}