mirror of https://github.com/apache/druid.git
Fixed codestyle and forbidden API errors
This commit is contained in:
parent
148939e88b
commit
dfe4aa9681
|
@ -165,14 +165,14 @@ public class ScanQueryQueryToolChest extends QueryToolChest<ScanResultValue, Sca
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
Iterator<ScanResultValue> heapsortScanResultValues(Iterator<ScanResultValue> inputIterator, ScanQuery scanQuery) {
|
Iterator<ScanResultValue> heapsortScanResultValues(Iterator<ScanResultValue> inputIterator, ScanQuery scanQuery)
|
||||||
|
{
|
||||||
Comparator<ScanResultValue> priorityQComparator = new ScanResultValueTimestampComparator(scanQuery);
|
Comparator<ScanResultValue> priorityQComparator = new ScanResultValueTimestampComparator(scanQuery);
|
||||||
|
|
||||||
// Converting the limit from long to int could theoretically throw an ArithmeticException but this branch
|
// 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)
|
// only runs if limit < MAX_LIMIT_FOR_IN_MEMORY_TIME_ORDERING (which should be < Integer.MAX_VALUE)
|
||||||
|
|
||||||
PriorityQueue<ScanResultValue> q = new PriorityQueue<>
|
PriorityQueue<ScanResultValue> q = new PriorityQueue<>(Math.toIntExact(scanQuery.getLimit()), priorityQComparator);
|
||||||
(Math.toIntExact(scanQuery.getLimit()), priorityQComparator);
|
|
||||||
|
|
||||||
while (inputIterator.hasNext()) {
|
while (inputIterator.hasNext()) {
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ public class ScanQueryQueryToolChest extends QueryToolChest<ScanResultValue, Sca
|
||||||
// Need to convert to a List because Priority Queue's iterator doesn't guarantee that the sorted order
|
// Need to convert to a List because Priority Queue's iterator doesn't guarantee that the sorted order
|
||||||
// will be maintained
|
// will be maintained
|
||||||
List<ScanResultValue> sortedElements = new ArrayList<>(q.size());
|
List<ScanResultValue> sortedElements = new ArrayList<>(q.size());
|
||||||
while (q.size() != 0 ) {
|
while (q.size() != 0) {
|
||||||
sortedElements.add(q.poll());
|
sortedElements.add(q.poll());
|
||||||
}
|
}
|
||||||
return sortedElements.iterator();
|
return sortedElements.iterator();
|
||||||
|
|
|
@ -86,7 +86,8 @@ public class ScanQueryQueryToolChestTest
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> QueryRunner<T> lookup(
|
public <T> QueryRunner<T> lookup(
|
||||||
Query<T> query, QuerySegmentWalker walker
|
Query<T> query,
|
||||||
|
QuerySegmentWalker walker
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
@ -138,7 +139,8 @@ public class ScanQueryQueryToolChestTest
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> QueryRunner<T> lookup(
|
public <T> QueryRunner<T> lookup(
|
||||||
Query<T> query, QuerySegmentWalker walker
|
Query<T> query,
|
||||||
|
QuerySegmentWalker walker
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
@ -188,7 +190,8 @@ public class ScanQueryQueryToolChestTest
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> QueryRunner<T> lookup(
|
public <T> QueryRunner<T> lookup(
|
||||||
Query<T> query, QuerySegmentWalker walker
|
Query<T> query,
|
||||||
|
QuerySegmentWalker walker
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
@ -199,7 +202,7 @@ public class ScanQueryQueryToolChestTest
|
||||||
Iterator<ScanResultValue> sorted = chest.heapsortScanResultValues(inputs.iterator(), scanQuery);
|
Iterator<ScanResultValue> sorted = chest.heapsortScanResultValues(inputs.iterator(), scanQuery);
|
||||||
|
|
||||||
Long previousTime = Long.MAX_VALUE;
|
Long previousTime = Long.MAX_VALUE;
|
||||||
int count = 0 ;
|
int count = 0;
|
||||||
while (sorted.hasNext()) {
|
while (sorted.hasNext()) {
|
||||||
count++;
|
count++;
|
||||||
ScanResultValue curr = sorted.next();
|
ScanResultValue curr = sorted.next();
|
||||||
|
@ -238,7 +241,8 @@ public class ScanQueryQueryToolChestTest
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> QueryRunner<T> lookup(
|
public <T> QueryRunner<T> lookup(
|
||||||
Query<T> query, QuerySegmentWalker walker
|
Query<T> query,
|
||||||
|
QuerySegmentWalker walker
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package org.apache.druid.query.scan;
|
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.Druids;
|
||||||
import org.apache.druid.query.spec.MultipleIntervalSegmentSpec;
|
import org.apache.druid.query.spec.MultipleIntervalSegmentSpec;
|
||||||
import org.apache.druid.query.spec.QuerySegmentSpec;
|
import org.apache.druid.query.spec.QuerySegmentSpec;
|
||||||
|
@ -38,8 +39,13 @@ public class ScanResultValueTimestampComparatorTest
|
||||||
private static QuerySegmentSpec intervalSpec;
|
private static QuerySegmentSpec intervalSpec;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public void setup() {
|
public void setup()
|
||||||
intervalSpec = new MultipleIntervalSegmentSpec(Collections.singletonList(new Interval(0, 1)));
|
{
|
||||||
|
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);
|
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<>();
|
HashMap<String, Object> event1 = new HashMap<>();
|
||||||
event1.put(ColumnHolder.TIME_COLUMN_NAME, new Long(42));
|
event1.put(ColumnHolder.TIME_COLUMN_NAME, new Long(42));
|
||||||
events1.add(event1);
|
events1.add(event1);
|
||||||
|
@ -63,7 +69,8 @@ public class ScanResultValueTimestampComparatorTest
|
||||||
ScanResultValue s1 = new ScanResultValue(
|
ScanResultValue s1 = new ScanResultValue(
|
||||||
"segmentId",
|
"segmentId",
|
||||||
Collections.singletonList(ColumnHolder.TIME_COLUMN_NAME),
|
Collections.singletonList(ColumnHolder.TIME_COLUMN_NAME),
|
||||||
events1);
|
events1
|
||||||
|
);
|
||||||
|
|
||||||
ArrayList<HashMap<String, Object>> events2 = new ArrayList<>();
|
ArrayList<HashMap<String, Object>> events2 = new ArrayList<>();
|
||||||
HashMap<String, Object> event2 = new HashMap<>();
|
HashMap<String, Object> event2 = new HashMap<>();
|
||||||
|
@ -73,7 +80,8 @@ public class ScanResultValueTimestampComparatorTest
|
||||||
ScanResultValue s2 = new ScanResultValue(
|
ScanResultValue s2 = new ScanResultValue(
|
||||||
"segmentId",
|
"segmentId",
|
||||||
Collections.singletonList(ColumnHolder.TIME_COLUMN_NAME),
|
Collections.singletonList(ColumnHolder.TIME_COLUMN_NAME),
|
||||||
events2);
|
events2
|
||||||
|
);
|
||||||
|
|
||||||
Assert.assertEquals(1, comparator.compare(s1, s2));
|
Assert.assertEquals(1, comparator.compare(s1, s2));
|
||||||
}
|
}
|
||||||
|
@ -90,7 +98,7 @@ public class ScanResultValueTimestampComparatorTest
|
||||||
|
|
||||||
ScanResultValueTimestampComparator comparator = new ScanResultValueTimestampComparator(query);
|
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<>();
|
HashMap<String, Object> event1 = new HashMap<>();
|
||||||
event1.put(ColumnHolder.TIME_COLUMN_NAME, new Long(42));
|
event1.put(ColumnHolder.TIME_COLUMN_NAME, new Long(42));
|
||||||
events1.add(event1);
|
events1.add(event1);
|
||||||
|
@ -98,7 +106,8 @@ public class ScanResultValueTimestampComparatorTest
|
||||||
ScanResultValue s1 = new ScanResultValue(
|
ScanResultValue s1 = new ScanResultValue(
|
||||||
"segmentId",
|
"segmentId",
|
||||||
Collections.singletonList(ColumnHolder.TIME_COLUMN_NAME),
|
Collections.singletonList(ColumnHolder.TIME_COLUMN_NAME),
|
||||||
events1);
|
events1
|
||||||
|
);
|
||||||
|
|
||||||
ArrayList<HashMap<String, Object>> events2 = new ArrayList<>();
|
ArrayList<HashMap<String, Object>> events2 = new ArrayList<>();
|
||||||
HashMap<String, Object> event2 = new HashMap<>();
|
HashMap<String, Object> event2 = new HashMap<>();
|
||||||
|
@ -108,7 +117,8 @@ public class ScanResultValueTimestampComparatorTest
|
||||||
ScanResultValue s2 = new ScanResultValue(
|
ScanResultValue s2 = new ScanResultValue(
|
||||||
"segmentId",
|
"segmentId",
|
||||||
Collections.singletonList(ColumnHolder.TIME_COLUMN_NAME),
|
Collections.singletonList(ColumnHolder.TIME_COLUMN_NAME),
|
||||||
events2);
|
events2
|
||||||
|
);
|
||||||
|
|
||||||
Assert.assertEquals(-1, comparator.compare(s1, s2));
|
Assert.assertEquals(-1, comparator.compare(s1, s2));
|
||||||
}
|
}
|
||||||
|
@ -132,7 +142,8 @@ public class ScanResultValueTimestampComparatorTest
|
||||||
ScanResultValue s1 = new ScanResultValue(
|
ScanResultValue s1 = new ScanResultValue(
|
||||||
"segmentId",
|
"segmentId",
|
||||||
Collections.singletonList(ColumnHolder.TIME_COLUMN_NAME),
|
Collections.singletonList(ColumnHolder.TIME_COLUMN_NAME),
|
||||||
events1);
|
events1
|
||||||
|
);
|
||||||
|
|
||||||
List<List<Object>> events2 = new ArrayList<>();
|
List<List<Object>> events2 = new ArrayList<>();
|
||||||
List<Object> event2 = Collections.singletonList(new Long(43));
|
List<Object> event2 = Collections.singletonList(new Long(43));
|
||||||
|
@ -141,7 +152,8 @@ public class ScanResultValueTimestampComparatorTest
|
||||||
ScanResultValue s2 = new ScanResultValue(
|
ScanResultValue s2 = new ScanResultValue(
|
||||||
"segmentId",
|
"segmentId",
|
||||||
Collections.singletonList(ColumnHolder.TIME_COLUMN_NAME),
|
Collections.singletonList(ColumnHolder.TIME_COLUMN_NAME),
|
||||||
events2);
|
events2
|
||||||
|
);
|
||||||
|
|
||||||
Assert.assertEquals(1, comparator.compare(s1, s2));
|
Assert.assertEquals(1, comparator.compare(s1, s2));
|
||||||
}
|
}
|
||||||
|
@ -165,7 +177,8 @@ public class ScanResultValueTimestampComparatorTest
|
||||||
ScanResultValue s1 = new ScanResultValue(
|
ScanResultValue s1 = new ScanResultValue(
|
||||||
"segmentId",
|
"segmentId",
|
||||||
Collections.singletonList(ColumnHolder.TIME_COLUMN_NAME),
|
Collections.singletonList(ColumnHolder.TIME_COLUMN_NAME),
|
||||||
events1);
|
events1
|
||||||
|
);
|
||||||
|
|
||||||
List<List<Object>> events2 = new ArrayList<>();
|
List<List<Object>> events2 = new ArrayList<>();
|
||||||
List<Object> event2 = Collections.singletonList(new Long(43));
|
List<Object> event2 = Collections.singletonList(new Long(43));
|
||||||
|
@ -174,7 +187,8 @@ public class ScanResultValueTimestampComparatorTest
|
||||||
ScanResultValue s2 = new ScanResultValue(
|
ScanResultValue s2 = new ScanResultValue(
|
||||||
"segmentId",
|
"segmentId",
|
||||||
Collections.singletonList(ColumnHolder.TIME_COLUMN_NAME),
|
Collections.singletonList(ColumnHolder.TIME_COLUMN_NAME),
|
||||||
events2);
|
events2
|
||||||
|
);
|
||||||
|
|
||||||
Assert.assertEquals(-1, comparator.compare(s1, s2));
|
Assert.assertEquals(-1, comparator.compare(s1, s2));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue