use VectorValueSelector instead of BaseLongVectorValueSelector for StringFirstAggregatorFactory.factorizeVector (#14957)

This commit is contained in:
Clint Wylie 2023-09-09 04:03:05 -07:00 committed by GitHub
parent 09f7dfe327
commit 2b7f2c5119
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 8 deletions

View File

@ -23,22 +23,22 @@ import org.apache.druid.common.config.NullHandling;
import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.StringUtils;
import org.apache.druid.query.aggregation.SerializablePairLongString; import org.apache.druid.query.aggregation.SerializablePairLongString;
import org.apache.druid.query.aggregation.VectorAggregator; import org.apache.druid.query.aggregation.VectorAggregator;
import org.apache.druid.segment.vector.BaseLongVectorValueSelector;
import org.apache.druid.segment.vector.SingleValueDimensionVectorSelector; import org.apache.druid.segment.vector.SingleValueDimensionVectorSelector;
import org.apache.druid.segment.vector.VectorValueSelector;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
public class SingleStringFirstDimensionVectorAggregator implements VectorAggregator public class SingleStringFirstDimensionVectorAggregator implements VectorAggregator
{ {
private final BaseLongVectorValueSelector timeSelector; private final VectorValueSelector timeSelector;
private final SingleValueDimensionVectorSelector valueDimensionVectorSelector; private final SingleValueDimensionVectorSelector valueDimensionVectorSelector;
private long firstTime; private long firstTime;
private final int maxStringBytes; private final int maxStringBytes;
private final boolean useDefault = NullHandling.replaceWithDefault(); private final boolean useDefault = NullHandling.replaceWithDefault();
public SingleStringFirstDimensionVectorAggregator( public SingleStringFirstDimensionVectorAggregator(
BaseLongVectorValueSelector timeSelector, VectorValueSelector timeSelector,
SingleValueDimensionVectorSelector valueDimensionVectorSelector, SingleValueDimensionVectorSelector valueDimensionVectorSelector,
int maxStringBytes int maxStringBytes
) )

View File

@ -43,10 +43,10 @@ import org.apache.druid.segment.column.ColumnCapabilities;
import org.apache.druid.segment.column.ColumnHolder; import org.apache.druid.segment.column.ColumnHolder;
import org.apache.druid.segment.column.ColumnType; import org.apache.druid.segment.column.ColumnType;
import org.apache.druid.segment.column.ValueType; import org.apache.druid.segment.column.ValueType;
import org.apache.druid.segment.vector.BaseLongVectorValueSelector;
import org.apache.druid.segment.vector.SingleValueDimensionVectorSelector; import org.apache.druid.segment.vector.SingleValueDimensionVectorSelector;
import org.apache.druid.segment.vector.VectorColumnSelectorFactory; import org.apache.druid.segment.vector.VectorColumnSelectorFactory;
import org.apache.druid.segment.vector.VectorObjectSelector; import org.apache.druid.segment.vector.VectorObjectSelector;
import org.apache.druid.segment.vector.VectorValueSelector;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
@ -186,8 +186,7 @@ public class StringFirstAggregatorFactory extends AggregatorFactory
@Override @Override
public VectorAggregator factorizeVector(VectorColumnSelectorFactory selectorFactory) public VectorAggregator factorizeVector(VectorColumnSelectorFactory selectorFactory)
{ {
BaseLongVectorValueSelector timeSelector = (BaseLongVectorValueSelector) selectorFactory.makeValueSelector( final VectorValueSelector timeSelector = selectorFactory.makeValueSelector(timeColumn);
timeColumn);
ColumnCapabilities capabilities = selectorFactory.getColumnCapabilities(fieldName); ColumnCapabilities capabilities = selectorFactory.getColumnCapabilities(fieldName);
if (capabilities != null) { if (capabilities != null) {
if (capabilities.is(ValueType.STRING) && capabilities.isDictionaryEncoded().isTrue()) { if (capabilities.is(ValueType.STRING) && capabilities.isDictionaryEncoded().isTrue()) {

View File

@ -23,7 +23,6 @@ import org.apache.druid.java.util.common.DateTimes;
import org.apache.druid.query.aggregation.SerializablePairLongString; import org.apache.druid.query.aggregation.SerializablePairLongString;
import org.apache.druid.query.aggregation.VectorAggregator; import org.apache.druid.query.aggregation.VectorAggregator;
import org.apache.druid.segment.DimensionHandlerUtils; import org.apache.druid.segment.DimensionHandlerUtils;
import org.apache.druid.segment.vector.BaseLongVectorValueSelector;
import org.apache.druid.segment.vector.VectorObjectSelector; import org.apache.druid.segment.vector.VectorObjectSelector;
import org.apache.druid.segment.vector.VectorValueSelector; import org.apache.druid.segment.vector.VectorValueSelector;
@ -42,7 +41,7 @@ public class StringFirstVectorAggregator implements VectorAggregator
public StringFirstVectorAggregator( public StringFirstVectorAggregator(
BaseLongVectorValueSelector timeSelector, VectorValueSelector timeSelector,
VectorObjectSelector valueSelector, VectorObjectSelector valueSelector,
int maxStringBytes int maxStringBytes
) )