Fixed codestyle and forbidden API errors

This commit is contained in:
Justin Borromeo 2019-02-06 13:41:18 -08:00
parent 148939e88b
commit dfe4aa9681
3 changed files with 39 additions and 21 deletions

View File

@ -165,14 +165,14 @@ public class ScanQueryQueryToolChest extends QueryToolChest<ScanResultValue, Sca
}
@VisibleForTesting
Iterator<ScanResultValue> heapsortScanResultValues(Iterator<ScanResultValue> inputIterator, ScanQuery scanQuery) {
Iterator<ScanResultValue> heapsortScanResultValues(Iterator<ScanResultValue> inputIterator, ScanQuery scanQuery)
{
Comparator<ScanResultValue> 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<ScanResultValue> q = new PriorityQueue<>
(Math.toIntExact(scanQuery.getLimit()), priorityQComparator);
PriorityQueue<ScanResultValue> q = new PriorityQueue<>(Math.toIntExact(scanQuery.getLimit()), priorityQComparator);
while (inputIterator.hasNext()) {

View File

@ -86,7 +86,8 @@ public class ScanQueryQueryToolChestTest
@Override
public <T> QueryRunner<T> lookup(
Query<T> query, QuerySegmentWalker walker
Query<T> query,
QuerySegmentWalker walker
)
{
return null;
@ -138,7 +139,8 @@ public class ScanQueryQueryToolChestTest
@Override
public <T> QueryRunner<T> lookup(
Query<T> query, QuerySegmentWalker walker
Query<T> query,
QuerySegmentWalker walker
)
{
return null;
@ -188,7 +190,8 @@ public class ScanQueryQueryToolChestTest
@Override
public <T> QueryRunner<T> lookup(
Query<T> query, QuerySegmentWalker walker
Query<T> query,
QuerySegmentWalker walker
)
{
return null;
@ -238,7 +241,8 @@ public class ScanQueryQueryToolChestTest
@Override
public <T> QueryRunner<T> lookup(
Query<T> query, QuerySegmentWalker walker
Query<T> query,
QuerySegmentWalker walker
)
{
return null;

View File

@ -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<HashMap<String, Object>> events1 = new ArrayList<>();
ArrayList<HashMap<String, Object>> events1 = new ArrayList<>();` `
HashMap<String, Object> 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<HashMap<String, Object>> events2 = new ArrayList<>();
HashMap<String, Object> 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));
}
@ -98,7 +106,8 @@ public class ScanResultValueTimestampComparatorTest
ScanResultValue s1 = new ScanResultValue(
"segmentId",
Collections.singletonList(ColumnHolder.TIME_COLUMN_NAME),
events1);
events1
);
ArrayList<HashMap<String, Object>> events2 = new ArrayList<>();
HashMap<String, Object> 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<List<Object>> events2 = new ArrayList<>();
List<Object> 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<List<Object>> events2 = new ArrayList<>();
List<Object> 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));
}