@Override public void write(DataOutput output) throws IOException { WritableUtils.writeVInt( output, (byteValue.length + 1) * (this.determinism == Determinism.ALWAYS ? 1 : -1)); output.write(byteValue); // since we need to support clients of a lower version, serialize the determinism enum ordinal // in the int used to // serialize sort order system value (which is either 1 or 2) int sortOrderAndDeterminism = ((this.determinism.ordinal() + 1) << 2) + sortOrder.getSystemValue(); WritableUtils.writeVInt(output, sortOrderAndDeterminism); WritableUtils.writeVInt(output, this.type == null ? -1 : this.type.ordinal()); }
@Override public void write(DataOutput output) throws IOException { // read/write type ordinal, maxLength presence, scale presence and isNullable bit together to // save space int typeAndFlag = (isNullable ? 1 : 0) | ((scale != null ? 1 : 0) << 1) | ((maxLength != null ? 1 : 0) << 2) | (type.ordinal() << 3); WritableUtils.writeVInt(output, typeAndFlag); if (scale != null) { WritableUtils.writeVInt(output, scale); } if (maxLength != null) { WritableUtils.writeVInt(output, maxLength); } WritableUtils.writeVInt(output, sortOrder.getSystemValue()); }