Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.apache.druid.query.aggregation;

import com.google.common.collect.Ordering;
import com.google.common.primitives.Longs;
import org.apache.druid.segment.BaseLongColumnValueSelector;

Expand All @@ -28,14 +29,14 @@
*/
public class LongSumAggregator implements Aggregator
{
static final Comparator COMPARATOR = new Comparator()
static final Comparator COMPARATOR = new Ordering()
{
@Override
public int compare(Object o, Object o1)
{
return Longs.compare(((Number) o).longValue(), ((Number) o1).longValue());
}
};
}.nullsFirst();

static long combineValues(Object lhs, Object rhs)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public void updateSearchResultSet(
)
{
if (selector != null) {
final String dimVal = String.valueOf(selector.getLong());
final String dimVal = selector.isNull() ? null : String.valueOf(selector.getLong());
if (searchQuerySpec.accept(dimVal)) {
set.addTo(new SearchHit(outputName, dimVal), 1);
}
Expand All @@ -175,7 +175,7 @@ public void updateSearchResultSet(
)
{
if (selector != null) {
final String dimVal = String.valueOf(selector.getFloat());
final String dimVal = selector.isNull() ? null : String.valueOf(selector.getFloat());
if (searchQuerySpec.accept(dimVal)) {
set.addTo(new SearchHit(outputName, dimVal), 1);
}
Expand All @@ -196,7 +196,7 @@ public void updateSearchResultSet(
)
{
if (selector != null) {
final String dimVal = String.valueOf(selector.getDouble());
final String dimVal = selector.isNull() ? null : String.valueOf(selector.getDouble());
if (searchQuerySpec.accept(dimVal)) {
set.addTo(new SearchHit(outputName, dimVal), 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ public Double getObject()
{
final Object[] dims = currEntry.get().getDims();

if (dimIndex >= dims.length) {
return null;
if (dimIndex >= dims.length || dims[dimIndex] == null) {
return NullHandling.defaultDoubleValue();
}
return (Double) dims[dimIndex];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ public Float getObject()
{
final Object[] dims = currEntry.get().getDims();

if (dimIndex >= dims.length) {
return null;
if (dimIndex >= dims.length || dims[dimIndex] == null) {
return NullHandling.defaultFloatValue();
}

return (Float) dims[dimIndex];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ public Long getObject()
{
final Object[] dims = currEntry.get().getDims();

if (dimIndex >= dims.length) {
return null;
if (dimIndex >= dims.length || dims[dimIndex] == null) {
return NullHandling.defaultLongValue();
}

return (Long) dims[dimIndex];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.apache.druid.query.groupby.strategy.GroupByStrategySelector;
import org.apache.druid.query.groupby.strategy.GroupByStrategyV1;
import org.apache.druid.query.groupby.strategy.GroupByStrategyV2;
import org.apache.druid.testing.InitializedNullHandlingTest;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
Expand All @@ -56,7 +57,7 @@
import java.util.List;

@RunWith(Parameterized.class)
public class GroupByQueryMergeBufferTest
public class GroupByQueryMergeBufferTest extends InitializedNullHandlingTest
{
private static final long TIMEOUT = 5000;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
import org.apache.druid.segment.column.ColumnHolder;
import org.apache.druid.segment.column.ValueType;
import org.apache.druid.segment.virtual.ExpressionVirtualColumn;
import org.apache.druid.testing.InitializedNullHandlingTest;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.Period;
Expand Down Expand Up @@ -153,7 +154,7 @@
import java.util.concurrent.Executors;

@RunWith(Parameterized.class)
public class GroupByQueryRunnerTest
public class GroupByQueryRunnerTest extends InitializedNullHandlingTest
{
public static final ObjectMapper DEFAULT_MAPPER = TestHelper.makeSmileMapper();
private static final DruidProcessingConfig DEFAULT_PROCESSING_CONFIG = new DruidProcessingConfig()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,13 @@ public SegmentMetadataQueryTest(

int preferedSize1 = 0;
int placementSize2 = 0;
int overallSize1 = 119691;
int overallSize2 = 119691;
int overallSize1 = 152334;
int overallSize2 = 152334;
if (bitmaps) {
preferedSize1 = mmap1 ? 10881 : 10764;
placementSize2 = mmap2 ? 10881 : 0;
overallSize1 = mmap1 ? 167493 : 168188;
overallSize2 = mmap2 ? 167493 : 168188;
overallSize1 = mmap1 ? 200136 : 200831;
overallSize2 = mmap2 ? 200136 : 200831;
}
expectedSegmentAnalysis1 = new SegmentAnalysis(
id1.toString(),
Expand All @@ -214,16 +214,6 @@ public SegmentMetadataQueryTest(
null,
null
),
"placement",
new ColumnAnalysis(
ValueType.STRING.toString(),
!mmap1,
preferedSize1,
1,
"preferred",
"preferred",
null
),
"index",
new ColumnAnalysis(
ValueType.DOUBLE.toString(),
Expand All @@ -233,6 +223,16 @@ public SegmentMetadataQueryTest(
null,
null,
null
),
"placement",
new ColumnAnalysis(
ValueType.STRING.toString(),
!mmap1,
preferedSize1,
1,
"preferred",
"preferred",
null
)
), overallSize1,
1209,
Expand All @@ -255,16 +255,6 @@ public SegmentMetadataQueryTest(
null,
null
),
"placement",
new ColumnAnalysis(
ValueType.STRING.toString(),
!mmap2,
placementSize2,
1,
null,
null,
null
),
"index",
new ColumnAnalysis(
ValueType.DOUBLE.toString(),
Expand All @@ -274,6 +264,16 @@ public SegmentMetadataQueryTest(
null,
null,
null
),
"placement",
new ColumnAnalysis(
ValueType.STRING.toString(),
!mmap2,
placementSize2,
1,
null,
null,
null
)
// null_column will be included only for incremental index, which makes a little bigger result than expected
), overallSize2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.apache.druid.segment.TestHelper;
import org.apache.druid.segment.TestIndex;
import org.apache.druid.segment.column.ValueType;
import org.apache.druid.testing.InitializedNullHandlingTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
Expand All @@ -45,7 +46,7 @@
import java.util.List;

@RunWith(Parameterized.class)
public class SegmentMetadataUnionQueryTest
public class SegmentMetadataUnionQueryTest extends InitializedNullHandlingTest
{
static {
NullHandling.initializeForTests();
Expand Down Expand Up @@ -109,7 +110,7 @@ public void testSegmentMetadataUnionQuery()
null
)
),
mmap ? 669972 : 672752,
mmap ? 800544 : 803324,
4836,
null,
null,
Expand Down
Loading