From 43d3c53806084286f91b42c01ad1c6e5370d8b95 Mon Sep 17 00:00:00 2001 From: fjy Date: Wed, 8 May 2013 10:14:40 -0700 Subject: [PATCH 1/3] fix order by double sum agg --- .../aggregation/DoubleSumAggregator.java | 3 +- .../query/group/GroupByQueryRunnerTest.java | 39 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/com/metamx/druid/aggregation/DoubleSumAggregator.java b/common/src/main/java/com/metamx/druid/aggregation/DoubleSumAggregator.java index 545c8c64feb..15dc4736b63 100644 --- a/common/src/main/java/com/metamx/druid/aggregation/DoubleSumAggregator.java +++ b/common/src/main/java/com/metamx/druid/aggregation/DoubleSumAggregator.java @@ -19,6 +19,7 @@ package com.metamx.druid.aggregation; +import com.google.common.primitives.Doubles; import com.metamx.druid.processing.FloatMetricSelector; import java.util.Comparator; @@ -32,7 +33,7 @@ public class DoubleSumAggregator implements Aggregator @Override public int compare(Object o, Object o1) { - return ((Double) o).compareTo((Double) o1); + return Doubles.compare(((Number) o).doubleValue(), ((Number) o1).doubleValue()); } }; diff --git a/server/src/test/java/com/metamx/druid/query/group/GroupByQueryRunnerTest.java b/server/src/test/java/com/metamx/druid/query/group/GroupByQueryRunnerTest.java index c713dee7090..7dfc83f6f4f 100644 --- a/server/src/test/java/com/metamx/druid/query/group/GroupByQueryRunnerTest.java +++ b/server/src/test/java/com/metamx/druid/query/group/GroupByQueryRunnerTest.java @@ -32,6 +32,7 @@ import com.metamx.druid.Query; import com.metamx.druid.QueryGranularity; import com.metamx.druid.TestHelper; import com.metamx.druid.aggregation.AggregatorFactory; +import com.metamx.druid.aggregation.DoubleSumAggregatorFactory; import com.metamx.druid.aggregation.LongSumAggregatorFactory; import com.metamx.druid.collect.StupidPool; import com.metamx.druid.input.MapBasedRow; @@ -361,7 +362,45 @@ public class GroupByQueryRunnerTest TestHelper.assertExpectedObjects( Iterables.limit(expectedResults, 5), mergeRunner.run(builder.limit(5).build()), "limited" ); + } + @Test + public void testGroupByWithOrderLimit3() throws Exception + { + GroupByQuery.Builder builder = GroupByQuery + .builder() + .setDataSource(QueryRunnerTestHelper.dataSource) + .setInterval("2011-04-02/2011-04-04") + .setDimensions(Lists.newArrayList(new DefaultDimensionSpec("quality", "alias"))) + .setAggregatorSpecs( + Arrays.asList( + QueryRunnerTestHelper.rowsCount, + new DoubleSumAggregatorFactory("idx", "index") + ) + ) + .addOrderByColumn("idx", "desc") + .addOrderByColumn("alias", "d") + .setGranularity(new PeriodGranularity(new Period("P1M"), null, null)); + + final GroupByQuery query = builder.build(); + + List expectedResults = Arrays.asList( + createExpectedRow("2011-04-01", "alias", "mezzanine", "rows", 6L, "idx", 4423.6533203125D), + createExpectedRow("2011-04-01", "alias", "premium", "rows", 6L, "idx", 4418.61865234375D), + createExpectedRow("2011-04-01", "alias", "entertainment", "rows", 2L, "idx", 319.94403076171875D), + createExpectedRow("2011-04-01", "alias", "automotive", "rows", 2L, "idx", 270.3977966308594D), + createExpectedRow("2011-04-01", "alias", "travel", "rows", 2L, "idx", 243.65843200683594D), + createExpectedRow("2011-04-01", "alias", "news", "rows", 2L, "idx", 222.20980834960938D), + createExpectedRow("2011-04-01", "alias", "business", "rows", 2L, "idx", 218.7224884033203D), + createExpectedRow("2011-04-01", "alias", "health", "rows", 2L, "idx", 216.97836303710938D), + createExpectedRow("2011-04-01", "alias", "technology", "rows", 2L, "idx", 178.24917602539062D) + ); + + QueryRunner mergeRunner = new GroupByQueryQueryToolChest().mergeResults(runner); + TestHelper.assertExpectedObjects(expectedResults, mergeRunner.run(query), "no-limit"); + TestHelper.assertExpectedObjects( + Iterables.limit(expectedResults, 5), mergeRunner.run(builder.limit(5).build()), "limited" + ); } private Row createExpectedRow(final String timestamp, Object... vals) From 758baa913b40457480b5ba852640682ed97a22d3 Mon Sep 17 00:00:00 2001 From: fjy Date: Wed, 8 May 2013 10:17:17 -0700 Subject: [PATCH 2/3] [maven-release-plugin] prepare release druid-0.4.7 --- client/pom.xml | 2 +- common/pom.xml | 2 +- examples/pom.xml | 2 +- index-common/pom.xml | 2 +- indexer/pom.xml | 2 +- merger/pom.xml | 2 +- pom.xml | 2 +- realtime/pom.xml | 2 +- server/pom.xml | 2 +- services/pom.xml | 4 ++-- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/client/pom.xml b/client/pom.xml index 1d193d8584d..a6067ba2298 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -28,7 +28,7 @@ com.metamx druid - 0.4.7-SNAPSHOT + 0.4.7 diff --git a/common/pom.xml b/common/pom.xml index 31831cf71fa..b79e865b382 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -28,7 +28,7 @@ com.metamx druid - 0.4.7-SNAPSHOT + 0.4.7 diff --git a/examples/pom.xml b/examples/pom.xml index d824c8487d4..ac4a1fe7b91 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -9,7 +9,7 @@ com.metamx druid - 0.4.7-SNAPSHOT + 0.4.7 diff --git a/index-common/pom.xml b/index-common/pom.xml index 105c9d383e0..e4a49336c77 100644 --- a/index-common/pom.xml +++ b/index-common/pom.xml @@ -28,7 +28,7 @@ com.metamx druid - 0.4.7-SNAPSHOT + 0.4.7 diff --git a/indexer/pom.xml b/indexer/pom.xml index 697b6162295..8e701d75e36 100644 --- a/indexer/pom.xml +++ b/indexer/pom.xml @@ -28,7 +28,7 @@ com.metamx druid - 0.4.7-SNAPSHOT + 0.4.7 diff --git a/merger/pom.xml b/merger/pom.xml index 4746fc7d7ff..4dad2baeda3 100644 --- a/merger/pom.xml +++ b/merger/pom.xml @@ -28,7 +28,7 @@ com.metamx druid - 0.4.7-SNAPSHOT + 0.4.7 diff --git a/pom.xml b/pom.xml index d4ffa9c7ce3..d2680c51aa7 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ com.metamx druid pom - 0.4.7-SNAPSHOT + 0.4.7 druid druid diff --git a/realtime/pom.xml b/realtime/pom.xml index 91ff1c3fe94..7f325e0f8c6 100644 --- a/realtime/pom.xml +++ b/realtime/pom.xml @@ -28,7 +28,7 @@ com.metamx druid - 0.4.7-SNAPSHOT + 0.4.7 diff --git a/server/pom.xml b/server/pom.xml index 4a12e76743b..9e07f4a9a6d 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -28,7 +28,7 @@ com.metamx druid - 0.4.7-SNAPSHOT + 0.4.7 diff --git a/services/pom.xml b/services/pom.xml index 6bb1271a456..cfc3c256669 100644 --- a/services/pom.xml +++ b/services/pom.xml @@ -24,11 +24,11 @@ druid-services druid-services druid-services - 0.4.7-SNAPSHOT + 0.4.7 com.metamx druid - 0.4.7-SNAPSHOT + 0.4.7 From e20aabd7a9ae6d9c70e5b3d40591623ce87c71dd Mon Sep 17 00:00:00 2001 From: fjy Date: Wed, 8 May 2013 10:17:25 -0700 Subject: [PATCH 3/3] [maven-release-plugin] prepare for next development iteration --- client/pom.xml | 2 +- common/pom.xml | 2 +- examples/pom.xml | 2 +- index-common/pom.xml | 2 +- indexer/pom.xml | 2 +- merger/pom.xml | 2 +- pom.xml | 2 +- realtime/pom.xml | 2 +- server/pom.xml | 2 +- services/pom.xml | 4 ++-- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/client/pom.xml b/client/pom.xml index a6067ba2298..fa78b3b06ab 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -28,7 +28,7 @@ com.metamx druid - 0.4.7 + 0.4.8-SNAPSHOT diff --git a/common/pom.xml b/common/pom.xml index b79e865b382..c2c7fc71fcd 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -28,7 +28,7 @@ com.metamx druid - 0.4.7 + 0.4.8-SNAPSHOT diff --git a/examples/pom.xml b/examples/pom.xml index ac4a1fe7b91..783a9a3f5d0 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -9,7 +9,7 @@ com.metamx druid - 0.4.7 + 0.4.8-SNAPSHOT diff --git a/index-common/pom.xml b/index-common/pom.xml index e4a49336c77..cae9ec9e2f5 100644 --- a/index-common/pom.xml +++ b/index-common/pom.xml @@ -28,7 +28,7 @@ com.metamx druid - 0.4.7 + 0.4.8-SNAPSHOT diff --git a/indexer/pom.xml b/indexer/pom.xml index 8e701d75e36..53f3219fd6d 100644 --- a/indexer/pom.xml +++ b/indexer/pom.xml @@ -28,7 +28,7 @@ com.metamx druid - 0.4.7 + 0.4.8-SNAPSHOT diff --git a/merger/pom.xml b/merger/pom.xml index 4dad2baeda3..59a3d10343a 100644 --- a/merger/pom.xml +++ b/merger/pom.xml @@ -28,7 +28,7 @@ com.metamx druid - 0.4.7 + 0.4.8-SNAPSHOT diff --git a/pom.xml b/pom.xml index d2680c51aa7..72092aec537 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ com.metamx druid pom - 0.4.7 + 0.4.8-SNAPSHOT druid druid diff --git a/realtime/pom.xml b/realtime/pom.xml index 7f325e0f8c6..99c86cdc827 100644 --- a/realtime/pom.xml +++ b/realtime/pom.xml @@ -28,7 +28,7 @@ com.metamx druid - 0.4.7 + 0.4.8-SNAPSHOT diff --git a/server/pom.xml b/server/pom.xml index 9e07f4a9a6d..9e6ad324dbf 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -28,7 +28,7 @@ com.metamx druid - 0.4.7 + 0.4.8-SNAPSHOT diff --git a/services/pom.xml b/services/pom.xml index cfc3c256669..98da65b2b32 100644 --- a/services/pom.xml +++ b/services/pom.xml @@ -24,11 +24,11 @@ druid-services druid-services druid-services - 0.4.7 + 0.4.8-SNAPSHOT com.metamx druid - 0.4.7 + 0.4.8-SNAPSHOT