Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Forever310
druid
提交
578ca64e
D
druid
项目概览
Forever310
/
druid
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
druid
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
578ca64e
编写于
8月 28, 2014
作者:
G
Gian Merlino
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #711 from metamx/fix-maxtime-caching
Fix maxtime caching
上级
08b6a267
674e7b04
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
122 addition
and
18 deletion
+122
-18
processing/src/main/java/io/druid/query/TimewarpOperator.java
...essing/src/main/java/io/druid/query/TimewarpOperator.java
+14
-8
processing/src/main/java/io/druid/query/timeboundary/TimeBoundaryQueryQueryToolChest.java
...d/query/timeboundary/TimeBoundaryQueryQueryToolChest.java
+3
-2
processing/src/test/java/io/druid/query/TimewarpOperatorTest.java
...ng/src/test/java/io/druid/query/TimewarpOperatorTest.java
+42
-0
server/src/test/java/io/druid/client/CachingClusteredClientTest.java
...test/java/io/druid/client/CachingClusteredClientTest.java
+63
-8
未找到文件。
processing/src/main/java/io/druid/query/TimewarpOperator.java
浏览文件 @
578ca64e
...
...
@@ -22,7 +22,6 @@ package io.druid.query;
import
com.fasterxml.jackson.annotation.JsonCreator
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.google.common.base.Function
;
import
com.google.common.collect.ImmutableMap
;
import
com.metamx.common.guava.Sequence
;
import
com.metamx.common.guava.Sequences
;
import
io.druid.data.input.MapBasedRow
;
...
...
@@ -80,7 +79,7 @@ public class TimewarpOperator<T> implements PostProcessingOperator<T>
return
new
QueryRunner
<
T
>()
{
@Override
public
Sequence
<
T
>
run
(
Query
<
T
>
query
)
public
Sequence
<
T
>
run
(
final
Query
<
T
>
query
)
{
final
long
offset
=
computeOffset
(
now
);
...
...
@@ -103,12 +102,19 @@ public class TimewarpOperator<T> implements PostProcessingOperator<T>
Object
value
=
res
.
getValue
();
if
(
value
instanceof
TimeBoundaryResultValue
)
{
TimeBoundaryResultValue
boundary
=
(
TimeBoundaryResultValue
)
value
;
value
=
new
TimeBoundaryResultValue
(
ImmutableMap
.
of
(
TimeBoundaryQuery
.
MIN_TIME
,
boundary
.
getMinTime
().
minus
(
offset
),
TimeBoundaryQuery
.
MAX_TIME
,
new
DateTime
(
Math
.
min
(
boundary
.
getMaxTime
().
getMillis
()
-
offset
,
now
))
)
);
DateTime
minTime
=
null
;
try
{
minTime
=
boundary
.
getMinTime
();
}
catch
(
IllegalArgumentException
e
)
{}
final
DateTime
maxTime
=
boundary
.
getMaxTime
();
return
(
T
)
((
TimeBoundaryQuery
)
query
).
buildResult
(
new
DateTime
(
Math
.
min
(
res
.
getTimestamp
().
getMillis
()
-
offset
,
now
)),
minTime
!=
null
?
minTime
.
minus
(
offset
)
:
null
,
maxTime
!=
null
?
new
DateTime
(
Math
.
min
(
maxTime
.
getMillis
()
-
offset
,
now
))
:
null
).
iterator
().
next
();
}
return
(
T
)
new
Result
(
res
.
getTimestamp
().
minus
(
offset
),
value
);
}
else
if
(
input
instanceof
MapBasedRow
)
{
...
...
processing/src/main/java/io/druid/query/timeboundary/TimeBoundaryQueryQueryToolChest.java
浏览文件 @
578ca64e
...
...
@@ -145,9 +145,10 @@ public class TimeBoundaryQueryQueryToolChest
@Override
public
byte
[]
computeCacheKey
(
TimeBoundaryQuery
query
)
{
return
ByteBuffer
.
allocate
(
2
)
final
byte
[]
cacheKey
=
query
.
getCacheKey
();
return
ByteBuffer
.
allocate
(
1
+
cacheKey
.
length
)
.
put
(
TIMEBOUNDARY_QUERY
)
.
put
(
query
.
getCacheKey
()
)
.
put
(
cacheKey
)
.
array
();
}
...
...
processing/src/test/java/io/druid/query/TimewarpOperatorTest.java
浏览文件 @
578ca64e
...
...
@@ -26,6 +26,7 @@ import com.metamx.common.guava.Sequence;
import
com.metamx.common.guava.Sequences
;
import
io.druid.query.aggregation.AggregatorFactory
;
import
io.druid.query.aggregation.CountAggregatorFactory
;
import
io.druid.query.timeboundary.TimeBoundaryResultValue
;
import
io.druid.query.timeseries.TimeseriesResultValue
;
import
org.joda.time.DateTime
;
import
org.joda.time.Interval
;
...
...
@@ -122,5 +123,46 @@ public class TimewarpOperatorTest
Sequences
.
toList
(
queryRunner
.
run
(
query
),
Lists
.<
Result
<
TimeseriesResultValue
>>
newArrayList
())
);
TimewarpOperator
<
Result
<
TimeBoundaryResultValue
>>
timeBoundaryOperator
=
new
TimewarpOperator
<>(
new
Interval
(
new
DateTime
(
"2014-01-01"
),
new
DateTime
(
"2014-01-15"
)),
new
Period
(
"P1W"
),
new
DateTime
(
"2014-01-06"
)
// align on Monday
);
QueryRunner
<
Result
<
TimeBoundaryResultValue
>>
timeBoundaryRunner
=
timeBoundaryOperator
.
postProcess
(
new
QueryRunner
<
Result
<
TimeBoundaryResultValue
>>()
{
@Override
public
Sequence
<
Result
<
TimeBoundaryResultValue
>>
run
(
Query
<
Result
<
TimeBoundaryResultValue
>>
query
)
{
return
Sequences
.
simple
(
ImmutableList
.
of
(
new
Result
<>(
new
DateTime
(
"2014-01-12"
),
new
TimeBoundaryResultValue
(
ImmutableMap
.<
String
,
Object
>
of
(
"maxTime"
,
new
DateTime
(
"2014-01-12"
)))
)
)
);
}
},
new
DateTime
(
"2014-08-02"
).
getMillis
()
);
final
Query
<
Result
<
TimeBoundaryResultValue
>>
timeBoundaryQuery
=
Druids
.
newTimeBoundaryQueryBuilder
()
.
dataSource
(
"dummy"
)
.
build
();
Assert
.
assertEquals
(
Lists
.
newArrayList
(
new
Result
<>(
new
DateTime
(
"2014-08-02"
),
new
TimeBoundaryResultValue
(
ImmutableMap
.<
String
,
Object
>
of
(
"maxTime"
,
new
DateTime
(
"2014-08-02"
)))
)
),
Sequences
.
toList
(
timeBoundaryRunner
.
run
(
timeBoundaryQuery
),
Lists
.<
Result
<
TimeBoundaryResultValue
>>
newArrayList
())
);
}
}
server/src/test/java/io/druid/client/CachingClusteredClientTest.java
浏览文件 @
578ca64e
...
...
@@ -929,6 +929,48 @@ public class CachingClusteredClientTest
new
Interval
(
"2011-01-01/2011-01-10"
),
makeTimeBoundaryResult
(
new
DateTime
(
"2011-01-05T01"
),
new
DateTime
(
"2011-01-05T01"
),
new
DateTime
(
"2011-01-10"
))
);
testQueryCaching
(
client
,
Druids
.
newTimeBoundaryQueryBuilder
()
.
dataSource
(
CachingClusteredClientTest
.
DATA_SOURCE
)
.
intervals
(
CachingClusteredClientTest
.
SEG_SPEC
)
.
context
(
CachingClusteredClientTest
.
CONTEXT
)
.
bound
(
TimeBoundaryQuery
.
MAX_TIME
)
.
build
(),
new
Interval
(
"2011-01-01/2011-01-02"
),
makeTimeBoundaryResult
(
new
DateTime
(
"2011-01-01"
),
null
,
new
DateTime
(
"2011-01-02"
)),
new
Interval
(
"2011-01-01/2011-01-03"
),
makeTimeBoundaryResult
(
new
DateTime
(
"2011-01-02"
),
null
,
new
DateTime
(
"2011-01-03"
)),
new
Interval
(
"2011-01-01/2011-01-10"
),
makeTimeBoundaryResult
(
new
DateTime
(
"2011-01-05"
),
null
,
new
DateTime
(
"2011-01-10"
)),
new
Interval
(
"2011-01-01/2011-01-10"
),
makeTimeBoundaryResult
(
new
DateTime
(
"2011-01-05T01"
),
null
,
new
DateTime
(
"2011-01-10"
))
);
testQueryCaching
(
client
,
Druids
.
newTimeBoundaryQueryBuilder
()
.
dataSource
(
CachingClusteredClientTest
.
DATA_SOURCE
)
.
intervals
(
CachingClusteredClientTest
.
SEG_SPEC
)
.
context
(
CachingClusteredClientTest
.
CONTEXT
)
.
bound
(
TimeBoundaryQuery
.
MIN_TIME
)
.
build
(),
new
Interval
(
"2011-01-01/2011-01-02"
),
makeTimeBoundaryResult
(
new
DateTime
(
"2011-01-01"
),
new
DateTime
(
"2011-01-01"
),
null
),
new
Interval
(
"2011-01-01/2011-01-03"
),
makeTimeBoundaryResult
(
new
DateTime
(
"2011-01-02"
),
new
DateTime
(
"2011-01-02"
),
null
),
new
Interval
(
"2011-01-01/2011-01-10"
),
makeTimeBoundaryResult
(
new
DateTime
(
"2011-01-05"
),
new
DateTime
(
"2011-01-05"
),
null
),
new
Interval
(
"2011-01-01/2011-01-10"
),
makeTimeBoundaryResult
(
new
DateTime
(
"2011-01-05T01"
),
new
DateTime
(
"2011-01-05T01"
),
null
)
);
}
private
Iterable
<
Result
<
TimeBoundaryResultValue
>>
makeTimeBoundaryResult
(
...
...
@@ -937,17 +979,30 @@ public class CachingClusteredClientTest
DateTime
maxTime
)
{
final
Object
value
;
if
(
minTime
!=
null
&&
maxTime
!=
null
)
{
value
=
ImmutableMap
.
of
(
TimeBoundaryQuery
.
MIN_TIME
,
minTime
.
toString
(),
TimeBoundaryQuery
.
MAX_TIME
,
maxTime
.
toString
()
);
}
else
if
(
maxTime
!=
null
)
{
value
=
ImmutableMap
.
of
(
TimeBoundaryQuery
.
MAX_TIME
,
maxTime
.
toString
()
);
}
else
{
value
=
ImmutableMap
.
of
(
TimeBoundaryQuery
.
MIN_TIME
,
minTime
.
toString
()
);
}
return
Arrays
.
asList
(
new
Result
<>(
timestamp
,
new
TimeBoundaryResultValue
(
ImmutableMap
.
of
(
TimeBoundaryQuery
.
MIN_TIME
,
minTime
.
toString
(),
TimeBoundaryQuery
.
MAX_TIME
,
maxTime
.
toString
()
)
)
new
TimeBoundaryResultValue
(
value
)
)
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录