当前位置:网站首页>Concurrentskiplistmap -- principle of table skipping
Concurrentskiplistmap -- principle of table skipping
2022-07-01 23:35:00 【HD243608836】
In order to elicit ConcurrentSkipListMap, First, let's briefly understand what is skip table .
For single chain table , Even if the linked list is ordered , If you want to find some data in it , You can only traverse the linked list from beginning to end , In this way, the efficiency will be very low , The jump watch is different . Jump table is a kind of data structure that can be used to find quickly , It's kind of like a balance tree . They can all find elements quickly . But an important difference is : The insertion and deletion of the balance tree may lead to a global adjustment of the balance tree ; And the insertion and deletion of the jump table , You only need to operate on parts of the entire data structure . The advantage of this is : In the case of high concurrency , Need a global lock , To ensure the thread safety of the whole balance tree ; And for jump tables , Then only part of the lock is needed . such , In a highly concurrent environment , You can have better performance . In terms of query performance , The time complexity of the jump table is O(logn), So in concurrent data structures ,JDK Use a jump table to implement a Map.
Essence of skip table , yes Multiple linked lists are maintained at the same time , And linked lists are hierarchical :

The lowest linked list , All elements in the jump table are maintained , Each layer of linked list , Are subsets of the lower layer .
All the elements of the linked list in the jump list are sorted . When looking for , You can start with the top-level list . Once it is found that the element being searched is larger than the value in the current linked list , Will go to the next level of linked list to continue looking for . That is to say, during the search process , The search is leaping . As shown in the figure above , Look up elements in the jump table 18.

lookup 18 When , Originally, you need to traverse 18 Time , Now it's just a matter of 7 Next time . When the length of the linked list is relatively large , Build index , The improvement of search efficiency will be very obvious .
It's easy to see from above , Jump table is an algorithm that uses space to change time .
Use the jump table to achieve Map, And using hash algorithm to achieve Map The other difference between them is : Hashing doesn't hold the order of the elements , And all the elements in the jump table are sorted . therefore , When traversing the jump table , You'll get an orderly result . therefore , If your application needs order , So watch jumping is your best choice .
JDK The class that implements this data structure in is ConcurrentSkipListMap
.
边栏推荐
- 2021 robocom world robot developer competition - preliminary competition of higher vocational group
- PostgreSQL source code (57) why is the performance gap so large in hot update?
- Redis AOF日志
- De PIP. Interne. CLI. Main Import main modulenotfounderror: No module named 'PIP'
- Practical application and extension of plain framework
- 常见的积分商城游戏类型有哪些?
- algolia 搜索需求,做的快自闭了...
- 写给当前及未来博士研究生一些建议整理分享
- Linux foundation - centos7 offline installation of MySQL
- Who do you want to know when opening a stock account? Is it safe to open an account online?
猜你喜欢
Why is PHP called hypertext preprocessor
Win 10 mstsc connect RemoteApp
问题随记 —— file /usr/share/mysql/charsets/README from install of MySQL-server-5.1.73-1.glibc23.x86_64 c
使用 pair 做 unordered_map 的键值
Notblank and notempty
字典、哈希表、数组的概念
Chapter 6 data flow modeling
为什么PHP叫超文本预处理器
Huisheng Huiying 2022 intelligent, fast and simple video editing software
SWT / anr problem - SWT causes kernel fuse deadlock
随机推荐
Notblank and notempty
Why is PHP called hypertext preprocessor
Depth first search and breadth first search of graph traversal
2021 robocom world robot developer competition - preliminary competition of undergraduate group
常见的积分商城游戏类型有哪些?
2022-07-01: at the annual meeting of a company, everyone is going to play a game of giving bonuses. There are a total of N employees. Each employee has construction points and trouble points. They nee
Reproduction process and problems of analog transformer (ICLR 2022 Spotlight)
每日三题 6.30
What are the common types of points mall games?
Experience of practical learning of Silicon Valley products
Future trend and development of neural network Internet of things
ARP message header format and request flow
SWT / anr problem - SWT causes low memory killer (LMK)
Write some suggestions to current and future doctoral students to sort out and share
Door level modeling - after class exercises
每日三题 6.28
Redis master-slave synchronization
物联网现状及未来发展趋势
哈工大《信息内容安全》课程知识要点和难点
物联网开发零基础教程