mirror of https://github.com/apache/druid.git
Adjustments to comments and usage of generics.
This commit is contained in:
parent
bda5a8a95e
commit
157e75a1fe
|
@ -36,7 +36,7 @@ import java.util.Map;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
public class StringTopNColumnSelectorStrategy
|
public class StringTopNColumnSelectorStrategy
|
||||||
implements TopNColumnSelectorStrategy<DimensionSelector, Map<Comparable, Aggregator[]>>
|
implements TopNColumnSelectorStrategy<DimensionSelector, Map<Comparable<?>, Aggregator[]>>
|
||||||
{
|
{
|
||||||
private final Function<Object, Comparable<?>> dimensionValueConverter;
|
private final Function<Object, Comparable<?>> dimensionValueConverter;
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ public class StringTopNColumnSelectorStrategy
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<Comparable, Aggregator[]> makeDimExtractionAggregateStore()
|
public Map<Comparable<?>, Aggregator[]> makeDimExtractionAggregateStore()
|
||||||
{
|
{
|
||||||
return new HashMap<>();
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ public class StringTopNColumnSelectorStrategy
|
||||||
DimensionSelector selector,
|
DimensionSelector selector,
|
||||||
Cursor cursor,
|
Cursor cursor,
|
||||||
Aggregator[][] rowSelector,
|
Aggregator[][] rowSelector,
|
||||||
Map<Comparable, Aggregator[]> aggregatesStore
|
Map<Comparable<?>, Aggregator[]> aggregatesStore
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (selector.getValueCardinality() != DimensionSelector.CARDINALITY_UNKNOWN) {
|
if (selector.getValueCardinality() != DimensionSelector.CARDINALITY_UNKNOWN) {
|
||||||
|
@ -96,11 +96,11 @@ public class StringTopNColumnSelectorStrategy
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateDimExtractionResults(
|
public void updateDimExtractionResults(
|
||||||
final Map<Comparable, Aggregator[]> aggregatesStore,
|
final Map<Comparable<?>, Aggregator[]> aggregatesStore,
|
||||||
final TopNResultBuilder resultBuilder
|
final TopNResultBuilder resultBuilder
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
for (Map.Entry<Comparable, Aggregator[]> entry : aggregatesStore.entrySet()) {
|
for (Map.Entry<Comparable<?>, Aggregator[]> entry : aggregatesStore.entrySet()) {
|
||||||
Aggregator[] aggs = entry.getValue();
|
Aggregator[] aggs = entry.getValue();
|
||||||
if (aggs != null) {
|
if (aggs != null) {
|
||||||
Object[] vals = new Object[aggs.length];
|
Object[] vals = new Object[aggs.length];
|
||||||
|
@ -108,7 +108,7 @@ public class StringTopNColumnSelectorStrategy
|
||||||
vals[i] = aggs[i].get();
|
vals[i] = aggs[i].get();
|
||||||
}
|
}
|
||||||
|
|
||||||
final Comparable key = dimensionValueConverter.apply(entry.getKey());
|
final Comparable<?> key = dimensionValueConverter.apply(entry.getKey());
|
||||||
resultBuilder.addEntry(key, key, vals);
|
resultBuilder.addEntry(key, key, vals);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ public class StringTopNColumnSelectorStrategy
|
||||||
Cursor cursor,
|
Cursor cursor,
|
||||||
DimensionSelector selector,
|
DimensionSelector selector,
|
||||||
Aggregator[][] rowSelector,
|
Aggregator[][] rowSelector,
|
||||||
Map<Comparable, Aggregator[]> aggregatesStore
|
Map<Comparable<?>, Aggregator[]> aggregatesStore
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
long processedRows = 0;
|
long processedRows = 0;
|
||||||
|
@ -152,7 +152,7 @@ public class StringTopNColumnSelectorStrategy
|
||||||
TopNQuery query,
|
TopNQuery query,
|
||||||
Cursor cursor,
|
Cursor cursor,
|
||||||
DimensionSelector selector,
|
DimensionSelector selector,
|
||||||
Map<Comparable, Aggregator[]> aggregatesStore
|
Map<Comparable<?>, Aggregator[]> aggregatesStore
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
long processedRows = 0;
|
long processedRows = 0;
|
||||||
|
|
|
@ -49,9 +49,13 @@ public class TopNColumnSelectorStrategyFactory implements ColumnSelectorStrategy
|
||||||
case LONG:
|
case LONG:
|
||||||
case FLOAT:
|
case FLOAT:
|
||||||
case DOUBLE:
|
case DOUBLE:
|
||||||
|
// When the selector is numeric, we want to use NumericTopNColumnSelectorStrategy. It aggregates using
|
||||||
|
// a numeric type and then converts to the desired output type after aggregating. We must be careful not to
|
||||||
|
// convert to an output type that cannot represent all possible values of the input type.
|
||||||
|
|
||||||
if (ValueType.isNumeric(dimensionType)) {
|
if (ValueType.isNumeric(dimensionType)) {
|
||||||
// Return strategy that aggregates using the _output_ type, because this allows us to collapse values
|
// Return strategy that aggregates using the _output_ type, because this allows us to collapse values
|
||||||
// properly (numeric types cannot represent all values of other numeric types).
|
// properly (numeric types cannot always represent all values of other numeric types).
|
||||||
return NumericTopNColumnSelectorStrategy.ofType(dimensionType, dimensionType);
|
return NumericTopNColumnSelectorStrategy.ofType(dimensionType, dimensionType);
|
||||||
} else {
|
} else {
|
||||||
// Return strategy that aggregates using the _input_ type. Here we are assuming that the output type can
|
// Return strategy that aggregates using the _input_ type. Here we are assuming that the output type can
|
||||||
|
|
|
@ -343,10 +343,7 @@ public final class DimensionHandlerUtils
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static Comparable<?> convertObjectToType(
|
public static Comparable<?> convertObjectToType(@Nullable final Object obj, final ValueType type)
|
||||||
@Nullable final Object obj,
|
|
||||||
final ValueType type
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return convertObjectToType(obj, Preconditions.checkNotNull(type, "type"), false);
|
return convertObjectToType(obj, Preconditions.checkNotNull(type, "type"), false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue