Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import static com.facebook.presto.operator.scalar.ScalarFunctionImplementation.NullConvention.USE_BOXED_TYPE;
import static com.facebook.presto.operator.scalar.ScalarFunctionImplementation.NullConvention.USE_NULL_FLAG;
import static com.facebook.presto.type.TypeUtils.resolveTypes;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import static java.util.Collections.emptyList;
import static java.util.Objects.requireNonNull;
Expand Down Expand Up @@ -186,7 +185,6 @@ private static Class<?> getNullAwareContainerType(Class<?> clazz, boolean nullab
if (nullable) {
return Primitives.wrap(clazz);
}
checkArgument(clazz != void.class);
return clazz;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,17 @@
public abstract class AbstractMinMaxAggregationFunction
extends SqlAggregationFunction
{
private static final MethodHandle UNKNOWN_INPUT_FUNCTION = methodHandle(AbstractMinMaxAggregationFunction.class, "input", AccumulatorState.class, Block.class, int.class);
private static final MethodHandle LONG_INPUT_FUNCTION = methodHandle(AbstractMinMaxAggregationFunction.class, "input", MethodHandle.class, NullableLongState.class, long.class);
private static final MethodHandle DOUBLE_INPUT_FUNCTION = methodHandle(AbstractMinMaxAggregationFunction.class, "input", MethodHandle.class, NullableDoubleState.class, double.class);
private static final MethodHandle BOOLEAN_INPUT_FUNCTION = methodHandle(AbstractMinMaxAggregationFunction.class, "input", MethodHandle.class, NullableBooleanState.class, boolean.class);
private static final MethodHandle BLOCK_POSITION_MIN_INPUT_FUNCTION = methodHandle(AbstractMinMaxAggregationFunction.class, "minInput", Type.class, BlockPositionState.class, Block.class, int.class);
private static final MethodHandle BLOCK_POSITION_MAX_INPUT_FUNCTION = methodHandle(AbstractMinMaxAggregationFunction.class, "maxInput", Type.class, BlockPositionState.class, Block.class, int.class);

private static final MethodHandle UNKNOWN_OUTPUT_FUNCTION = methodHandle(AbstractMinMaxAggregationFunction.class, "writeNull", AccumulatorState.class, BlockBuilder.class);
private static final MethodHandle LONG_OUTPUT_FUNCTION = methodHandle(NullableLongState.class, "write", Type.class, NullableLongState.class, BlockBuilder.class);
private static final MethodHandle DOUBLE_OUTPUT_FUNCTION = methodHandle(NullableDoubleState.class, "write", Type.class, NullableDoubleState.class, BlockBuilder.class);
private static final MethodHandle BOOLEAN_OUTPUT_FUNCTION = methodHandle(NullableBooleanState.class, "write", Type.class, NullableBooleanState.class, BlockBuilder.class);
private static final MethodHandle BLOCK_POSITION_OUTPUT_FUNCTION = methodHandle(BlockPositionState.class, "write", Type.class, BlockPositionState.class, BlockBuilder.class);

private static final MethodHandle UNKNOWN_COMBINE_FUNCTION = methodHandle(AbstractMinMaxAggregationFunction.class, "combine", AccumulatorState.class, AccumulatorState.class);
private static final MethodHandle LONG_COMBINE_FUNCTION = methodHandle(AbstractMinMaxAggregationFunction.class, "combine", MethodHandle.class, NullableLongState.class, NullableLongState.class);
private static final MethodHandle DOUBLE_COMBINE_FUNCTION = methodHandle(AbstractMinMaxAggregationFunction.class, "combine", MethodHandle.class, NullableDoubleState.class, NullableDoubleState.class);
private static final MethodHandle BOOLEAN_COMBINE_FUNCTION = methodHandle(AbstractMinMaxAggregationFunction.class, "combine", MethodHandle.class, NullableBooleanState.class, NullableBooleanState.class);
Expand Down Expand Up @@ -109,14 +106,7 @@ protected InternalAggregationFunction generateAggregation(Type type, MethodHandl
Class<? extends AccumulatorState> stateInterface;
AccumulatorStateSerializer<?> stateSerializer;

if (type.getJavaType() == void.class) {
stateInterface = AccumulatorState.class;
stateSerializer = StateCompiler.generateStateSerializer(stateInterface, classLoader);
inputFunction = UNKNOWN_INPUT_FUNCTION;
combineFunction = UNKNOWN_COMBINE_FUNCTION;
outputFunction = UNKNOWN_OUTPUT_FUNCTION;
}
else if (type.getJavaType() == long.class) {
if (type.getJavaType() == long.class) {
stateInterface = NullableLongState.class;
stateSerializer = StateCompiler.generateStateSerializer(stateInterface, classLoader);
inputFunction = LONG_INPUT_FUNCTION.bindTo(compareMethodHandle);
Expand Down Expand Up @@ -166,7 +156,7 @@ else if (type.getJavaType() == boolean.class) {

private static List<ParameterMetadata> createParameterMetadata(Type type)
{
if (type.getJavaType().isPrimitive() && type.getJavaType() != void.class) {
if (type.getJavaType().isPrimitive()) {
return ImmutableList.of(
new ParameterMetadata(STATE),
new ParameterMetadata(INPUT_CHANNEL, type));
Expand All @@ -179,11 +169,6 @@ private static List<ParameterMetadata> createParameterMetadata(Type type)
}
}

public static void input(AccumulatorState state, Block block, int position)
{
// Do nothing
}

public static void input(MethodHandle methodHandle, NullableDoubleState state, double value)
{
compareAndUpdateState(methodHandle, state, value);
Expand Down Expand Up @@ -215,11 +200,6 @@ public static void maxInput(Type type, BlockPositionState state, Block block, in
}
}

public static void combine(AccumulatorState state, AccumulatorState otherState)
{
// Do nothing
}

public static void combine(MethodHandle methodHandle, NullableLongState state, NullableLongState otherState)
{
compareAndUpdateState(methodHandle, state, otherState.getLong());
Expand Down Expand Up @@ -251,11 +231,6 @@ public static void maxCombine(Type type, BlockPositionState state, BlockPosition
}
}

public static void writeNull(AccumulatorState state, BlockBuilder out)
{
out.appendNull();
}

private static void compareAndUpdateState(MethodHandle methodHandle, NullableLongState state, long value)
{
if (state.isNull()) {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -40,37 +40,26 @@ private TwoNullableValueStateMapping() {}
.put(ImmutableList.of(boolean.class, double.class), BooleanDoubleState.class)
.put(ImmutableList.of(boolean.class, long.class), BooleanLongState.class)
.put(ImmutableList.of(boolean.class, Slice.class), BooleanAndBlockPositionValueState.class)
.put(ImmutableList.of(boolean.class, void.class), BooleanUnknownState.class)
.put(ImmutableList.of(double.class, boolean.class), DoubleBooleanState.class)
.put(ImmutableList.of(double.class, Block.class), DoubleAndBlockPositionValueState.class)
.put(ImmutableList.of(double.class, double.class), DoubleDoubleState.class)
.put(ImmutableList.of(double.class, long.class), DoubleLongState.class)
.put(ImmutableList.of(double.class, Slice.class), DoubleAndBlockPositionValueState.class)
.put(ImmutableList.of(double.class, void.class), DoubleUnknownState.class)
.put(ImmutableList.of(long.class, Block.class), LongAndBlockPositionValueState.class)
.put(ImmutableList.of(long.class, boolean.class), LongBooleanState.class)
.put(ImmutableList.of(long.class, double.class), LongDoubleState.class)
.put(ImmutableList.of(long.class, long.class), LongLongState.class)
.put(ImmutableList.of(long.class, Slice.class), LongAndBlockPositionValueState.class)
.put(ImmutableList.of(long.class, void.class), LongUnknownState.class)
.put(ImmutableList.of(Slice.class, boolean.class), SliceBooleanState.class)
.put(ImmutableList.of(Slice.class, Block.class), SliceAndBlockPositionValueState.class)
.put(ImmutableList.of(Slice.class, double.class), SliceDoubleState.class)
.put(ImmutableList.of(Slice.class, long.class), SliceLongState.class)
.put(ImmutableList.of(Slice.class, Slice.class), SliceAndBlockPositionValueState.class)
.put(ImmutableList.of(Slice.class, void.class), SliceUnknownState.class)
.put(ImmutableList.of(Block.class, boolean.class), BlockBooleanState.class)
.put(ImmutableList.of(Block.class, Block.class), BlockAndBlockPositionValueState.class)
.put(ImmutableList.of(Block.class, double.class), BlockDoubleState.class)
.put(ImmutableList.of(Block.class, long.class), BlockLongState.class)
.put(ImmutableList.of(Block.class, Slice.class), BlockAndBlockPositionValueState.class)
.put(ImmutableList.of(Block.class, void.class), BlockUnknownState.class)
.put(ImmutableList.of(void.class, void.class), TwoNullableValueState.class)
.put(ImmutableList.of(void.class, Block.class), KeyAndBlockPositionValueState.class) // no need to specify the first field if it is unknown
.put(ImmutableList.of(void.class, boolean.class), UnknownBooleanState.class)
.put(ImmutableList.of(void.class, double.class), UnknownDoubleState.class)
.put(ImmutableList.of(void.class, long.class), UnknownLongState.class)
.put(ImmutableList.of(void.class, Slice.class), KeyAndBlockPositionValueState.class) // no need to specify the first field if it is unknown
.build();
}

Expand Down Expand Up @@ -105,9 +94,6 @@ public static AccumulatorStateSerializer<?> getStateSerializer(Type firstType, T
if (firstJavaType == Block.class) {
return new BlockAndBlockPositionStateSerializer(firstType, secondType);
}
if (firstJavaType == void.class) {
return new UnknownAndBlockPositionStateSerializer(firstType, secondType);
}
throw new IllegalArgumentException(format("Unsupported state type combination: (%s, %s)", firstJavaType.getName(), secondJavaType.getName()));
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading