当前位置:网站首页>Map design
Map design
2022-06-24 01:01:00 【Love each other when flowers fall】
bucket (buckets)
Go Store key value pairs in a bucket list , Each bucket will hold 8 Key value pairs , When map When capacity is exhausted , The hash bucket will double its capacity . The following figure shows four barrels roughly :
map Of buckets list
In the next article, we will introduce how the key value pairs in the bucket are stored . If map Capacity increase , The number of barrels will double to 8 individual 、16 Wait a minute .
When one key/value To deposit map among , Based on the key The hash value of is allocated to the bucket of .
hash
When key/value Assign to map when ,Go Will be based on key It's worth generating a hash value . We insert "foo=1" For example, key value pairs , Generated hash The value could be 15491954468309821754, Use this value for a bit operation , The mask is equal to the number of buckets minus 1. The number of barrels is shown in the figure below 4 Example , You can get the mask 3, Then perform bitwise and operation :
value Distribution in barrels
Hash values are not only used to allocate bucket values , There are other operations . According to the height of the hash value 8 position , You can confirm that an array stored in a bucket value The location of . Here's the picture :
In the bucket top hash table
Because there is this table in the bucket ,Go Can quickly access and compare key For the value value .
According to the procedure map Use ,Go A scalable mechanism is needed to store more key/value value .
Map Capacity expansion
If the bucket needs to store one key/value, Will be stored internally available 8 In the groove of a barrel . If no barrels are available , An overflow bucket will be created and linked to the current bucket , And link to the current bucket .
Overflow bucket
This overflow characteristic summarizes the internal structure of the barrel . However, increasing the overflow bucket will reduce map Performance of . To solve the performance problem ,Go New buckets will be allocated ( Twice the current number ) A connection will be established between the old barrel and the new barrel .
Go Use its load factor to know when to start distributing new barrels and the evacuation process .
边栏推荐
- Shardingsphere-proxy-5.0.0 implementation of capacity range partition (V)
- 解决base64压缩文件,经过post请求解压出来是空格的问题
- C language: structure array implementation to find the lowest student record
- Map data types in golang
- Is it safe to open an account online? What conditions need to be met?
- Building a digital software factory -- panoramic interpretation of one-stop Devops platform
- Use recursion to form a multi-level directory tree structure, with possibly the most detailed notes of the whole network.
- JS input / output statements, variables
- 2022 postgraduate entrance examination experience sharing [preliminary examination, school selection, re examination, adjustment, school recruitment and social recruitment]
- 实时计算框架:Spark集群搭建与入门案例
猜你喜欢

CVPR2022 | 可精简域适应

Isn't this another go bug?

Efficient integration of heterogeneous single cell transcriptome with scanorama

使用递归形成多级目录树结构,附带可能是全网最详细注释。

Theoretical analysis of countermeasure training: adaptive step size fast countermeasure training

【Flutter】如何使用Flutter包和插件

ICML'22 | ProGCL: 重新思考图对比学习中的难样本挖掘

Shardingsphere-proxy-5.0.0 implementation of capacity range partition (V)

How to write peer-reviewed papers

C语言:关于矩阵右移问题
随机推荐
使用递归形成多级目录树结构,附带可能是全网最详细注释。
The concept of TP FP TN FN in machine learning
C language: how to solve the problem of hundreds of horses and loads
【小程序】相对路径和绝对路径的表示符
Security | warm tips: security incidents on the cloud have intensified recently. Please do a good job in backup monitoring of cloud security protection!
牛学长周年庆活动:软件大促限时抢,注册码免费送!
所见之处都是我精准定位的范畴!显著图可视化新方法开源
[Hongke case] how can 3D data become operable information Object detection and tracking
【虹科案例】3D数据如何成为可操作的信息?– 对象检测和跟踪
The industrial Internet era will be realized by products, technologies and models derived from the industry itself
9次Android面试经验总结,已收字节,阿里,高级android面试答案
Basic usage of setfacl command
[applet] when compiling the preview applet, a -80063 error prompt appears
ICML'22 | ProGCL: 重新思考图对比学习中的难样本挖掘
[CVPR 2020 oral] a physics based noise formation model for extreme low light raw denoising
Theoretical analysis of countermeasure training: adaptive step size fast countermeasure training
Graduation project - thesis writing notes [design topic type, thesis writing details, design materials]
How to write peer-reviewed papers
[CVPR 2020] conference version: a physics based noise formation model for extreme low light raw denoising
Cvpr2022 𞓜 thin domain adaptation