postgreSQL的哈希索引

13 篇文章 0 订阅

Hash Table (Hash Map)

哈希表是根据key直接进行访问的数据结构(这一结构的实现通常采用数组),它通过把关键码值映射(这个映射函数叫做散列函数)到表中一个位置来访问记录,以加快查找的速度。

hash table (hash map) is a data structure that implements an associative array abstract data type,  a structure that can map keys to values. A hash table uses a has function to compute an index, also called a hash code, into an array of buckets or slots, from which the desired value can be found.

Collision resolution

  • Separate chaining (most used): each bucket is independent, insert the record into the bucket when a conflict occurs (has entries with the same index). (i.e. 数组不再直接存储键值对,而是把“链”作为自己的元素)
    • linked list 
    • store the first record of each chain in the slot array itself
    • self-balancing binary search tree 
  • Open addressing:  all records are stored in the bucket array itself. When a new record is inserted, the buckets are examined, starting with the hashed-to slot and proceeding in some probe sequence (linear probing / ..), until an unoccupied slot is found. (i.e. 当发生地址冲突时,按照某种方法继续探测哈希表中的其他存储单元)

Load factor

        填入表中的元素个数 / 散列表的长度

Dynamic resizing

  • resizing directions: shrink / grow
  • resizing implementation:
    • all-at-once rehashing: enlarging the hash table all at once, which includes allocating a new larger table, removing each entry from the old table, and inserting into the new table. 
    • rehashing gradually

Reference

Dynamic-Sized Nonblocking Hash Tables

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值