else if (SMALLINT.equals(type)) { short shortValue = resultSet.getShort(i); if (resultSet.wasNull()) {
@Override public void setField(Block block, int position) { value.set(Shorts.checkedCast(SmallintType.SMALLINT.getLong(block, position))); rowInspector.setStructFieldData(row, field, value); } }
@Override protected Object getGreaterValue(Object value) { Block block = (Block) value; BlockBuilder blockBuilder = SMALLINT.createBlockBuilder(null, block.getPositionCount() + 1); for (int i = 0; i < block.getPositionCount(); i++) { SMALLINT.appendTo(block, i, blockBuilder); } SMALLINT.writeLong(blockBuilder, 1L); return blockBuilder.build(); } }
public static Block createTestBlock() { BlockBuilder blockBuilder = SMALLINT.createBlockBuilder(null, 15); SMALLINT.writeLong(blockBuilder, 1111); SMALLINT.writeLong(blockBuilder, 1111); SMALLINT.writeLong(blockBuilder, 1111); SMALLINT.writeLong(blockBuilder, 2222); SMALLINT.writeLong(blockBuilder, 2222); SMALLINT.writeLong(blockBuilder, 2222); SMALLINT.writeLong(blockBuilder, 2222); SMALLINT.writeLong(blockBuilder, 2222); SMALLINT.writeLong(blockBuilder, 3333); SMALLINT.writeLong(blockBuilder, 3333); SMALLINT.writeLong(blockBuilder, 4444); return blockBuilder.build(); }
@Override public void append(JsonParser parser, BlockBuilder blockBuilder) throws IOException { Long result = currentTokenAsInteger(parser); if (result == null) { blockBuilder.appendNull(); } else { SMALLINT.writeLong(blockBuilder, result); } } }
@Override public long hash(Block block, int position) { return hash(block.getShort(position, 0)); }
@Override public BlockBuilder createBlockBuilder(BlockBuilderStatus blockBuilderStatus, int expectedEntries) { return createBlockBuilder(blockBuilderStatus, expectedEntries, Short.BYTES); }
public static Block createTestBlock() { BlockBuilder blockBuilder = SMALLINT.createBlockBuilder(null, 15); SMALLINT.writeLong(blockBuilder, 1111); SMALLINT.writeLong(blockBuilder, 1111); SMALLINT.writeLong(blockBuilder, 1111); SMALLINT.writeLong(blockBuilder, 2222); SMALLINT.writeLong(blockBuilder, 2222); SMALLINT.writeLong(blockBuilder, 2222); SMALLINT.writeLong(blockBuilder, 2222); SMALLINT.writeLong(blockBuilder, 2222); SMALLINT.writeLong(blockBuilder, 3333); SMALLINT.writeLong(blockBuilder, 3333); SMALLINT.writeLong(blockBuilder, 4444); return blockBuilder.build(); }
@Override public void append(JsonParser parser, BlockBuilder blockBuilder) throws IOException { Long result = currentTokenAsInteger(parser); if (result == null) { blockBuilder.appendNull(); } else { SMALLINT.writeLong(blockBuilder, result); } } }
@ScalarOperator(HASH_CODE) @SqlType(StandardTypes.BIGINT) public static long hashCode(@SqlType(StandardTypes.SMALLINT) long value) { return SmallintType.hash((short) value); }
private static boolean convertibleToDoubleWithCast(Type type) { return type instanceof DecimalType || DoubleType.DOUBLE.equals(type) || RealType.REAL.equals(type) || BigintType.BIGINT.equals(type) || IntegerType.INTEGER.equals(type) || SmallintType.SMALLINT.equals(type) || TinyintType.TINYINT.equals(type) || BooleanType.BOOLEAN.equals(type); } }
@Override protected Object getGreaterValue(Object value) { Block block = (Block) value; BlockBuilder blockBuilder = SMALLINT.createBlockBuilder(null, block.getPositionCount() + 1); for (int i = 0; i < block.getPositionCount(); i++) { SMALLINT.appendTo(block, i, blockBuilder); } SMALLINT.writeLong(blockBuilder, 1L); return blockBuilder.build(); } }
@ScalarFunction @SqlType("map(bigint,smallint)") public static Block hashCounts(@TypeParameter("map<bigint,smallint>") Type mapType, @SqlType(SetDigestType.NAME) Slice slice) { SetDigest digest = SetDigest.newInstance(slice); // Maybe use static BlockBuilderStatus in order avoid `new`? BlockBuilder blockBuilder = mapType.createBlockBuilder(null, 1); BlockBuilder singleMapBlockBuilder = blockBuilder.beginBlockEntry(); for (Map.Entry<Long, Short> entry : digest.getHashCounts().entrySet()) { BIGINT.writeLong(singleMapBlockBuilder, entry.getKey()); SMALLINT.writeLong(singleMapBlockBuilder, entry.getValue()); } blockBuilder.closeEntry(); return (Block) mapType.getObject(blockBuilder, 0); }
@SqlType(StandardTypes.BOOLEAN) public static boolean isDistinctFrom( @BlockPosition @SqlType(value = StandardTypes.SMALLINT, nativeContainerType = long.class) Block left, @BlockIndex int leftPosition, @BlockPosition @SqlType(value = StandardTypes.SMALLINT, nativeContainerType = long.class) Block right, @BlockIndex int rightPosition) { if (left.isNull(leftPosition) != right.isNull(rightPosition)) { return true; } if (left.isNull(leftPosition)) { return false; } return notEqual(SMALLINT.getLong(left, leftPosition), SMALLINT.getLong(right, rightPosition)); } }
@ScalarOperator(HASH_CODE) @SqlType(StandardTypes.BIGINT) public static long hashCode(@SqlType(StandardTypes.SMALLINT) long value) { return SmallintType.hash((short) value); }
private static boolean convertibleToDoubleWithCast(Type type) { return type instanceof DecimalType || DoubleType.DOUBLE.equals(type) || RealType.REAL.equals(type) || BigintType.BIGINT.equals(type) || IntegerType.INTEGER.equals(type) || SmallintType.SMALLINT.equals(type) || TinyintType.TINYINT.equals(type) || BooleanType.BOOLEAN.equals(type); } }
@ScalarFunction @SqlType("map(bigint,smallint)") public static Block hashCounts(@TypeParameter("map<bigint,smallint>") Type mapType, @SqlType(SetDigestType.NAME) Slice slice) { SetDigest digest = SetDigest.newInstance(slice); // Maybe use static BlockBuilderStatus in order avoid `new`? BlockBuilder blockBuilder = mapType.createBlockBuilder(null, 1); BlockBuilder singleMapBlockBuilder = blockBuilder.beginBlockEntry(); for (Map.Entry<Long, Short> entry : digest.getHashCounts().entrySet()) { BIGINT.writeLong(singleMapBlockBuilder, entry.getKey()); SMALLINT.writeLong(singleMapBlockBuilder, entry.getValue()); } blockBuilder.closeEntry(); return (Block) mapType.getObject(blockBuilder, 0); }
@SqlType(StandardTypes.BOOLEAN) public static boolean isDistinctFrom( @BlockPosition @SqlType(value = StandardTypes.SMALLINT, nativeContainerType = long.class) Block left, @BlockIndex int leftPosition, @BlockPosition @SqlType(value = StandardTypes.SMALLINT, nativeContainerType = long.class) Block right, @BlockIndex int rightPosition) { if (left.isNull(leftPosition) != right.isNull(rightPosition)) { return true; } if (left.isNull(leftPosition)) { return false; } return notEqual(SMALLINT.getLong(left, leftPosition), SMALLINT.getLong(right, rightPosition)); } }
return ((Number) value).byteValue(); else if (SMALLINT.equals(type)) { return ((Number) value).shortValue();
return; case SHORT: SmallintType.SMALLINT.writeLong(builder, ((ShortObjectInspector) inspector).get(object)); return; case INT: