From dfe4aa9681d04b8a31dcc1486e0447f29f6eb7bd Mon Sep 17 00:00:00 2001 From: Justin Borromeo Date: Wed, 6 Feb 2019 13:41:18 -0800 Subject: [PATCH] Fixed codestyle and forbidden API errors --- .../query/scan/ScanQueryQueryToolChest.java | 8 ++-- .../scan/ScanQueryQueryToolChestTest.java | 14 ++++--- ...canResultValueTimestampComparatorTest.java | 38 +++++++++++++------ 3 files changed, 39 insertions(+), 21 deletions(-) diff --git a/processing/src/main/java/org/apache/druid/query/scan/ScanQueryQueryToolChest.java b/processing/src/main/java/org/apache/druid/query/scan/ScanQueryQueryToolChest.java index 337b016e14f..0681ad71412 100644 --- a/processing/src/main/java/org/apache/druid/query/scan/ScanQueryQueryToolChest.java +++ b/processing/src/main/java/org/apache/druid/query/scan/ScanQueryQueryToolChest.java @@ -165,14 +165,14 @@ public class ScanQueryQueryToolChest extends QueryToolChest heapsortScanResultValues(Iterator inputIterator, ScanQuery scanQuery) { + Iterator heapsortScanResultValues(Iterator inputIterator, ScanQuery scanQuery) + { Comparator priorityQComparator = new ScanResultValueTimestampComparator(scanQuery); // Converting the limit from long to int could theoretically throw an ArithmeticException but this branch // only runs if limit < MAX_LIMIT_FOR_IN_MEMORY_TIME_ORDERING (which should be < Integer.MAX_VALUE) - PriorityQueue q = new PriorityQueue<> - (Math.toIntExact(scanQuery.getLimit()), priorityQComparator); + PriorityQueue q = new PriorityQueue<>(Math.toIntExact(scanQuery.getLimit()), priorityQComparator); while (inputIterator.hasNext()) { @@ -187,7 +187,7 @@ public class ScanQueryQueryToolChest extends QueryToolChest sortedElements = new ArrayList<>(q.size()); - while (q.size() != 0 ) { + while (q.size() != 0) { sortedElements.add(q.poll()); } return sortedElements.iterator(); diff --git a/processing/src/test/java/org/apache/druid/query/scan/ScanQueryQueryToolChestTest.java b/processing/src/test/java/org/apache/druid/query/scan/ScanQueryQueryToolChestTest.java index 6a556ea5d2c..f3c69b5e53d 100644 --- a/processing/src/test/java/org/apache/druid/query/scan/ScanQueryQueryToolChestTest.java +++ b/processing/src/test/java/org/apache/druid/query/scan/ScanQueryQueryToolChestTest.java @@ -86,7 +86,8 @@ public class ScanQueryQueryToolChestTest @Override public QueryRunner lookup( - Query query, QuerySegmentWalker walker + Query query, + QuerySegmentWalker walker ) { return null; @@ -138,7 +139,8 @@ public class ScanQueryQueryToolChestTest @Override public QueryRunner lookup( - Query query, QuerySegmentWalker walker + Query query, + QuerySegmentWalker walker ) { return null; @@ -188,7 +190,8 @@ public class ScanQueryQueryToolChestTest @Override public QueryRunner lookup( - Query query, QuerySegmentWalker walker + Query query, + QuerySegmentWalker walker ) { return null; @@ -199,7 +202,7 @@ public class ScanQueryQueryToolChestTest Iterator sorted = chest.heapsortScanResultValues(inputs.iterator(), scanQuery); Long previousTime = Long.MAX_VALUE; - int count = 0 ; + int count = 0; while (sorted.hasNext()) { count++; ScanResultValue curr = sorted.next(); @@ -238,7 +241,8 @@ public class ScanQueryQueryToolChestTest @Override public QueryRunner lookup( - Query query, QuerySegmentWalker walker + Query query, + QuerySegmentWalker walker ) { return null; diff --git a/processing/src/test/java/org/apache/druid/query/scan/ScanResultValueTimestampComparatorTest.java b/processing/src/test/java/org/apache/druid/query/scan/ScanResultValueTimestampComparatorTest.java index d7d860fb00c..9492269e8ba 100644 --- a/processing/src/test/java/org/apache/druid/query/scan/ScanResultValueTimestampComparatorTest.java +++ b/processing/src/test/java/org/apache/druid/query/scan/ScanResultValueTimestampComparatorTest.java @@ -19,6 +19,7 @@ package org.apache.druid.query.scan; +import org.apache.druid.java.util.common.DateTimes; import org.apache.druid.query.Druids; import org.apache.druid.query.spec.MultipleIntervalSegmentSpec; import org.apache.druid.query.spec.QuerySegmentSpec; @@ -38,8 +39,13 @@ public class ScanResultValueTimestampComparatorTest private static QuerySegmentSpec intervalSpec; @BeforeClass - public void setup() { - intervalSpec = new MultipleIntervalSegmentSpec(Collections.singletonList(new Interval(0, 1))); + public void setup() + { + intervalSpec = new MultipleIntervalSegmentSpec( + Collections.singletonList( + new Interval(DateTimes.of("2012-01-01"), DateTimes.of("2012-01-01").plusHours(1)) + ) + ); } @@ -55,7 +61,7 @@ public class ScanResultValueTimestampComparatorTest ScanResultValueTimestampComparator comparator = new ScanResultValueTimestampComparator(query); - ArrayList> events1 = new ArrayList<>(); + ArrayList> events1 = new ArrayList<>();` ` HashMap event1 = new HashMap<>(); event1.put(ColumnHolder.TIME_COLUMN_NAME, new Long(42)); events1.add(event1); @@ -63,7 +69,8 @@ public class ScanResultValueTimestampComparatorTest ScanResultValue s1 = new ScanResultValue( "segmentId", Collections.singletonList(ColumnHolder.TIME_COLUMN_NAME), - events1); + events1 + ); ArrayList> events2 = new ArrayList<>(); HashMap event2 = new HashMap<>(); @@ -73,7 +80,8 @@ public class ScanResultValueTimestampComparatorTest ScanResultValue s2 = new ScanResultValue( "segmentId", Collections.singletonList(ColumnHolder.TIME_COLUMN_NAME), - events2); + events2 + ); Assert.assertEquals(1, comparator.compare(s1, s2)); } @@ -90,7 +98,7 @@ public class ScanResultValueTimestampComparatorTest ScanResultValueTimestampComparator comparator = new ScanResultValueTimestampComparator(query); - ArrayList> events1 = new ArrayList<>(); + ArrayList> events1 = new ArrayList<>(); HashMap event1 = new HashMap<>(); event1.put(ColumnHolder.TIME_COLUMN_NAME, new Long(42)); events1.add(event1); @@ -98,7 +106,8 @@ public class ScanResultValueTimestampComparatorTest ScanResultValue s1 = new ScanResultValue( "segmentId", Collections.singletonList(ColumnHolder.TIME_COLUMN_NAME), - events1); + events1 + ); ArrayList> events2 = new ArrayList<>(); HashMap event2 = new HashMap<>(); @@ -108,7 +117,8 @@ public class ScanResultValueTimestampComparatorTest ScanResultValue s2 = new ScanResultValue( "segmentId", Collections.singletonList(ColumnHolder.TIME_COLUMN_NAME), - events2); + events2 + ); Assert.assertEquals(-1, comparator.compare(s1, s2)); } @@ -132,7 +142,8 @@ public class ScanResultValueTimestampComparatorTest ScanResultValue s1 = new ScanResultValue( "segmentId", Collections.singletonList(ColumnHolder.TIME_COLUMN_NAME), - events1); + events1 + ); List> events2 = new ArrayList<>(); List event2 = Collections.singletonList(new Long(43)); @@ -141,7 +152,8 @@ public class ScanResultValueTimestampComparatorTest ScanResultValue s2 = new ScanResultValue( "segmentId", Collections.singletonList(ColumnHolder.TIME_COLUMN_NAME), - events2); + events2 + ); Assert.assertEquals(1, comparator.compare(s1, s2)); } @@ -165,7 +177,8 @@ public class ScanResultValueTimestampComparatorTest ScanResultValue s1 = new ScanResultValue( "segmentId", Collections.singletonList(ColumnHolder.TIME_COLUMN_NAME), - events1); + events1 + ); List> events2 = new ArrayList<>(); List event2 = Collections.singletonList(new Long(43)); @@ -174,7 +187,8 @@ public class ScanResultValueTimestampComparatorTest ScanResultValue s2 = new ScanResultValue( "segmentId", Collections.singletonList(ColumnHolder.TIME_COLUMN_NAME), - events2); + events2 + ); Assert.assertEquals(-1, comparator.compare(s1, s2)); }