Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_57962205
redisson
提交
f0e27b4a
R
redisson
项目概览
weixin_57962205
/
redisson
与 Fork 源项目一致
从无法访问的项目Fork
通知
10
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redisson
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
f0e27b4a
编写于
9月 24, 2019
作者:
N
Nikita Koksharov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactoring
上级
f2e9063b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
41 addition
and
62 deletion
+41
-62
redisson/src/main/java/org/redisson/liveobject/LiveObjectSearch.java
...c/main/java/org/redisson/liveobject/LiveObjectSearch.java
+41
-62
未找到文件。
redisson/src/main/java/org/redisson/liveobject/LiveObjectSearch.java
浏览文件 @
f0e27b4a
...
...
@@ -60,8 +60,6 @@ public class LiveObjectSearch {
private
Set
<
Object
>
traverseAnd
(
ANDCondition
condition
,
NamingScheme
namingScheme
,
Class
<?>
entityClass
)
{
Set
<
Object
>
allIds
=
new
HashSet
<
Object
>();
RSet
<
Object
>
firstEqSet
=
null
;
List
<
String
>
eqNames
=
new
ArrayList
<
String
>();
Map
<
RScoredSortedSet
<
Object
>,
Number
>
gtNumericNames
=
new
HashMap
<>();
...
...
@@ -81,11 +79,7 @@ public class LiveObjectSearch {
}
else
{
RSetMultimap
<
Object
,
Object
>
map
=
redisson
.
getSetMultimap
(
indexName
,
namingScheme
.
getCodec
());
RSet
<
Object
>
values
=
map
.
get
(
eqc
.
getValue
());
if
(
firstEqSet
==
null
)
{
firstEqSet
=
values
;
}
else
{
eqNames
.
add
(
values
.
getName
());
}
eqNames
.
add
(
values
.
getName
());
}
}
if
(
cond
instanceof
LTCondition
)
{
...
...
@@ -122,24 +116,23 @@ public class LiveObjectSearch {
if
(
ids
.
isEmpty
())
{
return
Collections
.
emptySet
();
}
allIds
.
addAll
(
ids
);
allIds
.
retainAll
(
ids
);
if
(
allIds
.
isEmpty
())
{
return
Collections
.
emptySet
();
}
}
}
if
(
firstEqSet
!=
null
)
{
if
(
eqNames
.
isEmpty
())
{
if
(!
allIds
.
isEmpty
())
{
allIds
.
retainAll
(
firstEqSet
.
readAll
());
}
else
{
allIds
.
addAll
(
firstEqSet
.
readAll
());
if
(!
eqNames
.
isEmpty
())
{
RSet
<
Object
>
set
=
redisson
.
getSet
(
eqNames
.
get
(
0
));
Set
<
Object
>
intersect
=
set
.
readIntersection
(
eqNames
.
toArray
(
new
String
[
eqNames
.
size
()]));
if
(!
allIds
.
isEmpty
())
{
allIds
.
retainAll
(
intersect
);
if
(
allIds
.
isEmpty
())
{
return
Collections
.
emptySet
();
}
}
else
{
Set
<
Object
>
intersect
=
firstEqSet
.
readIntersection
(
eqNames
.
toArray
(
new
String
[
eqNames
.
size
()]));
if
(!
allIds
.
isEmpty
())
{
allIds
.
retainAll
(
intersect
);
}
else
{
allIds
.
addAll
(
intersect
);
}
allIds
.
addAll
(
intersect
);
}
}
...
...
@@ -178,25 +171,22 @@ public class LiveObjectSearch {
private
boolean
checkValueRange
(
Set
<
Object
>
allIds
,
Map
<
RScoredSortedSet
<
Object
>,
Number
>
numericNames
,
BiFunction
<
RScoredSortedSet
<
Object
>,
Number
,
Collection
<
Object
>>
func
)
{
if
(!
numericNames
.
isEmpty
())
{
Set
<
Object
>
gtAllIds
=
new
HashSet
<>();
boolean
firstFill
=
false
;
for
(
Entry
<
RScoredSortedSet
<
Object
>,
Number
>
e
:
numericNames
.
entrySet
())
{
Collection
<
Object
>
gtIds
=
func
.
apply
(
e
.
getKey
(),
e
.
getValue
());
if
(
gtIds
.
isEmpty
())
{
return
false
;
}
if
(!
firstFill
)
{
gtAllIds
.
addAll
(
gtIds
);
firstFill
=
true
;
}
else
{
gtAllIds
.
retainAll
(
gtIds
);
}
if
(
numericNames
.
isEmpty
())
{
return
true
;
}
for
(
Entry
<
RScoredSortedSet
<
Object
>,
Number
>
e
:
numericNames
.
entrySet
())
{
Collection
<
Object
>
gtIds
=
func
.
apply
(
e
.
getKey
(),
e
.
getValue
());
if
(
gtIds
.
isEmpty
())
{
return
false
;
}
if
(!
allIds
.
isEmpty
())
{
allIds
.
retainAll
(
gtAllIds
);
allIds
.
retainAll
(
gtIds
);
if
(
allIds
.
isEmpty
())
{
return
false
;
}
}
else
{
allIds
.
addAll
(
gt
All
Ids
);
allIds
.
addAll
(
gtIds
);
}
}
return
true
;
...
...
@@ -205,7 +195,6 @@ public class LiveObjectSearch {
private
Set
<
Object
>
traverseOr
(
ORCondition
condition
,
NamingScheme
namingScheme
,
Class
<?>
entityClass
)
{
Set
<
Object
>
allIds
=
new
HashSet
<
Object
>();
RSet
<
Object
>
firstEqSet
=
null
;
List
<
String
>
eqNames
=
new
ArrayList
<
String
>();
Map
<
RScoredSortedSet
<
Object
>,
Number
>
ltNumericNames
=
new
HashMap
<>();
...
...
@@ -225,11 +214,7 @@ public class LiveObjectSearch {
}
else
{
RSetMultimap
<
Object
,
Object
>
map
=
redisson
.
getSetMultimap
(
indexName
,
namingScheme
.
getCodec
());
RSet
<
Object
>
values
=
map
.
get
(
eqc
.
getValue
());
if
(
firstEqSet
==
null
)
{
firstEqSet
=
values
;
}
else
{
eqNames
.
add
(
values
.
getName
());
}
eqNames
.
add
(
values
.
getName
());
}
}
if
(
cond
instanceof
GTCondition
)
{
...
...
@@ -265,12 +250,10 @@ public class LiveObjectSearch {
allIds
.
addAll
(
ids
);
}
}
if
(
firstEqSet
!=
null
)
{
if
(
eqNames
.
isEmpty
())
{
allIds
.
addAll
(
firstEqSet
.
readAll
());
}
else
{
allIds
.
addAll
(
firstEqSet
.
readUnion
(
eqNames
.
toArray
(
new
String
[
eqNames
.
size
()])));
}
if
(!
eqNames
.
isEmpty
())
{
RSet
<
Object
>
set
=
redisson
.
getSet
(
eqNames
.
get
(
0
));
allIds
.
addAll
(
set
.
readUnion
(
eqNames
.
toArray
(
new
String
[
eqNames
.
size
()])));
}
for
(
Entry
<
RScoredSortedSet
<
Object
>,
Number
>
e
:
eqNumericNames
.
entrySet
())
{
...
...
@@ -304,7 +287,6 @@ public class LiveObjectSearch {
public
Set
<
Object
>
find
(
Class
<?>
entityClass
,
Condition
condition
)
{
NamingScheme
namingScheme
=
objectBuilder
.
getNamingScheme
(
entityClass
);
Set
<
Object
>
ids
=
Collections
.
emptySet
();
if
(
condition
instanceof
EQCondition
)
{
EQCondition
c
=
(
EQCondition
)
condition
;
String
indexName
=
namingScheme
.
getIndexName
(
entityClass
,
c
.
getName
());
...
...
@@ -313,45 +295,42 @@ public class LiveObjectSearch {
RScoredSortedSet
<
Object
>
set
=
redisson
.
getScoredSortedSet
(
indexName
,
namingScheme
.
getCodec
());
double
v
=
((
Number
)
c
.
getValue
()).
doubleValue
();
Collection
<
Object
>
gtIds
=
set
.
valueRange
(
v
,
true
,
v
,
true
);
ids
=
new
HashSet
<>(
gtIds
);
return
new
HashSet
<>(
gtIds
);
}
else
{
RSetMultimap
<
Object
,
Object
>
map
=
redisson
.
getSetMultimap
(
indexName
,
namingScheme
.
getCodec
());
ids
=
map
.
getAll
(
c
.
getValue
());
return
map
.
getAll
(
c
.
getValue
());
}
}
else
if
(
condition
instanceof
GTCondition
)
{
GTCondition
c
=
(
GTCondition
)
condition
;
String
indexName
=
namingScheme
.
getIndexName
(
entityClass
,
c
.
getName
());
RScoredSortedSet
<
Object
>
set
=
redisson
.
getScoredSortedSet
(
indexName
,
namingScheme
.
getCodec
());
Collection
<
Object
>
gtIds
=
set
.
valueRange
(
c
.
getValue
().
doubleValue
(),
false
,
Double
.
POSITIVE_INFINITY
,
false
);
ids
=
new
HashSet
<>(
gtIds
);
return
new
HashSet
<>(
gtIds
);
}
else
if
(
condition
instanceof
GECondition
)
{
GECondition
c
=
(
GECondition
)
condition
;
String
indexName
=
namingScheme
.
getIndexName
(
entityClass
,
c
.
getName
());
RScoredSortedSet
<
Object
>
set
=
redisson
.
getScoredSortedSet
(
indexName
,
namingScheme
.
getCodec
());
Collection
<
Object
>
gtIds
=
set
.
valueRange
(
c
.
getValue
().
doubleValue
(),
true
,
Double
.
POSITIVE_INFINITY
,
false
);
ids
=
new
HashSet
<>(
gtIds
);
return
new
HashSet
<>(
gtIds
);
}
else
if
(
condition
instanceof
LTCondition
)
{
LTCondition
c
=
(
LTCondition
)
condition
;
String
indexName
=
namingScheme
.
getIndexName
(
entityClass
,
c
.
getName
());
RScoredSortedSet
<
Object
>
set
=
redisson
.
getScoredSortedSet
(
indexName
,
namingScheme
.
getCodec
());
Collection
<
Object
>
gtIds
=
set
.
valueRange
(
Double
.
NEGATIVE_INFINITY
,
false
,
c
.
getValue
().
doubleValue
(),
false
);
ids
=
new
HashSet
<>(
gtIds
);
return
new
HashSet
<>(
gtIds
);
}
else
if
(
condition
instanceof
LECondition
)
{
LECondition
c
=
(
LECondition
)
condition
;
String
indexName
=
namingScheme
.
getIndexName
(
entityClass
,
c
.
getName
());
RScoredSortedSet
<
Object
>
set
=
redisson
.
getScoredSortedSet
(
indexName
,
namingScheme
.
getCodec
());
Collection
<
Object
>
gtIds
=
set
.
valueRange
(
Double
.
NEGATIVE_INFINITY
,
false
,
c
.
getValue
().
doubleValue
(),
true
);
ids
=
new
HashSet
<>(
gtIds
);
return
new
HashSet
<>(
gtIds
);
}
else
if
(
condition
instanceof
ORCondition
)
{
ids
=
traverseOr
((
ORCondition
)
condition
,
namingScheme
,
entityClass
);
return
traverseOr
((
ORCondition
)
condition
,
namingScheme
,
entityClass
);
}
else
if
(
condition
instanceof
ANDCondition
)
{
ids
=
traverseAnd
((
ANDCondition
)
condition
,
namingScheme
,
entityClass
);
}
if
(
ids
.
isEmpty
())
{
return
Collections
.
emptySet
();
return
traverseAnd
((
ANDCondition
)
condition
,
namingScheme
,
entityClass
);
}
return
ids
;
throw
new
IllegalArgumentException
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录