use of org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector in project druid by druid-io.
the class ExpressionMultiValueDimensionSelector method makeValueMatcher.
@Override
public ValueMatcher makeValueMatcher(Predicate<String> predicate) {
return new ValueMatcher() {
@Override
public boolean matches() {
ExprEval evaluated = getEvaluated();
if (evaluated.isArray()) {
List<String> array = getArray(evaluated);
return array.stream().anyMatch(x -> predicate.apply(x));
}
return predicate.apply(getValue(evaluated));
}
@Override
public void inspectRuntimeShape(RuntimeShapeInspector inspector) {
inspector.visit("selector", baseSelector);
inspector.visit("predicate", predicate);
}
};
}
use of org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector in project druid by druid-io.
the class ForwardingFilteredDimensionSelector method makeValueMatcher.
@Override
public ValueMatcher makeValueMatcher(Predicate<String> predicate) {
final BitSet valueIds = DimensionSelectorUtils.makePredicateMatchingSet(this, predicate);
final boolean matchNull = predicate.apply(null);
return new ValueMatcher() {
@Override
public boolean matches() {
final IndexedInts baseRow = selector.getRow();
final int baseRowSize = baseRow.size();
boolean nullRow = true;
for (int i = 0; i < baseRowSize; ++i) {
int forwardedValue = idMapping.getForwardedId(baseRow.get(i));
if (forwardedValue >= 0) {
if (valueIds.get(forwardedValue)) {
return true;
}
nullRow = false;
}
}
// null should match empty rows in multi-value columns
return nullRow && matchNull;
}
@Override
public void inspectRuntimeShape(RuntimeShapeInspector inspector) {
inspector.visit("selector", selector);
}
};
}
use of org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector in project druid by druid-io.
the class PredicateFilteredDimensionSelector method makeValueMatcher.
@Override
public ValueMatcher makeValueMatcher(final String value) {
return new ValueMatcher() {
@Override
public boolean matches() {
final IndexedInts baseRow = selector.getRow();
final int baseRowSize = baseRow.size();
boolean nullRow = true;
for (int i = 0; i < baseRowSize; i++) {
String rowValue = lookupName(baseRow.get(i));
if (predicate.apply(rowValue)) {
if (Objects.equals(rowValue, value)) {
return true;
}
nullRow = false;
}
}
// null should match empty rows in multi-value columns
return nullRow && value == null;
}
@Override
public void inspectRuntimeShape(RuntimeShapeInspector inspector) {
// PredicateFilteredDimensionSelector.this inspects selector and predicate as well.
inspector.visit("selector", PredicateFilteredDimensionSelector.this);
}
};
}
use of org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector in project druid by druid-io.
the class DictionaryEncodedColumnMerger method convertSortedSegmentRowValuesToMergedRowValues.
@Override
public ColumnValueSelector convertSortedSegmentRowValuesToMergedRowValues(int segmentIndex, ColumnValueSelector source) {
IntBuffer converter = dimConversions.get(segmentIndex);
if (converter == null) {
return source;
}
DimensionSelector sourceDimensionSelector = (DimensionSelector) source;
IndexedInts convertedRow = new IndexedInts() {
@Override
public int size() {
return sourceDimensionSelector.getRow().size();
}
@Override
public int get(int index) {
return converter.get(sourceDimensionSelector.getRow().get(index));
}
@Override
public void inspectRuntimeShape(RuntimeShapeInspector inspector) {
inspector.visit("source", source);
inspector.visit("converter", converter);
}
};
return new DimensionSelector() {
@Override
public IndexedInts getRow() {
return convertedRow;
}
@Override
public void inspectRuntimeShape(RuntimeShapeInspector inspector) {
inspector.visit("convertedRow", convertedRow);
}
@Override
public ValueMatcher makeValueMatcher(String value) {
throw new UnsupportedOperationException();
}
@Override
public ValueMatcher makeValueMatcher(Predicate<String> predicate) {
throw new UnsupportedOperationException();
}
@Override
public int getValueCardinality() {
throw new UnsupportedOperationException();
}
@Nullable
@Override
public String lookupName(int id) {
throw new UnsupportedOperationException();
}
@Override
public boolean nameLookupPossibleInAdvance() {
throw new UnsupportedOperationException();
}
@Nullable
@Override
public IdLookup idLookup() {
throw new UnsupportedOperationException();
}
@Nullable
@Override
public Object getObject() {
return sourceDimensionSelector.getObject();
}
@Override
public Class classOfObject() {
return sourceDimensionSelector.classOfObject();
}
};
}
use of org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector in project druid by druid-io.
the class DimensionSelectorUtils method makeNonDictionaryEncodedValueMatcherGeneric.
private static ValueMatcher makeNonDictionaryEncodedValueMatcherGeneric(final DimensionSelector selector, @Nullable final String value) {
return new ValueMatcher() {
@Override
public boolean matches() {
final IndexedInts row = selector.getRow();
final int size = row.size();
if (size == 0) {
// null should match empty rows in multi-value columns
return value == null;
} else {
for (int i = 0; i < size; ++i) {
if (Objects.equals(selector.lookupName(row.get(i)), value)) {
return true;
}
}
return false;
}
}
@Override
public void inspectRuntimeShape(RuntimeShapeInspector inspector) {
inspector.visit("selector", selector);
}
};
}
Aggregations