当前位置:网站首页>Implement secondary index with Gaussian redis
Implement secondary index with Gaussian redis
2022-07-07 19:53:00 【InfoQ】
One 、 background




Two 、 Scene one : Complete the dictionary

2.1 Basic plan
ZADD myindex 0 banana:1
ZRANGEBYLEX myindex "[bit" "[bit\xff"
2.2 Frequency related dictionary completion
ZRANGEBYLEX myindex "[banana:" + LIMIT 0 1
ZADD myindex 0 banana:1
ZREM myindex 0 banana:1
ZADD myindex 0 banana:2
ZRANGEBYLEX myindex "[banana:" + LIMIT 0 10
1) "banana:123"
2) "banaooo:1"
3) "banned user:49"
4) "banning:89"
ZREM myindex 0 banaooo:1
ZREM myindex 0 banana:123
ZADD myindex 0 banana:122
3、 ... and 、 Scene two : Multidimensional index

3.1 Data encoding


3.2 Add a new element
ZADD myindex 0 000111000011001010
3.3 Inquire about
def spacequery(x0,y0,x1,y1,exp)
bits=exp*2
x_start = x0/(2**exp)
x_end = x1/(2**exp)
y_start = y0/(2**exp)
y_end = y1/(2**exp)
(x_start..x_end).each{|x|
(y_start..y_end).each{|y|
x_range_start = x*(2**exp)
x_range_end = x_range_start | ((2**exp)-1)
y_range_start = y*(2**exp)
y_range_end = y_range_start | ((2**exp)-1)
puts "#{x},#{y} x from #{x_range_start} to #{x_range_end}, y from #{y_range_start} to #{y_range_end}"
# Turn it into interleaved form for ZRANGEBYLEX query.
# We assume we need 9 bits for each integer, so the final
# interleaved representation will be 18 bits.
xbin = x_range_start.to_s(2).rjust(9,'0')
ybin = y_range_start.to_s(2).rjust(9,'0')
s = xbin.split("").zip(ybin.split("")).flatten.compact.join("")
# Now that we have the start of the range, calculate the end
# by replacing the specified number of bits from 0 to 1.
e = s[0..-(bits+1)]+("1"*bits)
puts "ZRANGEBYLEX myindex [#{s} [#{e}"
}
}
end
spacequery(50,100,100,300,6)
Four 、 summary
appendix
- The author of this article : Huawei cloud database GaussDB(for Redis) The team
- Hangzhou / Xi'an / Shenzhen resume delivery :[email protected]
- More product information , Welcome to the official blog :bbs.huaweicloud.com/blogs/248875
边栏推荐
- Navicat连接2002 - Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘解决
- Netease Yunxin participated in the preparation of the standard "real time audio and video service (RTC) basic capability requirements and evaluation methods" issued by the Chinese Academy of Communica
- 杰理之手动配对方式【篇】
- Interpretation of transpose convolution theory (input-output size analysis)
- Empowering smart power construction | Kirin Xin'an high availability cluster management system to ensure the continuity of users' key businesses
- Kirin Xin'an won the bid for the new generation dispatching project of State Grid!
- Numpy——axis
- Numpy——2. Shape of array
- PV static creation and dynamic creation
- Kirin Xin'an cloud platform is newly upgraded!
猜你喜欢
Le PGR est - il utile au travail? Comment choisir une plate - forme fiable pour économiser le cœur et la main - d'œuvre lors de la préparation de l'examen!!!
小试牛刀之NunJucks模板引擎
9 原子操作类之18罗汉增强
PV static creation and dynamic creation
[Verilog advanced challenge of Niuke network question brushing series] ~ multi bit MUX synchronizer
Research and practice of super-resolution technology in the field of real-time audio and video
Numpy——2. Shape of array
Make this crmeb single merchant wechat mall system popular, so easy to use!
Install mysql8 for Linux X ultra detailed graphic tutorial
位运算介绍
随机推荐
Kirin Xin'an with heterogeneous integration cloud financial information and innovation solutions appeared at the 15th Hunan Financial Technology Exchange Conference
Numpy——axis
Is PMP beneficial to work? How to choose a reliable platform to make it easier to prepare for the exam!!!
九章云极DataCanvas公司获评36氪「最受投资人关注的硬核科技企业」
How to buy stocks on your mobile phone and open an account? Is it safe to open an account
现在股票开户可以直接在网上开吗?安全吗。
【剑指offer】剑指 Offer II 012. 左右两边子数组的和相等
时间工具类
RESTAPI 版本控制策略【eolink 翻译】
ASP. Net kindergarten chain management system source code
R language ggplot2 visualization: use the ggecdf function of ggpubr package to visualize the grouping experience cumulative density distribution function curve, and the linetype parameter to specify t
String - string (Lua)
Introduction to bit operation
银行理财产品怎么买?需要办银行卡吗?
Chief technology officer of Pasqual: analog quantum computing takes the lead in bringing quantum advantages to industry
Notes...
Responsibility chain model - unity
让这个 CRMEB 单商户微信商城系统火起来,太好用了!
R语言使用ggplot2函数可视化需要构建泊松回归模型的计数目标变量的直方图分布并分析构建泊松回归模型的可行性
8 CAS