private Slice parseSlice(Slice slice, int offset, int length) { BigDecimal decimal = parseBigDecimal(slice, offset, length); return encodeUnscaledValue(decimal.unscaledValue()); }
@UsedByGeneratedCode public static Slice multiplyShortShortLong(long a, long b) { return multiplyLongLongLong(encodeUnscaledValue(a), encodeUnscaledValue(b)); }
public static Slice currentTokenAsLongDecimal(JsonParser parser, int precision, int scale) throws IOException { BigDecimal bigDecimal = currentTokenAsJavaDecimal(parser, precision, scale); if (bigDecimal == null) { return null; } return encodeUnscaledValue(bigDecimal.unscaledValue()); }
private static Slice encodeUnscaledValue(String unscaledValue) { return Decimals.encodeUnscaledValue(new BigInteger(unscaledValue)); } }
@UsedByGeneratedCode public static Slice shortDecimalToLongDecimal(long value, int sourcePrecision, int sourceScale, int resultPrecision, int resultScale) { return encodeUnscaledValue(bigintToBigintFloorSaturatedCast(BigInteger.valueOf(value), sourceScale, resultPrecision, resultScale)); }
@UsedByGeneratedCode public static Slice genericIntegerTypeToLongDecimal(long value, int resultPrecision, int resultScale) { return encodeUnscaledValue(bigDecimalToBigintFloorSaturatedCast(BigDecimal.valueOf(value), resultPrecision, resultScale)); } }
@Test public void testUnscaledValueToSlice() { assertEquals(encodeUnscaledValue(0L), encodeUnscaledValue(BigInteger.valueOf(0L))); assertEquals(encodeUnscaledValue(1L), encodeUnscaledValue(BigInteger.valueOf(1L))); assertEquals(encodeUnscaledValue(-1L), encodeUnscaledValue(BigInteger.valueOf(-1L))); assertEquals(encodeUnscaledValue(Long.MAX_VALUE), encodeUnscaledValue(BigInteger.valueOf(Long.MAX_VALUE))); assertEquals(encodeUnscaledValue(Long.MIN_VALUE), encodeUnscaledValue(BigInteger.valueOf(Long.MIN_VALUE))); }
private static Slice encodeUnscaledValue(String unscaledValue) { return Decimals.encodeUnscaledValue(new BigInteger(unscaledValue)); } }
@UsedByGeneratedCode public static Slice genericIntegerTypeToLongDecimal(long value, int resultPrecision, int resultScale) { return encodeUnscaledValue(bigDecimalToBigintFloorSaturatedCast(BigDecimal.valueOf(value), resultPrecision, resultScale)); } }
@UsedByGeneratedCode public static Slice shortDecimalToLongDecimal(long value, int sourcePrecision, int sourceScale, int resultPrecision, int resultScale) { return encodeUnscaledValue(bigintToBigintFloorSaturatedCast(BigInteger.valueOf(value), sourceScale, resultPrecision, resultScale)); }
public static Block decimalArrayBlockOf(DecimalType type, BigDecimal decimal) { if (type.isShort()) { long longDecimal = decimal.unscaledValue().longValue(); return arrayBlockOf(type, longDecimal); } else { Slice sliceDecimal = Decimals.encodeUnscaledValue(decimal.unscaledValue()); return arrayBlockOf(type, sliceDecimal); } }
@UsedByGeneratedCode public static Slice multiplyShortLongLong(long a, Slice b) { return multiplyLongLongLong(encodeUnscaledValue(a), b); }
@UsedByGeneratedCode public static Slice multiplyShortLongLong(long a, Slice b) { return multiplyLongLongLong(encodeUnscaledValue(a), b); }
public static Slice getLongDecimalValue(HiveDecimalWritable writable, int columnScale) { BigInteger value = new BigInteger(writable.getInternalStorage()); value = rescale(value, writable.getScale(), columnScale); return encodeUnscaledValue(value); } }
@UsedByGeneratedCode public static Slice longDecimalToLongDecimal(Slice value, int sourcePrecision, int sourceScale, int resultPrecision, int resultScale) { return encodeUnscaledValue(bigintToBigintFloorSaturatedCast(decodeUnscaledValue(value), sourceScale, resultPrecision, resultScale)); }
@LiteralParameters({"p", "s"}) @SqlType("decimal(p, s)") public static Slice negate(@SqlType("decimal(p, s)") Slice arg) { BigInteger argBigInteger = Decimals.decodeUnscaledValue(arg); return encodeUnscaledValue(argBigInteger.negate()); } }
@UsedByGeneratedCode public static Slice longDecimalToLongDecimal(Slice value, int sourcePrecision, int sourceScale, int resultPrecision, int resultScale) { return encodeUnscaledValue(bigintToBigintFloorSaturatedCast(decodeUnscaledValue(value), sourceScale, resultPrecision, resultScale)); }
@Override protected void writeValue(DecimalOutputStream outputStream, Long value) { outputStream.writeUnscaledValue(Decimals.encodeUnscaledValue(value)); }
public static Block createLongDecimalSequenceBlock(int start, int end, DecimalType type) { BlockBuilder builder = type.createFixedSizeBlockBuilder(end - start); BigInteger base = BigInteger.TEN.pow(type.getScale()); for (int i = start; i < end; ++i) { type.writeSlice(builder, encodeUnscaledValue(BigInteger.valueOf(i).multiply(base))); } return builder.build(); }
public static Block createLongDecimalSequenceBlock(int start, int end, DecimalType type) { BlockBuilder builder = type.createFixedSizeBlockBuilder(end - start); BigInteger base = BigInteger.TEN.pow(type.getScale()); for (int i = start; i < end; ++i) { type.writeSlice(builder, encodeUnscaledValue(BigInteger.valueOf(i).multiply(base))); } return builder.build(); }