Skip to content

Commit

Permalink
Make blockToNativeValue public
Browse files Browse the repository at this point in the history
This is counterpart of an already public `nativeValueToBlock`.
  • Loading branch information
findepi committed May 11, 2022
1 parent e66c9ef commit 1464cb8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import static com.google.common.base.Verify.verify;
import static io.trino.operator.aggregation.TypedSet.createUnboundedEqualityTypedSet;
import static io.trino.spi.predicate.Range.range;
import static io.trino.spi.predicate.Utils.blockToNativeValue;
import static io.trino.spi.type.DoubleType.DOUBLE;
import static io.trino.spi.type.RealType.REAL;
import static io.trino.spi.type.TypeUtils.isFloatingPointNaN;
Expand Down Expand Up @@ -377,8 +378,8 @@ public void finish()
domainsBuilder.put(channels.get(channelIndex).filterId, Domain.none(type));
continue;
}
Object min = readNativeValue(type, minValues[channelIndex], 0);
Object max = readNativeValue(type, maxValues[channelIndex], 0);
Object min = blockToNativeValue(type, minValues[channelIndex]);
Object max = blockToNativeValue(type, maxValues[channelIndex]);
Domain domain = Domain.create(
ValueSet.ofRanges(range(type, min, true, max, true)),
false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static Block nativeValueToBlock(Type type, @Nullable Object object)
return blockBuilder.build();
}

static Object blockToNativeValue(Type type, Block block)
public static Object blockToNativeValue(Type type, Block block)
{
if (block.getPositionCount() != 1) {
throw new IllegalArgumentException("Block should have exactly one position, but has: " + block.getPositionCount());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
import java.util.Objects;
import java.util.Optional;

import static com.google.common.base.Preconditions.checkArgument;
import static io.trino.spi.predicate.Utils.blockToNativeValue;
import static io.trino.spi.predicate.Utils.nativeValueToBlock;
import static io.trino.spi.type.TypeUtils.readNativeValue;
import static java.util.Objects.requireNonNull;

public final class QueryParameter
Expand All @@ -45,8 +44,7 @@ public static QueryParameter fromValueAsBlock(JdbcTypeHandle jdbcType, Type type
{
requireNonNull(type, "type is null");
requireNonNull(valueBlock, "valueBlock is null");
checkArgument(valueBlock.getPositionCount() == 1, "The block should have exactly one position, got %s", valueBlock.getPositionCount());
Optional<Object> value = Optional.ofNullable(readNativeValue(type, valueBlock, 0));
Optional<Object> value = Optional.ofNullable(blockToNativeValue(type, valueBlock));
return new QueryParameter(jdbcType, type, value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
import static io.trino.spi.predicate.Range.lessThanOrEqual;
import static io.trino.spi.predicate.Range.range;
import static io.trino.spi.predicate.TupleDomain.withColumnDomains;
import static io.trino.spi.predicate.Utils.blockToNativeValue;
import static io.trino.spi.predicate.ValueSet.ofRanges;
import static io.trino.spi.statistics.ColumnStatisticType.MAX_VALUE;
import static io.trino.spi.statistics.ColumnStatisticType.NUMBER_OF_DISTINCT_VALUES_SUMMARY;
Expand Down Expand Up @@ -2047,7 +2048,7 @@ private static Map<String, DeltaLakeColumnStatistics> toDeltaLakeColumnStatistic
return DeltaLakeColumnStatistics.create(HyperLogLog.newInstance(4096)); // empty HLL with number of buckets used by $approx_set
}
else {
Slice serializedSummary = HyperLogLogType.HYPER_LOG_LOG.getSlice(entry.getValue(), 0);
Slice serializedSummary = (Slice) blockToNativeValue(HyperLogLogType.HYPER_LOG_LOG, entry.getValue());
return DeltaLakeColumnStatistics.create(HyperLogLog.newInstance(serializedSummary));
}
}));
Expand Down

0 comments on commit 1464cb8

Please sign in to comment.