@Test public void stress_write() throws Exception { int count = 10000000; DecimalOption option = new DecimalOption(new BigDecimal("3.14")); DataOutput out = new DataOutputStream(new NullOutputStream()); for (int i = 0; i < count; i++) { option.write(out); } }
@Override public void write(DataOutput out) throws IOException { if (nullValue) { out.writeByte(HEAD_NULL); } else { DecimalBuffer buffer = BUFFER_MAIN.get(); buffer.set(entity); int head = MASK_PRESENT; if (buffer.plus) { head |= MASK_PLUS; } out.writeByte(head); WritableUtils.writeVInt(out, buffer.scale); byte[] bs = buffer.unsigned; int length = bs.length; for (int i = 0; i < bs.length; i++) { if (bs[i] == 0) { length--; } else { break; } } WritableUtils.writeVInt(out, length); if (length != 0) { out.write(bs, bs.length - length, length); } } }
DecimalOption extends ValueOption<DecimalOption> { @Override public void write(DataOutput out) throws IOException { if (nullValue) { out.writeByte(HEAD_NULL); } else { DecimalBuffer buffer = BUFFER_MAIN.get(); buffer.set(entity); int head = MASK_PRESENT; if (buffer.plus) { head |= MASK_PLUS; } out.writeByte(head); WritableUtils.writeVInt(out, buffer.scale); byte[] bs = buffer.unsigned; int length = bs.length; for (int i = 0; i < bs.length; i++) { if (bs[i] == 0) { length--; } else { break; } } WritableUtils.writeVInt(out, length); if (length != 0) { out.write(bs, bs.length - length, length); } } } }
DecimalOption extends ValueOption<DecimalOption> { @Override public void write(DataOutput out) throws IOException { if (nullValue) { out.writeByte(HEAD_NULL); } else { DecimalBuffer buffer = BUFFER_MAIN.get(); buffer.set(entity); int head = MASK_PRESENT; if (buffer.plus) { head |= MASK_PLUS; } out.writeByte(head); WritableUtils.writeVInt(out, buffer.scale); byte[] bs = buffer.unsigned; int length = bs.length; for (int i = 0; i < bs.length; i++) { if (bs[i] == 0) { length--; } else { break; } } WritableUtils.writeVInt(out, length); if (length != 0) { out.write(bs, bs.length - length, length); } } } DecimalOption();  DecimalOption(BigDecimal valueOrNull); }
DecimalOption extends ValueOption<DecimalOption> { @Override public void write(DataOutput out) throws IOException { if (nullValue) { out.writeByte(HEAD_NULL); } else { DecimalBuffer buffer = BUFFER_MAIN.get(); buffer.set(entity); int head = MASK_PRESENT; if (buffer.plus) { head |= MASK_PLUS; } out.writeByte(head); WritableUtils.writeVInt(out, buffer.scale); byte[] bs = buffer.unsigned; int length = bs.length; for (int i = 0; i < bs.length; i++) { if (bs[i] == 0) { length--; } else { break; } } WritableUtils.writeVInt(out, length); if (length != 0) { out.write(bs, bs.length - length, length); } } } DecimalOption();  DecimalOption(BigDecimal valueOrNull); BigDecimal get(); BigDecimal or(BigDecimal alternate); void add(BigDecimal delta); void add(DecimalOption other); @Deprecated DecimalOption modify(BigDecimal newValue); @Override @Deprecated void copyFrom(DecimalOption optionOrNull); @Override int hashCode(); @Override boolean equals(Object obj); boolean has(BigDecimal other); @Override int compareTo(WritableRawComparable o); @Override String toString(); @Override void write(DataOutput out); @SuppressWarnings("deprecation") @Override void readFields(DataInput in); @SuppressWarnings("deprecation") @Override int restore(byte[] bytes, int offset, int limit); @Override int getSizeInBytes(byte[] buf, int offset); @Override int compareInBytes(byte[] b1, int o1, byte[] b2, int o2); static int getBytesLength(byte[] bytes, int offset, int length); static int compareBytes(
            byte[] b1, int s1, int l1,
            byte[] b2, int s2, int l2); }
DecimalOption extends ValueOption<DecimalOption> { @Override public void write(DataOutput out) throws IOException { if (nullValue) { out.writeByte(HEAD_NULL); } else { DecimalBuffer buffer = BUFFER_MAIN.get(); buffer.set(entity); int head = MASK_PRESENT; if (buffer.plus) { head |= MASK_PLUS; } out.writeByte(head); WritableUtils.writeVInt(out, buffer.scale); byte[] bs = buffer.unsigned; int length = bs.length; for (int i = 0; i < bs.length; i++) { if (bs[i] == 0) { length--; } else { break; } } WritableUtils.writeVInt(out, length); if (length != 0) { out.write(bs, bs.length - length, length); } } } DecimalOption();  DecimalOption(BigDecimal valueOrNull); BigDecimal get(); BigDecimal or(BigDecimal alternate); void add(BigDecimal delta); void add(DecimalOption other); @Deprecated DecimalOption modify(BigDecimal newValue); @Override @Deprecated void copyFrom(DecimalOption optionOrNull); @Override int hashCode(); @Override boolean equals(Object obj); boolean has(BigDecimal other); @Override int compareTo(WritableRawComparable o); @Override String toString(); @Override void write(DataOutput out); @SuppressWarnings("deprecation") @Override void readFields(DataInput in); @SuppressWarnings("deprecation") @Override int restore(byte[] bytes, int offset, int limit); @Override int getSizeInBytes(byte[] buf, int offset); @Override int compareInBytes(byte[] b1, int o1, byte[] b2, int o2); static int getBytesLength(byte[] bytes, int offset, int length); static int compareBytes(
            byte[] b1, int s1, int l1,
            byte[] b2, int s2, int l2);  }