use of io.trino.type.BlockTypeOperators.BlockPositionComparison in project trino by trinodb.
the class DynamicFilterSourceOperator method addInput.
@Override
public void addInput(Page page) {
verify(!finished, "DynamicFilterSourceOperator: addInput() may not be called after finish()");
current = page;
if (valueSets == null) {
if (minValues == null) {
// there are too many rows to collect min/max range
return;
}
minMaxCollectionLimit -= page.getPositionCount();
if (minMaxCollectionLimit < 0) {
handleMinMaxCollectionLimitExceeded();
return;
}
// the predicate became too large, record only min and max values for each orderable channel
for (int i = 0; i < minMaxChannels.size(); i++) {
Integer channelIndex = minMaxChannels.get(i);
BlockPositionComparison comparison = minMaxComparisons.get(i);
Block block = page.getBlock(channels.get(channelIndex).index);
updateMinMaxValues(block, channelIndex, comparison);
}
return;
}
minMaxCollectionLimit -= page.getPositionCount();
// TODO: we should account for the memory used for collecting build-side values using MemoryContext
long filterSizeInBytes = 0;
int filterMaxDistinctValues = 0;
// Collect only the columns which are relevant for the JOIN.
for (int channelIndex = 0; channelIndex < channels.size(); ++channelIndex) {
Block block = page.getBlock(channels.get(channelIndex).index);
TypedSet valueSet = valueSets[channelIndex];
for (int position = 0; position < block.getPositionCount(); ++position) {
valueSet.add(block, position);
}
filterSizeInBytes += valueSet.getRetainedSizeInBytes();
filterMaxDistinctValues = Math.max(filterMaxDistinctValues, valueSet.size());
}
if (filterMaxDistinctValues > maxDistinctValues || filterSizeInBytes > maxFilterSizeInBytes) {
// The whole filter (summed over all columns) exceeds maxFilterSizeInBytes or a column contains too many distinct values
handleTooLargePredicate();
}
}
use of io.trino.type.BlockTypeOperators.BlockPositionComparison in project trino by trinodb.
the class DynamicFilterSourceOperator method handleTooLargePredicate.
private void handleTooLargePredicate() {
// The resulting predicate is too large
if (minMaxChannels.isEmpty()) {
// allow all probe-side values to be read.
dynamicPredicateConsumer.accept(TupleDomain.all());
} else {
if (minMaxCollectionLimit < 0) {
handleMinMaxCollectionLimitExceeded();
} else {
// convert to min/max per column for orderable types
for (int i = 0; i < minMaxChannels.size(); i++) {
Integer channelIndex = minMaxChannels.get(i);
BlockPositionComparison comparison = minMaxComparisons.get(i);
Block block = blockBuilders[channelIndex].build();
updateMinMaxValues(block, channelIndex, comparison);
}
}
}
// Drop references to collected values.
valueSets = null;
blockBuilders = null;
}
Aggregations