mirror of https://github.com/apache/druid.git
review comments
This commit is contained in:
parent
a0d3579a92
commit
80e4b68ee7
|
@ -42,8 +42,7 @@ import java.util.Map;
|
|||
public class DataSourceMetadataQuery extends BaseQuery<Result<DataSourceMetadataResultValue>>
|
||||
{
|
||||
public static final Interval MY_Y2K_INTERVAL = new Interval(
|
||||
new DateTime("0000-01-01"),
|
||||
new DateTime("3000-01-01")
|
||||
JodaUtils.MIN_INSTANT, JodaUtils.MAX_INSTANT
|
||||
);
|
||||
|
||||
public static String MAX_INGESTED_EVENT_TIME = "maxIngestedEventTime";
|
||||
|
@ -108,17 +107,7 @@ public class DataSourceMetadataQuery extends BaseQuery<Result<DataSourceMetadata
|
|||
|
||||
public Iterable<Result<DataSourceMetadataResultValue>> buildResult(DateTime timestamp, DateTime maxIngestedEventTime)
|
||||
{
|
||||
List<Result<DataSourceMetadataResultValue>> results = Lists.newArrayList();
|
||||
Map<String, Object> result = Maps.newHashMap();
|
||||
|
||||
if (maxIngestedEventTime != null) {
|
||||
result.put(MAX_INGESTED_EVENT_TIME, maxIngestedEventTime);
|
||||
}
|
||||
if (!result.isEmpty()) {
|
||||
results.add(new Result<>(timestamp, new DataSourceMetadataResultValue(result)));
|
||||
}
|
||||
|
||||
return results;
|
||||
return Arrays.asList(new Result<>(timestamp, new DataSourceMetadataResultValue(maxIngestedEventTime)));
|
||||
}
|
||||
|
||||
public Iterable<Result<DataSourceMetadataResultValue>> mergeResults(List<Result<DataSourceMetadataResultValue>> results)
|
||||
|
|
|
@ -21,38 +21,26 @@ package io.druid.query.datasourcemetadata;
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import com.metamx.common.IAE;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class DataSourceMetadataResultValue
|
||||
{
|
||||
private final Object value;
|
||||
private final DateTime maxIngestedEventTime;
|
||||
|
||||
@JsonCreator
|
||||
public DataSourceMetadataResultValue(
|
||||
Object value
|
||||
DateTime maxIngestedEventTime
|
||||
)
|
||||
{
|
||||
this.value = value;
|
||||
this.maxIngestedEventTime = maxIngestedEventTime;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public Object getBaseObject()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
public DateTime getMaxIngestedEventTime()
|
||||
{
|
||||
if (value instanceof Map) {
|
||||
return getDateTimeValue(((Map) value).get(DataSourceMetadataQuery.MAX_INGESTED_EVENT_TIME));
|
||||
} else {
|
||||
return getDateTimeValue(value);
|
||||
}
|
||||
return maxIngestedEventTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -67,7 +55,9 @@ public class DataSourceMetadataResultValue
|
|||
|
||||
DataSourceMetadataResultValue that = (DataSourceMetadataResultValue) o;
|
||||
|
||||
if (value != null ? !value.equals(that.value) : that.value != null) {
|
||||
if (maxIngestedEventTime != null
|
||||
? !maxIngestedEventTime.equals(that.maxIngestedEventTime)
|
||||
: that.maxIngestedEventTime != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -77,29 +67,14 @@ public class DataSourceMetadataResultValue
|
|||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return value != null ? value.hashCode() : 0;
|
||||
return maxIngestedEventTime != null ? maxIngestedEventTime.hashCode() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "DataSourceMetadataResultValue{" +
|
||||
"value=" + value +
|
||||
"maxIngestedEventTime=" + maxIngestedEventTime +
|
||||
'}';
|
||||
}
|
||||
|
||||
private DateTime getDateTimeValue(Object val)
|
||||
{
|
||||
if (val == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (val instanceof DateTime) {
|
||||
return (DateTime) val;
|
||||
} else if (val instanceof String) {
|
||||
return new DateTime(val);
|
||||
} else {
|
||||
throw new IAE("Cannot get time from type[%s]", val.getClass());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue