mirror of https://github.com/apache/druid.git
fix brokeness with dim extraction dim specs
This commit is contained in:
parent
b27d9af0ef
commit
b9015cee34
|
@ -76,6 +76,12 @@ public class DefaultDimensionSpec implements DimensionSpec
|
|||
.array();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTransformValues()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
|
|
@ -33,7 +33,12 @@ import io.druid.query.extraction.DimExtractionFn;
|
|||
public interface DimensionSpec
|
||||
{
|
||||
public String getDimension();
|
||||
|
||||
public String getOutputName();
|
||||
|
||||
public DimExtractionFn getDimExtractionFn();
|
||||
|
||||
public byte[] getCacheKey();
|
||||
|
||||
public boolean canTransformValues();
|
||||
}
|
||||
|
|
|
@ -83,6 +83,12 @@ public class ExtractionDimensionSpec implements DimensionSpec
|
|||
.array();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTransformValues()
|
||||
{
|
||||
return dimExtractionFn.canTransformValues();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
|
|
@ -24,7 +24,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
|||
|
||||
/**
|
||||
*/
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property="type")
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
|
||||
@JsonSubTypes(value = {
|
||||
@JsonSubTypes.Type(name = "time", value = TimeDimExtractionFn.class),
|
||||
@JsonSubTypes.Type(name = "regex", value = RegexDimExtractionFn.class),
|
||||
|
@ -35,5 +35,8 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
|||
public interface DimExtractionFn
|
||||
{
|
||||
public byte[] getCacheKey();
|
||||
|
||||
public String apply(String dimValue);
|
||||
|
||||
public boolean canTransformValues();
|
||||
}
|
||||
|
|
|
@ -92,4 +92,10 @@ public class JavascriptDimExtractionFn implements DimExtractionFn
|
|||
{
|
||||
return fn.apply(dimValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTransformValues()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,6 +67,12 @@ public class PartialDimExtractionFn implements DimExtractionFn
|
|||
return expr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTransformValues()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
|
|
@ -67,6 +67,12 @@ public class RegexDimExtractionFn implements DimExtractionFn
|
|||
return expr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTransformValues()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
|
|
@ -63,6 +63,12 @@ public class SearchQuerySpecDimExtractionFn implements DimExtractionFn
|
|||
return searchQuerySpec.accept(dimValue) ? dimValue : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTransformValues()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
|
|
@ -87,6 +87,12 @@ public class TimeDimExtractionFn implements DimExtractionFn
|
|||
return resultFormat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTransformValues()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
|
|
@ -62,7 +62,12 @@ public class AggregateTopNMetricFirstAlgorithm implements TopNAlgorithm<int[], T
|
|||
DimensionSelector dimSelector, Cursor cursor
|
||||
)
|
||||
{
|
||||
return new TopNParams(dimSelector, cursor, dimSelector.getValueCardinality(), Integer.MAX_VALUE);
|
||||
return new TopNParams(
|
||||
dimSelector,
|
||||
cursor,
|
||||
dimSelector.getValueCardinality(),
|
||||
Integer.MAX_VALUE
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -49,15 +49,26 @@ public class DimExtractionTopNAlgorithm extends BaseTopNAlgorithm<Aggregator[][]
|
|||
final DimensionSelector dimSelector, final Cursor cursor
|
||||
)
|
||||
{
|
||||
return new TopNParams(dimSelector, cursor, dimSelector.getValueCardinality(), Integer.MAX_VALUE);
|
||||
return new TopNParams(
|
||||
dimSelector,
|
||||
cursor,
|
||||
dimSelector.getValueCardinality(),
|
||||
Integer.MAX_VALUE
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Aggregator[][] makeDimValSelector(TopNParams params, int numProcessed, int numToProcess)
|
||||
{
|
||||
return query.getTopNMetricSpec().configureOptimizer(
|
||||
new AggregatorArrayProvider(params.getDimSelector(), query, params.getCardinality())
|
||||
).build();
|
||||
final AggregatorArrayProvider provider = new AggregatorArrayProvider(
|
||||
params.getDimSelector(),
|
||||
query,
|
||||
params.getCardinality()
|
||||
);
|
||||
if (query.getDimensionSpec().canTransformValues()) {
|
||||
return provider.build();
|
||||
}
|
||||
return query.getTopNMetricSpec().configureOptimizer(provider).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -116,6 +116,10 @@ public class PooledTopNAlgorithm
|
|||
{
|
||||
final TopNMetricSpecBuilder<int[]> arrayProvider = params.getArrayProvider();
|
||||
|
||||
if (query.getDimensionSpec().canTransformValues()) {
|
||||
return arrayProvider.build();
|
||||
}
|
||||
|
||||
arrayProvider.ignoreFirstN(numProcessed);
|
||||
arrayProvider.keepOnlyN(numToProcess);
|
||||
return query.getTopNMetricSpec().configureOptimizer(arrayProvider).build();
|
||||
|
|
|
@ -31,7 +31,12 @@ public class TopNParams
|
|||
private final int cardinality;
|
||||
private final int numValuesPerPass;
|
||||
|
||||
protected TopNParams(DimensionSelector dimSelector, Cursor cursor, int cardinality, int numValuesPerPass)
|
||||
protected TopNParams(
|
||||
DimensionSelector dimSelector,
|
||||
Cursor cursor,
|
||||
int cardinality,
|
||||
int numValuesPerPass
|
||||
)
|
||||
{
|
||||
this.dimSelector = dimSelector;
|
||||
this.cursor = cursor;
|
||||
|
|
Loading…
Reference in New Issue