Skip to content

Commit

Permalink
Remove unused typed constructors from nullable aggregation states
Browse files Browse the repository at this point in the history
The typed states were added for old min/max_by aggregations, and these
constructors are incompatible with the new generic state system.
  • Loading branch information
dain committed May 27, 2022
1 parent cb8c031 commit 1ca7383
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,20 @@
*/
package io.trino.operator.aggregation.state;

import io.trino.annotation.UsedByGeneratedCode;
import io.trino.spi.block.Block;
import io.trino.spi.block.BlockBuilder;
import io.trino.spi.function.AccumulatorStateSerializer;
import io.trino.spi.type.Type;

import static com.google.common.base.Preconditions.checkArgument;
import static io.trino.spi.type.BooleanType.BOOLEAN;
import static java.util.Objects.requireNonNull;

public class NullableBooleanStateSerializer
implements AccumulatorStateSerializer<NullableBooleanState>
{
private final Type type;

@UsedByGeneratedCode
public NullableBooleanStateSerializer()
{
this(BOOLEAN);
}

public NullableBooleanStateSerializer(Type type)
{
this.type = requireNonNull(type, "type is null");
checkArgument(type.getJavaType() == boolean.class, "Type must use boolean stack type: " + type);
}

@Override
public Type getSerializedType()
{
return type;
return BOOLEAN;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,20 @@
*/
package io.trino.operator.aggregation.state;

import io.trino.annotation.UsedByGeneratedCode;
import io.trino.spi.block.Block;
import io.trino.spi.block.BlockBuilder;
import io.trino.spi.function.AccumulatorStateSerializer;
import io.trino.spi.type.Type;

import static com.google.common.base.Preconditions.checkArgument;
import static io.trino.spi.type.DoubleType.DOUBLE;
import static java.util.Objects.requireNonNull;

public class NullableDoubleStateSerializer
implements AccumulatorStateSerializer<NullableDoubleState>
{
private final Type type;

@UsedByGeneratedCode
public NullableDoubleStateSerializer()
{
this(DOUBLE);
}

public NullableDoubleStateSerializer(Type type)
{
this.type = requireNonNull(type, "type is null");
checkArgument(type.getJavaType() == double.class, "Type must use double stack type: " + type);
}

@Override
public Type getSerializedType()
{
return type;
return DOUBLE;
}

@Override
Expand All @@ -53,7 +36,7 @@ public void serialize(NullableDoubleState state, BlockBuilder out)
out.appendNull();
}
else {
type.writeDouble(out, state.getValue());
DOUBLE.writeDouble(out, state.getValue());
}
}

Expand All @@ -65,7 +48,7 @@ public void deserialize(Block block, int index, NullableDoubleState state)
}
else {
state.setNull(false);
state.setValue(type.getDouble(block, index));
state.setValue(DOUBLE.getDouble(block, index));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,20 @@
*/
package io.trino.operator.aggregation.state;

import io.trino.annotation.UsedByGeneratedCode;
import io.trino.spi.block.Block;
import io.trino.spi.block.BlockBuilder;
import io.trino.spi.function.AccumulatorStateSerializer;
import io.trino.spi.type.Type;

import static com.google.common.base.Preconditions.checkArgument;
import static io.trino.spi.type.BigintType.BIGINT;
import static java.util.Objects.requireNonNull;

public class NullableLongStateSerializer
implements AccumulatorStateSerializer<NullableLongState>
{
private final Type type;

@UsedByGeneratedCode
public NullableLongStateSerializer()
{
this(BIGINT);
}

public NullableLongStateSerializer(Type type)
{
this.type = requireNonNull(type, "type is null");
checkArgument(type.getJavaType() == long.class, "Type must use long stack type: " + type);
}

@Override
public Type getSerializedType()
{
return type;
return BIGINT;
}

@Override
Expand All @@ -53,7 +36,7 @@ public void serialize(NullableLongState state, BlockBuilder out)
out.appendNull();
}
else {
type.writeLong(out, state.getValue());
BIGINT.writeLong(out, state.getValue());
}
}

Expand All @@ -65,7 +48,7 @@ public void deserialize(Block block, int index, NullableLongState state)
}
else {
state.setNull(false);
state.setValue(type.getLong(block, index));
state.setValue(BIGINT.getLong(block, index));
}
}
}

0 comments on commit 1ca7383

Please sign in to comment.