mirror of
https://github.com/apache/druid.git
synced 2025-02-17 07:25:02 +00:00
Merge pull request #1085 from gianm/dsmrv-fix
DataSourceMetadataResultValue fixes and JodaUtils adjustments.
This commit is contained in:
commit
25cf15824b
@ -33,9 +33,9 @@ import java.util.TreeSet;
|
||||
*/
|
||||
public class JodaUtils
|
||||
{
|
||||
// joda limits years to [-292275054,292278993] that should be reasonable
|
||||
public static final long MAX_INSTANT = new DateTime("292278993").getMillis();
|
||||
public static final long MIN_INSTANT = new DateTime("-292275054").getMillis();
|
||||
// limit intervals such that duration millis fits in a long
|
||||
public static final long MAX_INSTANT = Long.MAX_VALUE / 2;
|
||||
public static final long MIN_INSTANT = Long.MIN_VALUE / 2;
|
||||
|
||||
public static ArrayList<Interval> condenseIntervals(Iterable<Interval> intervals)
|
||||
{
|
||||
|
@ -117,4 +117,11 @@ public class JodaUtilsTest
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinMaxInterval()
|
||||
{
|
||||
final Interval interval = new Interval(JodaUtils.MIN_INSTANT, JodaUtils.MAX_INSTANT);
|
||||
Assert.assertEquals(Long.MAX_VALUE, interval.toDuration().getMillis());
|
||||
}
|
||||
}
|
||||
|
@ -42,9 +42,6 @@ public class DataSourceMetadataQuery extends BaseQuery<Result<DataSourceMetadata
|
||||
JodaUtils.MIN_INSTANT, JodaUtils.MAX_INSTANT
|
||||
);
|
||||
|
||||
public static String MAX_INGESTED_EVENT_TIME = "maxIngestedEventTime";
|
||||
|
||||
|
||||
@JsonCreator
|
||||
public DataSourceMetadataQuery(
|
||||
@JsonProperty("dataSource") DataSource dataSource,
|
||||
|
@ -18,7 +18,7 @@
|
||||
package io.druid.query.datasourcemetadata;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
@ -29,13 +29,13 @@ public class DataSourceMetadataResultValue
|
||||
|
||||
@JsonCreator
|
||||
public DataSourceMetadataResultValue(
|
||||
DateTime maxIngestedEventTime
|
||||
@JsonProperty("maxIngestedEventTime") DateTime maxIngestedEventTime
|
||||
)
|
||||
{
|
||||
this.maxIngestedEventTime = maxIngestedEventTime;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
@JsonProperty
|
||||
public DateTime getMaxIngestedEventTime()
|
||||
{
|
||||
return maxIngestedEventTime;
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package io.druid.query.datasourcemetadata;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
@ -70,20 +71,20 @@ public class DataSourceMetadataQueryTest
|
||||
public void testContextSerde() throws Exception
|
||||
{
|
||||
final DataSourceMetadataQuery query = Druids.newDataSourceMetadataQueryBuilder()
|
||||
.dataSource("foo")
|
||||
.intervals("2013/2014")
|
||||
.context(
|
||||
ImmutableMap.<String, Object>of(
|
||||
"priority",
|
||||
1,
|
||||
"useCache",
|
||||
true,
|
||||
"populateCache",
|
||||
true,
|
||||
"finalize",
|
||||
true
|
||||
)
|
||||
).build();
|
||||
.dataSource("foo")
|
||||
.intervals("2013/2014")
|
||||
.context(
|
||||
ImmutableMap.<String, Object>of(
|
||||
"priority",
|
||||
1,
|
||||
"useCache",
|
||||
true,
|
||||
"populateCache",
|
||||
true,
|
||||
"finalize",
|
||||
true
|
||||
)
|
||||
).build();
|
||||
|
||||
final ObjectMapper mapper = new DefaultObjectMapper();
|
||||
|
||||
@ -108,7 +109,8 @@ public class DataSourceMetadataQueryTest
|
||||
{
|
||||
final IncrementalIndex rtIndex = new OnheapIncrementalIndex(
|
||||
0L, QueryGranularity.NONE, new AggregatorFactory[]{new CountAggregatorFactory("count")}, 1000
|
||||
);;
|
||||
);
|
||||
;
|
||||
final QueryRunner runner = QueryRunnerTestHelper.makeQueryRunner(
|
||||
(QueryRunnerFactory) new DataSourceMetadataQueryRunnerFactory(
|
||||
QueryRunnerTestHelper.NOOP_QUERYWATCHER
|
||||
@ -123,8 +125,8 @@ public class DataSourceMetadataQueryTest
|
||||
)
|
||||
);
|
||||
DataSourceMetadataQuery dataSourceMetadataQuery = Druids.newDataSourceMetadataQueryBuilder()
|
||||
.dataSource("testing")
|
||||
.build();
|
||||
.dataSource("testing")
|
||||
.build();
|
||||
Map<String, Object> context = new MapMaker().makeMap();
|
||||
context.put(Result.MISSING_SEGMENTS_KEY, Lists.newArrayList());
|
||||
Iterable<Result<DataSourceMetadataResultValue>> results = Sequences.toList(
|
||||
@ -204,4 +206,34 @@ public class DataSourceMetadataQueryTest
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResultSerialization()
|
||||
{
|
||||
final DataSourceMetadataResultValue resultValue = new DataSourceMetadataResultValue(new DateTime("2000-01-01T00Z"));
|
||||
final Map<String, Object> resultValueMap = new DefaultObjectMapper().convertValue(
|
||||
resultValue,
|
||||
new TypeReference<Map<String, Object>>()
|
||||
{
|
||||
}
|
||||
);
|
||||
Assert.assertEquals(
|
||||
ImmutableMap.<String, Object>of("maxIngestedEventTime", "2000-01-01T00:00:00.000Z"),
|
||||
resultValueMap
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResultDeserialization()
|
||||
{
|
||||
final Map<String, Object> resultValueMap = ImmutableMap.<String, Object>of(
|
||||
"maxIngestedEventTime",
|
||||
"2000-01-01T00:00:00.000Z"
|
||||
);
|
||||
final DataSourceMetadataResultValue resultValue = new DefaultObjectMapper().convertValue(
|
||||
resultValueMap,
|
||||
DataSourceMetadataResultValue.class
|
||||
);
|
||||
Assert.assertEquals(new DateTime("2000"), resultValue.getMaxIngestedEventTime());
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user