@Override public void writeJsonValue(JsonGenerator jsonGenerator, Block block, int position, ConnectorSession session) throws IOException { if (block.isNull(position)) { jsonGenerator.writeNull(); } else { BigDecimal value = BigDecimal.valueOf(type.getLong(block, position), type.getScale()); jsonGenerator.writeNumber(value); } } }
@Override public void writeJsonValue(JsonGenerator jsonGenerator, Block block, int position, ConnectorSession session) throws IOException { if (block.isNull(position)) { jsonGenerator.writeNull(); } else { BigDecimal value = BigDecimal.valueOf(type.getLong(block, position), type.getScale()); jsonGenerator.writeNumber(value); } } }
public static BigDecimal readBigDecimal(DecimalType type, Block block, int position) { BigInteger unscaledValue = type.isShort() ? BigInteger.valueOf(type.getLong(block, position)) : decodeUnscaledValue(type.getSlice(block, position)); return new BigDecimal(unscaledValue, type.getScale(), new MathContext(type.getPrecision())); }
@Override public void encodeValueInto(Block block, int position, SliceOutput output) { if (isShortDecimal(type)) { writeLong(output, type.getLong(block, position)); } else { writeSlice(output, block, position); } }
private static HiveDecimal getHiveDecimal(DecimalType decimalType, Block block, int position) { BigInteger unscaledValue; if (decimalType.isShort()) { unscaledValue = BigInteger.valueOf(decimalType.getLong(block, position)); } else { unscaledValue = Decimals.decodeUnscaledValue(decimalType.getSlice(block, position)); } return HiveDecimal.create(unscaledValue, decimalType.getScale()); }
BigInteger unscaledValue; if (decimalType.isShort()) { unscaledValue = BigInteger.valueOf(decimalType.getLong(block, position));
DecimalType decimalType = (DecimalType) type; if (isShortDecimal(decimalType)) { return (block, position) -> Decimals.toString(decimalType.getLong(block, position), decimalType.getScale());
DecimalType decimalType = (DecimalType) type; if (isShortDecimal(decimalType)) { return (block, position) -> Decimals.toString(decimalType.getLong(block, position), decimalType.getScale());
private void encodeValue(Block block, int position, SliceOutput output) { if (isShortDecimal(type)) { output.writeBytes(utf8Slice(Decimals.toString(type.getLong(block, position), type.getScale()))); } else { output.writeBytes(utf8Slice(Decimals.toString(type.getSlice(block, position), type.getScale()))); } }
for (int position = 0; position < block.getPositionCount(); position++) { if (!block.isNull(position)) { long value = type.getLong(block, position); dataStream.writeUnscaledValue(value); shortDecimalStatisticsBuilder.addValue(value);
for (int position = 0; position < block.getPositionCount(); position++) { if (!block.isNull(position)) { long value = type.getLong(block, position); dataStream.writeUnscaledValue(value); shortDecimalStatisticsBuilder.addValue(value);