mysql 动态hash_MySQL动态hash删除操作

541   if (empty == lastpos)                 /* last key at wrong pos or no next link */

542     goto exit;

543

544   /* Move the last key (lastpos) */

545   lastpos_hashnr=rec_hashnr(hash,lastpos->data);//重新计算最后一个位置的hash值

546   /* pos is where lastpos should be */

547   pos= data + my_hash_mask(lastpos_hashnr, hash->blength, hash->records);//计算掩码//如果空闲位是最后以为掩码的位置,case2

548   if (pos == empty)                     /* Move to empty position. */

549   {

550     empty[0]=lastpos[0];

551     goto exit;

552   }

553   pos_hashnr=rec_hashnr(hash,pos->data);

554   /* pos3 is where the pos should be */  //计算pos位的hash掩码

555   pos3= data + my_hash_mask(pos_hashnr, hash->blength, hash->records);

556   if (pos != pos3)//如果pos位的元素掩码不等于pos,case3

557   {                                     /* pos is on wrong posit */

558     empty[0]=pos[0];                    /* Save it here */

559     pos[0]=lastpos[0];                  /* This should be here */

560     movelink(data,(uint) (pos-data),(uint) (pos3-data),empty_index);

561     goto exit;

562   }//计算数组最后一位的掩码(records等于减一之前的值),case4

563   pos2= my_hash_mask(lastpos_hashnr, blength, hash->records + 1);

564   if (pos2 == my_hash_mask(pos_hashnr, blength, hash->records + 1))

565   {                                     /* Identical key-positions */

566     if (pos2 != hash->records)//进入case4-1

567     {

568       empty[0]=lastpos[0];

569       movelink(data,(uint) (lastpos-data),(uint) (pos-data),empty_index);

570       goto exit;

571     }

572     idx= (uint) (pos-data);             /* Link pos->next after lastpos */

573   }

//case4-2

574   else idx= NO_RECORD;          /* Different positions merge */

575

576   empty[0]=lastpos[0];

577   movelink(data,idx,empty_index,pos->next);

578   pos->next=empty_index;

579

580 exit:

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值