mirror of https://github.com/apache/druid.git
address cr
This commit is contained in:
parent
9ca4f564ee
commit
5aa46d08a8
|
@ -49,8 +49,27 @@ public class TimeBoundaryQuery extends BaseQuery<Result<TimeBoundaryResultValue>
|
||||||
);
|
);
|
||||||
public static final String MAX_TIME = "maxTime";
|
public static final String MAX_TIME = "maxTime";
|
||||||
public static final String MIN_TIME = "minTime";
|
public static final String MIN_TIME = "minTime";
|
||||||
|
|
||||||
private static final byte CACHE_TYPE_ID = 0x0;
|
private static final byte CACHE_TYPE_ID = 0x0;
|
||||||
|
|
||||||
|
public static Iterable<Result<TimeBoundaryResultValue>> buildResult(DateTime timestamp, DateTime min, DateTime max)
|
||||||
|
{
|
||||||
|
List<Result<TimeBoundaryResultValue>> results = Lists.newArrayList();
|
||||||
|
Map<String, Object> result = Maps.newHashMap();
|
||||||
|
|
||||||
|
if (min != null) {
|
||||||
|
result.put(MIN_TIME, min);
|
||||||
|
}
|
||||||
|
if (max != null) {
|
||||||
|
result.put(MAX_TIME, max);
|
||||||
|
}
|
||||||
|
if (!result.isEmpty()) {
|
||||||
|
results.add(new Result<>(timestamp, new TimeBoundaryResultValue(result)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
private final String bound;
|
private final String bound;
|
||||||
|
|
||||||
@JsonCreator
|
@JsonCreator
|
||||||
|
@ -142,24 +161,6 @@ public class TimeBoundaryQuery extends BaseQuery<Result<TimeBoundaryResultValue>
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
public Iterable<Result<TimeBoundaryResultValue>> buildResult(DateTime timestamp, DateTime min, DateTime max)
|
|
||||||
{
|
|
||||||
List<Result<TimeBoundaryResultValue>> results = Lists.newArrayList();
|
|
||||||
Map<String, Object> result = Maps.newHashMap();
|
|
||||||
|
|
||||||
if (min != null) {
|
|
||||||
result.put(MIN_TIME, min);
|
|
||||||
}
|
|
||||||
if (max != null) {
|
|
||||||
result.put(MAX_TIME, max);
|
|
||||||
}
|
|
||||||
if (!result.isEmpty()) {
|
|
||||||
results.add(new Result<>(timestamp, new TimeBoundaryResultValue(result)));
|
|
||||||
}
|
|
||||||
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Iterable<Result<TimeBoundaryResultValue>> mergeResults(List<Result<TimeBoundaryResultValue>> results)
|
public Iterable<Result<TimeBoundaryResultValue>> mergeResults(List<Result<TimeBoundaryResultValue>> results)
|
||||||
{
|
{
|
||||||
if (results == null || results.isEmpty()) {
|
if (results == null || results.isEmpty()) {
|
||||||
|
@ -181,28 +182,24 @@ public class TimeBoundaryQuery extends BaseQuery<Result<TimeBoundaryResultValue>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>();
|
|
||||||
final DateTime ts;
|
final DateTime ts;
|
||||||
|
final DateTime minTime;
|
||||||
|
final DateTime maxTime;
|
||||||
|
|
||||||
if (bound.equalsIgnoreCase(MIN_TIME)) {
|
if (bound.equalsIgnoreCase(MIN_TIME)) {
|
||||||
ts = min;
|
ts = min;
|
||||||
builder.put(MIN_TIME, max);
|
minTime = min;
|
||||||
|
maxTime = null;
|
||||||
} else if (bound.equalsIgnoreCase(MAX_TIME)) {
|
} else if (bound.equalsIgnoreCase(MAX_TIME)) {
|
||||||
ts = max;
|
ts = max;
|
||||||
builder.put(MAX_TIME, min);
|
minTime = null;
|
||||||
|
maxTime = max;
|
||||||
} else {
|
} else {
|
||||||
ts = min;
|
ts = min;
|
||||||
builder.put(MIN_TIME, min);
|
minTime = min;
|
||||||
builder.put(MAX_TIME, max);
|
maxTime = max;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Arrays.asList(
|
return buildResult(ts, minTime, maxTime);
|
||||||
new Result<>(
|
|
||||||
ts,
|
|
||||||
new TimeBoundaryResultValue(
|
|
||||||
builder.build()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue