public DrillBinaryToDecimal28Converter(
     Decimal28SparseWriter writer, int precision, int scale, DrillBuf buf) {
   this.writer = writer;
   this.buf = buf.reallocIfNeeded(28);
   holder.precision = precision;
   holder.scale = scale;
 }
 @Override
 public void addBinary(Binary value) {
   BigDecimal bigDecimal =
       DecimalUtility.getBigDecimalFromByteArray(
           value.getBytes(), 0, value.length(), holder.scale);
   DecimalUtility.getSparseFromBigDecimal(
       bigDecimal, buf, 0, holder.scale, holder.precision, Decimal28SparseHolder.nDecimalDigits);
   holder.buffer = buf;
   writer.write(holder);
 }
Ejemplo n.º 3
0
  public static Decimal28SparseHolder getDecimal28Holder(DrillBuf buf, String decimal) {

    Decimal28SparseHolder dch = new Decimal28SparseHolder();

    BigDecimal bigDecimal = new BigDecimal(decimal);

    dch.scale = bigDecimal.scale();
    dch.precision = bigDecimal.precision();
    Decimal28SparseHolder.setSign(bigDecimal.signum() == -1, dch.start, dch.buffer);
    dch.start = 0;
    dch.buffer = buf.reallocIfNeeded(5 * DecimalUtility.INTEGER_SIZE);
    DecimalUtility.getSparseFromBigDecimal(
        bigDecimal, dch.buffer, dch.start, dch.scale, dch.precision, dch.nDecimalDigits);

    return dch;
  }