@SuppressWarnings("deprecation") @Override public void readFields(DataInput in) throws IOException { int head = in.readByte() & 0xff; if ((head & MASK_PRESENT) == 0) { setNull(); return; } boolean plus = (head & MASK_PLUS) != 0; int scale = WritableUtils.readVInt(in); int length = WritableUtils.readVInt(in); DecimalBuffer buffer = BUFFER_MAIN.get(); byte[] target = buffer.setMeta(plus, scale, length); in.readFully(target, target.length - length, length); modify(buffer.toBigDecimal()); }
@SuppressWarnings("deprecation") private void fill0(DecimalOption option, boolean doRecover) throws CsvFormatException { if (lineBuffer.hasRemaining()) { try { BigDecimal value = toBigDecimal(); option.modify(value); } catch (NumberFormatException e) { if (doRecover && trimWhitespaces()) { fill0(option, false); return; } throw new CsvFormatException(createStatusInLine(Reason.INVALID_CELL_FORMAT, "decimal value"), e); } } else { option.setNull(); } }
@SuppressWarnings("deprecation") @Override public int restore(byte[] bytes, int offset, int limit) throws IOException { int cursor = offset; int head = bytes[cursor++] & 0xff; if ((head & MASK_PRESENT) == 0) { setNull(); } else { boolean plus = (head & MASK_PLUS) != 0; int scale = WritableComparator.readVInt(bytes, cursor); cursor += WritableUtils.decodeVIntSize(bytes[cursor]); int length = WritableComparator.readVInt(bytes, cursor); cursor += WritableUtils.decodeVIntSize(bytes[cursor]); DecimalBuffer buffer = BUFFER_MAIN.get(); buffer.set(plus, scale, bytes, cursor, length); cursor += length; modify(buffer.toBigDecimal()); } return cursor - offset; }
emitter.endRecord(); value.setNull(); emitter.emit(value); value.modify(decimal("0.9999999999999999999999999999999999999999999999999"));