public DrillBinaryToDecimal38Converter( Decimal38SparseWriter writer, int precision, int scale, DrillBuf buf) { this.writer = writer; this.buf = buf.reallocIfNeeded(38); holder.precision = precision; holder.scale = scale; }
@Override public void addBinary(Binary value) { holder.buffer = buf = buf.reallocIfNeeded(value.length()); buf.setBytes(0, value.toByteBuffer()); holder.start = 0; holder.end = value.length(); writer.write(holder); }
public static VarCharHolder getVarCharHolder(DrillBuf buf, String s) { VarCharHolder vch = new VarCharHolder(); byte[] b = s.getBytes(Charsets.UTF_8); vch.start = 0; vch.end = b.length; vch.buffer = buf.reallocIfNeeded(b.length); vch.buffer.setBytes(0, b); return vch; }
public static Decimal38SparseHolder getDecimal38Holder(DrillBuf buf, String decimal) { Decimal38SparseHolder dch = new Decimal38SparseHolder(); BigDecimal bigDecimal = new BigDecimal(decimal); dch.scale = bigDecimal.scale(); dch.precision = bigDecimal.precision(); Decimal38SparseHolder.setSign(bigDecimal.signum() == -1, dch.start, dch.buffer); dch.start = 0; dch.buffer = buf.reallocIfNeeded(dch.maxPrecision * DecimalUtility.INTEGER_SIZE); DecimalUtility.getSparseFromBigDecimal( bigDecimal, dch.buffer, dch.start, dch.scale, dch.precision, dch.nDecimalDigits); return dch; }
public DrillFixedBinaryToVarbinaryConverter(VarBinaryWriter writer, int length, DrillBuf buf) { this.writer = writer; holder.buffer = buf = buf.reallocIfNeeded(length); holder.start = 0; holder.end = length; }
private void ensure(final int length) { workBuf = workBuf.reallocIfNeeded(length); }