当前位置:网站首页>使用高斯Redis实现二级索引
使用高斯Redis实现二级索引
2022-07-07 17:38:00 【InfoQ】
一、背景




二、场景一:词典补全

2.1 基本方案
ZADD myindex 0 banana:1ZRANGEBYLEX myindex "[bit" "[bit\xff"2.2 与频率相关的词典补全
ZRANGEBYLEX myindex "[banana:" + LIMIT 0 1ZADD myindex 0 banana:1ZREM myindex 0 banana:1ZADD myindex 0 banana:2ZRANGEBYLEX myindex "[banana:" + LIMIT 0 10
1) "banana:123"
2) "banaooo:1"
3) "banned user:49"
4) "banning:89"ZREM myindex 0 banaooo:1ZREM myindex 0 banana:123
ZADD myindex 0 banana:122三、场景二:多维索引

3.1 数据编码


3.2 添加新元素
ZADD myindex 0 0001110000110010103.3 查询
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)四、总结
附录
- 本文作者:华为云数据库GaussDB(for Redis)团队
- 杭州/西安/深圳简历投递:[email protected]
- 更多产品信息,欢迎访问官方博客:bbs.huaweicloud.com/blogs/248875
边栏推荐
- ASP. Net kindergarten chain management system source code
- 杰理之相同声道的耳机不允许配对【篇】
- PMP每日一练 | 考试不迷路-7.7
- POJ 1182: food chain (parallel search) [easy to understand]
- Numpy——2. Shape of array
- 实训九 网络服务的基本配置
- R语言ggplot2可视化:使用ggpubr包的ggdensity函数可视化分组密度图、使用stat_overlay_normal_density函数为每个分组的密度图叠加正太分布曲线
- 微信公众号OAuth2.0授权登录并显示用户信息
- 超分辨率技术在实时音视频领域的研究与实践
- 2022.07.05
猜你喜欢

转置卷积理论解释(输入输出大小分析)

Business experience in virtual digital human

干货分享|DevExpress v22.1原版帮助文档下载集合

论文解读(ValidUtil)《Rethinking the Setting of Semi-supervised Learning on Graphs》

The project manager's "eight interview questions" is equal to a meeting

谷歌seo外链Backlinks研究工具推荐

el-upload上传组件的动态添加;el-upload动态上传文件;el-upload区分文件是哪个组件上传的。

网易云信参与中国信通院《实时音视频服务(RTC)基础能力要求及评估方法》标准编制...

华南X99平台打鸡血教程

2022.07.04
随机推荐
AI writes a poem
Dynamic addition of El upload upload component; El upload dynamically uploads files; El upload distinguishes which component uploads the file.
解决远程rviz报错问题
Throughput
Number - number (Lua)
R language ggplot2 visualization: use the ggstripchart function of ggpubr package to visualize the dot strip plot, set the position parameter, and configure the separation degree of different grouped
PMP每日一练 | 考试不迷路-7.7
Kirin Xin'an won the bid for the new generation dispatching project of State Grid!
最长公共前缀(leetcode题14)
[Verilog advanced challenge of Niuke network question brushing series] ~ multi bit MUX synchronizer
Make insurance more "safe"! Kirin Xin'an one cloud multi-core cloud desktop won the bid of China Life Insurance, helping the innovation and development of financial and insurance information technolog
How to buy bank financial products? Do you need a bank card?
The project manager's "eight interview questions" is equal to a meeting
【Confluence】JVM内存调整
ant desgin 多选
RESTAPI 版本控制策略【eolink 翻译】
Responsibility chain model - unity
POJ 1182: food chain (parallel search) [easy to understand]
IP tools
Kunpeng developer summit 2022 | Kirin Xin'an and Kunpeng jointly build a new ecosystem of computing industry