scratch = new Decimal128FastBuffer();
}
private void doTestFastStreamForHiveDecimal(String valueString) {
BigDecimal value = new BigDecimal(valueString);
Decimal128 dec = new Decimal128();
dec.update(value);
HiveDecimalWritable witness = new HiveDecimalWritable();
witness.set(HiveDecimal.create(value));
int bufferUsed = dec.fastSerializeForHiveDecimal(scratch);
HiveDecimalWritable hdw = new HiveDecimalWritable();
hdw.set(scratch.getBytes(bufferUsed), dec.getScale());
HiveDecimal hd = hdw.getHiveDecimal();
BigDecimal readValue = hd.bigDecimalValue();
Assert.assertEquals(value, readValue);
// Now test fastUpdate from the same serialized HiveDecimal
Decimal128 decRead = new Decimal128().fastUpdateFromInternalStorage(
witness.getInternalStorage(), (short) witness.getScale());
Assert.assertEquals(dec, decRead);
// Test fastUpdate from it's own (not fully compacted) serialized output
Decimal128 decReadSelf = new Decimal128().fastUpdateFromInternalStorage(
hdw.getInternalStorage(), (short) hdw.getScale());
Assert.assertEquals(dec, decReadSelf);
}