-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Fixes, adjustments to numeric null handling and string first/last aggregators. #8834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,7 @@ | |
| import org.apache.druid.query.filter.BloomKFilter; | ||
| import org.apache.druid.segment.BaseNullableColumnValueSelector; | ||
| import org.apache.druid.segment.ColumnSelectorFactory; | ||
| import org.apache.druid.segment.DimensionSelector; | ||
| import org.apache.druid.segment.NilColumnValueSelector; | ||
| import org.apache.druid.segment.column.ColumnCapabilities; | ||
| import org.apache.druid.segment.column.ValueType; | ||
|
|
@@ -279,16 +280,21 @@ private BaseBloomFilterAggregator factorizeInternal(ColumnSelectorFactory column | |
| ); | ||
| } | ||
| } else { | ||
| // No column capabilities, try to guess based on selector type. | ||
| BaseNullableColumnValueSelector selector = columnFactory.makeColumnValueSelector(field.getDimension()); | ||
|
|
||
| if (selector instanceof NilColumnValueSelector) { | ||
| return new NoopBloomFilterAggregator(maxNumEntries, onHeap); | ||
| } else if (selector instanceof DimensionSelector) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| return new StringBloomFilterAggregator((DimensionSelector) selector, maxNumEntries, onHeap); | ||
| } else { | ||
| // Use fallback 'object' aggregator. | ||
| return new ObjectBloomFilterAggregator( | ||
| columnFactory.makeColumnValueSelector(field.getDimension()), | ||
| maxNumEntries, | ||
| onHeap | ||
| ); | ||
| } | ||
| // no column capabilities, use fallback 'object' aggregator | ||
| return new ObjectBloomFilterAggregator( | ||
| columnFactory.makeColumnValueSelector(field.getDimension()), | ||
| maxNumEntries, | ||
| onHeap | ||
| ); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,20 +19,18 @@ | |
|
|
||
| package org.apache.druid.query.aggregation.bloom; | ||
|
|
||
| import org.apache.druid.common.config.NullHandling; | ||
| import org.apache.druid.query.filter.BloomKFilter; | ||
| import org.apache.druid.segment.ColumnValueSelector; | ||
| import org.apache.druid.segment.DimensionSelector; | ||
| import org.apache.druid.segment.BaseObjectColumnValueSelector; | ||
|
|
||
| import java.nio.ByteBuffer; | ||
|
|
||
| /** | ||
| * Handles "unknown" columns by examining what comes out of the selector | ||
| */ | ||
| class ObjectBloomFilterAggregator extends BaseBloomFilterAggregator<ColumnValueSelector> | ||
| class ObjectBloomFilterAggregator extends BaseBloomFilterAggregator<BaseObjectColumnValueSelector<Object>> | ||
| { | ||
| ObjectBloomFilterAggregator( | ||
| ColumnValueSelector selector, | ||
| BaseObjectColumnValueSelector<Object> selector, | ||
| int maxNumEntries, | ||
| boolean onHeap | ||
| ) | ||
|
|
@@ -48,16 +46,14 @@ void bufferAdd(ByteBuffer buf) | |
| final ByteBuffer other = (ByteBuffer) object; | ||
| BloomKFilter.mergeBloomFilterByteBuffers(buf, buf.position(), other, other.position()); | ||
| } else { | ||
| if (NullHandling.replaceWithDefault() || !selector.isNull()) { | ||
| if (object instanceof Long) { | ||
| BloomKFilter.addLong(buf, selector.getLong()); | ||
| } else if (object instanceof Double) { | ||
| BloomKFilter.addDouble(buf, selector.getDouble()); | ||
| } else if (object instanceof Float) { | ||
| BloomKFilter.addFloat(buf, selector.getFloat()); | ||
| } else { | ||
| StringBloomFilterAggregator.stringBufferAdd(buf, (DimensionSelector) selector); | ||
| } | ||
| if (object instanceof Long) { | ||
| BloomKFilter.addLong(buf, (long) object); | ||
| } else if (object instanceof Double) { | ||
| BloomKFilter.addDouble(buf, (double) object); | ||
| } else if (object instanceof Float) { | ||
| BloomKFilter.addFloat(buf, (float) object); | ||
| } else if (object instanceof String) { | ||
| BloomKFilter.addString(buf, (String) object); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 this is a good change I think, moving the DimensionSelector out of here. This doesn't need to handle |
||
| } else { | ||
| BloomKFilter.addBytes(buf, null, 0, 0); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
... limit can be changed ...or... may be ...?