mirror of https://github.com/apache/druid.git
fix maxTime caching for individual bounds
This commit is contained in:
parent
08b6a2677d
commit
b0b39d6ec0
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
)
|
||||
{
|
||||
return Arrays.asList(
|
||||
new Result<>(
|
||||
timestamp,
|
||||
new TimeBoundaryResultValue(
|
||||
ImmutableMap.of(
|
||||
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(value)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue