From 488b3ef8ff57dfe0c2993e813d780fc3d1061a74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scheibe?= Date: Sat, 6 Apr 2013 12:38:35 +0200 Subject: [PATCH] refactoring - made json type infos consistent for all query types --- client/src/main/java/com/metamx/druid/Query.java | 6 ++++-- .../java/com/metamx/druid/query/group/GroupByQuery.java | 2 +- .../metamx/druid/query/metadata/SegmentMetadataQuery.java | 4 +++- .../com/metamx/druid/query/timeseries/TimeseriesQuery.java | 4 +--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/client/src/main/java/com/metamx/druid/Query.java b/client/src/main/java/com/metamx/druid/Query.java index e39927cb3de..02b81bc6586 100644 --- a/client/src/main/java/com/metamx/druid/Query.java +++ b/client/src/main/java/com/metamx/druid/Query.java @@ -42,14 +42,16 @@ import java.util.Map; @JsonSubTypes.Type(name = Query.TIMESERIES, value = TimeseriesQuery.class), @JsonSubTypes.Type(name = Query.SEARCH, value = SearchQuery.class), @JsonSubTypes.Type(name = Query.TIME_BOUNDARY, value = TimeBoundaryQuery.class), - @JsonSubTypes.Type(name = "groupBy", value= GroupByQuery.class), - @JsonSubTypes.Type(name = "segmentMetadata", value= SegmentMetadataQuery.class) + @JsonSubTypes.Type(name = Query.GROUP_BY, value = GroupByQuery.class), + @JsonSubTypes.Type(name = Query.SEGMENT_METADATA, value = SegmentMetadataQuery.class) }) public interface Query { public static final String TIMESERIES = "timeseries"; public static final String SEARCH = "search"; public static final String TIME_BOUNDARY = "timeBoundary"; + public static final String GROUP_BY = "groupBy"; + public static final String SEGMENT_METADATA = "segmentMetadata"; public String getDataSource(); diff --git a/client/src/main/java/com/metamx/druid/query/group/GroupByQuery.java b/client/src/main/java/com/metamx/druid/query/group/GroupByQuery.java index 5cc16bae920..8299187f655 100644 --- a/client/src/main/java/com/metamx/druid/query/group/GroupByQuery.java +++ b/client/src/main/java/com/metamx/druid/query/group/GroupByQuery.java @@ -116,7 +116,7 @@ public class GroupByQuery extends BaseQuery @Override public String getType() { - return "groupBy"; + return Query.GROUP_BY; } @Override diff --git a/client/src/main/java/com/metamx/druid/query/metadata/SegmentMetadataQuery.java b/client/src/main/java/com/metamx/druid/query/metadata/SegmentMetadataQuery.java index e22d51b6fc9..4be24fdaf95 100644 --- a/client/src/main/java/com/metamx/druid/query/metadata/SegmentMetadataQuery.java +++ b/client/src/main/java/com/metamx/druid/query/metadata/SegmentMetadataQuery.java @@ -19,6 +19,7 @@ package com.metamx.druid.query.metadata; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.metamx.druid.BaseQuery; import com.metamx.druid.Query; @@ -32,6 +33,7 @@ public class SegmentMetadataQuery extends BaseQuery private final ColumnIncluderator toInclude; private final boolean merge; + @JsonCreator public SegmentMetadataQuery( @JsonProperty("dataSource") String dataSource, @JsonProperty("intervals") QuerySegmentSpec querySegmentSpec, @@ -67,7 +69,7 @@ public class SegmentMetadataQuery extends BaseQuery @Override public String getType() { - return "segmentMetadata"; + return Query.SEGMENT_METADATA; } @Override diff --git a/client/src/main/java/com/metamx/druid/query/timeseries/TimeseriesQuery.java b/client/src/main/java/com/metamx/druid/query/timeseries/TimeseriesQuery.java index 8c5797753a1..ff55a79b65a 100644 --- a/client/src/main/java/com/metamx/druid/query/timeseries/TimeseriesQuery.java +++ b/client/src/main/java/com/metamx/druid/query/timeseries/TimeseriesQuery.java @@ -43,8 +43,6 @@ import java.util.Map; @JsonTypeName("timeseries") public class TimeseriesQuery extends BaseQuery> { - public static final String TIMESERIES = "timeseries"; - private final DimFilter dimFilter; private final QueryGranularity granularity; private final List aggregatorSpecs; @@ -79,7 +77,7 @@ public class TimeseriesQuery extends BaseQuery> @Override public String getType() { - return TIMESERIES; + return Query.TIMESERIES; } @JsonProperty("filter")