当前位置:网站首页>使用高斯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
边栏推荐
- The strength index of specialized and new software development enterprises was released, and Kirin Xin'an was honored on the list
- 谷歌seo外链Backlinks研究工具推荐
- 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
- 指定opencv非标准安装的版本
- R语言使用ggplot2函数可视化需要构建泊松回归模型的计数目标变量的直方图分布并分析构建泊松回归模型的可行性
- Key points of anti reptile: identifying reptiles
- ASP.NET体育馆综合会员管理系统源码,免费分享
- Specify the version of OpenCV non-standard installation
- 2022.07.02
- Time tools
猜你喜欢

Kirin Xin'an cloud platform is newly upgraded!

2022.07.04

Chief technology officer of Pasqual: analog quantum computing takes the lead in bringing quantum advantages to industry

Research and practice of super-resolution technology in the field of real-time audio and video

Redis master-slave and sentinel master-slave switchover are built step by step

开源OA开发平台:合同管理使用手册

Matplotlib drawing 3D graphics
![[Verilog advanced challenge of Niuke network question brushing series] ~ multi bit MUX synchronizer](/img/7d/ed9a5c536b4cc1913fb69640afb98d.png)
[Verilog advanced challenge of Niuke network question brushing series] ~ multi bit MUX synchronizer

5billion, another master fund was born in Fujian

ASP.NET幼儿园连锁管理系统源码
随机推荐
ASP. Net gymnasium integrated member management system source code, free sharing
tp6 实现佣金排行榜
ASP.NET幼儿园连锁管理系统源码
The DBSCAN function of FPC package of R language performs density clustering analysis on data, checks the clustering labels of all samples, and the table function calculates the two-dimensional contin
最长公共前缀(leetcode题14)
2022.07.05
杰理之测试盒配置声道【篇】
LeetCode 648(C#)
注解。。。
R language dplyr package mutate_ At function and min_ The rank function calculates the sorting sequence number value and ranking value of the specified data column in the dataframe, and assigns the ra
Chief technology officer of Pasqual: analog quantum computing takes the lead in bringing quantum advantages to industry
Business experience in virtual digital human
2022.07.02
IP tools
Introduction to bit operation
Mysql, sqlserver Oracle database connection mode
how to prove compiler‘s correctness
Throughput
RESTAPI 版本控制策略【eolink 翻译】
LeetCode 535(C#)