pwc1.key = 0; pwc1.bigInt = BigInteger.valueOf(Long.MAX_VALUE).multiply(BigInteger.TEN); pwc1.scalaBigInt = BigInt.int2bigInt(10); pwc1.bigDecimalKeepItNull = null; pwc2.key = 0; pwc2.bigInt = BigInteger.valueOf(Long.MAX_VALUE).multiply(BigInteger.TEN); pwc2.scalaBigInt = BigInt.int2bigInt(31104000); pwc2.bigDecimalKeepItNull = null;
private static Object normalize(Object value) { if (value instanceof Long) { return new BigDecimal((Long) value); } else if (value instanceof Integer) { return new BigDecimal((Integer) value); } else if (value instanceof Short) { return new BigDecimal((Short) value); } else if (value instanceof Byte) { return new BigDecimal((Byte) value); } else if (value instanceof scala.math.BigDecimal) { // Convert it to a Java BigDecimal return ((scala.math.BigDecimal) value).bigDecimal(); } return value; }
@Override public int compare( Object baseObj1, long baseOff1, int baseLen1, Object baseObj2, long baseOff2, int baseLen2) { // Note that since ordering doesn't need the total length of the record, we just pass 0 // into the row. row1.pointTo(baseObj1, baseOff1, 0); row2.pointTo(baseObj2, baseOff2, 0); return ordering.compare(row1, row2); } }
@Override public Decimal getDecimal(int ordinal, int precision, int scale) { if (isNullAt(ordinal)) return null; if (precision <= Decimal.MAX_LONG_DIGITS()) { return Decimal.apply(getLong(ordinal), precision, scale); } else { final byte[] bytes = getBinary(ordinal); final BigInteger bigInteger = new BigInteger(bytes); final BigDecimal javaDecimal = new BigDecimal(bigInteger, scale); return Decimal.apply(new scala.math.BigDecimal(javaDecimal), precision, scale); } }
@Test void emptyQuotaRootShouldReturnErrorWhenNotString() { assertThat(DTO_JSON_SERIALIZE.quotaRootReads().reads(new JsNumber(BigDecimal.valueOf(18)))) .isInstanceOf(JsError.class); } }
@Override public Decimal getDecimal(int ordinal, int precision, int scale) { if (isNullAt(ordinal)) return null; if (precision <= Decimal.MAX_LONG_DIGITS()) { return Decimal.apply(getLong(ordinal), precision, scale); } else { final byte[] bytes = getBinary(ordinal); final BigInteger bigInteger = new BigInteger(bytes); final BigDecimal javaDecimal = new BigDecimal(bigInteger, scale); return Decimal.apply(new scala.math.BigDecimal(javaDecimal), precision, scale); } }
@Override public int compare( Object baseObj1, long baseOff1, int baseLen1, Object baseObj2, long baseOff2, int baseLen2) { // Note that since ordering doesn't need the total length of the record, we just pass -1 // into the row. row1.pointTo(baseObj1, baseOff1, -1); row2.pointTo(baseObj2, baseOff2, -1); return ordering.compare(row1, row2); } }
@Test void mailboxIdDeserializationShouldReturnErrorWhenNumber() { assertThat(DTO_JSON_SERIALIZE.mailboxIdReads().reads(new JsNumber(BigDecimal.valueOf(18)))) .isInstanceOf(JsError.class); }
private Object normalize(Object value) { if (value instanceof Long) { return new BigDecimal((Long) value); } else if (value instanceof Integer) { return new BigDecimal((Integer) value); } else if (value instanceof Short) { return new BigDecimal((Short) value); } else if (value instanceof Byte) { return new BigDecimal((Byte) value); } else if (value instanceof scala.math.BigDecimal) { // Convert it to a Java BigDecimal return ((scala.math.BigDecimal) value).bigDecimal(); } return value; }
pwc1.key = new IntValue(0); pwc1.bigInt = BigInteger.valueOf(Long.MAX_VALUE).multiply(BigInteger.TEN); pwc1.scalaBigInt = BigInt.int2bigInt(10); pwc1.bigDecimalKeepItNull = null; pwc2.key = new IntValue(0); pwc2.bigInt = BigInteger.valueOf(Long.MAX_VALUE).multiply(BigInteger.TEN); pwc2.scalaBigInt = BigInt.int2bigInt(31104000); pwc2.bigDecimalKeepItNull = null;
@Override public Decimal getDecimal(int ordinal, int precision, int scale) { if (isNullAt(ordinal)) return null; if (precision <= Decimal.MAX_LONG_DIGITS()) { return Decimal.apply(getLong(ordinal), precision, scale); } else { final byte[] bytes = getBinary(ordinal); final BigInteger bigInteger = new BigInteger(bytes); final BigDecimal javaDecimal = new BigDecimal(bigInteger, scale); return Decimal.apply(new scala.math.BigDecimal(javaDecimal), precision, scale); } }
@Override public int compare( Object baseObj1, long baseOff1, int baseLen1, Object baseObj2, long baseOff2, int baseLen2) { // Note that since ordering doesn't need the total length of the record, we just pass 0 // into the row. row1.pointTo(baseObj1, baseOff1, 0); row2.pointTo(baseObj2, baseOff2, 0); return ordering.compare(row1, row2); } }
@Test void messageIdDeserializationShouldReturnErrorWhenNumber() { assertThat(DTO_JSON_SERIALIZE.messageIdReads().reads(new JsNumber(BigDecimal.valueOf(18)))) .isInstanceOf(JsError.class); }
private static Object normalize(Object value) { if (value instanceof Long) { return new BigDecimal((Long) value); } else if (value instanceof Integer) { return new BigDecimal((Integer) value); } else if (value instanceof Short) { return new BigDecimal((Short) value); } else if (value instanceof Byte) { return new BigDecimal((Byte) value); } else if (value instanceof scala.math.BigDecimal) { // Convert it to a Java BigDecimal return ((scala.math.BigDecimal) value).bigDecimal(); } return value; }
@Override public void convert(UnsafeRowWriter writer, int column, ColumnVector vector, int row) { if (vector.isRepeating) { row = 0; } if (!vector.noNulls && vector.isNull[row]) { writer.setNullAt(column); } else { BigDecimal v = ((DecimalColumnVector) vector).vector[row] .getHiveDecimal().bigDecimalValue(); writer.write(column, new Decimal().set(new scala.math.BigDecimal(v), precision, scale), precision, scale); } }
@Test void deSerializeShouldThrowWhenNameInEntryKeyIsNotString() { assertThat(DTO_JSON_SERIALIZE.aclEntryKeyReads().reads(new JsNumber(BigDecimal.valueOf(18)))) .isInstanceOf(JsError.class); } }
private Object normalize(Object value) { if (value instanceof Long) { return new BigDecimal((Long) value); } else if (value instanceof Integer) { return new BigDecimal((Integer) value); } else if (value instanceof Short) { return new BigDecimal((Short) value); } else if (value instanceof Byte) { return new BigDecimal((Byte) value); } else if (value instanceof scala.math.BigDecimal) { // Convert it to a Java BigDecimal return ((scala.math.BigDecimal) value).bigDecimal(); } return value; }
@Override public void convert(UnsafeArrayWriter writer, int element, ColumnVector vector, int row) { if (vector.isRepeating) { row = 0; } if (!vector.noNulls && vector.isNull[row]) { writer.setNull(element); } else { BigDecimal v = ((DecimalColumnVector) vector).vector[row] .getHiveDecimal().bigDecimalValue(); writer.write(element, new Decimal().set(new scala.math.BigDecimal(v), precision, scale), precision, scale); } } }
@Test void eventIdDeserializationShouldReturnErrorWhenNumber() { assertThat(DTO_JSON_SERIALIZE.eventIdReads().reads(new JsNumber(BigDecimal.valueOf(18)))) .isInstanceOf(JsError.class); }
@Test void deSerializeShouldThrowWhenRightIsNotString() { assertThat(DTO_JSON_SERIALIZE.aclRightsReads().reads(new JsNumber(BigDecimal.valueOf(18)))) .isInstanceOf(JsError.class); } }