@Override public void readFields(DataInput input) throws IOException { int encodedByteLengthAndBool = WritableUtils.readVInt(input); int byteLength = Math.abs(encodedByteLengthAndBool) - 1; this.byteValue = new byte[byteLength]; input.readFully(byteValue, 0, byteLength); int sortOrderAndDeterminism = WritableUtils.readVInt(input); if (sortOrderAndDeterminism <= 2) { // client is on an older version this.determinism = encodedByteLengthAndBool > 0 ? Determinism.ALWAYS : Determinism.PER_ROW; this.sortOrder = SortOrder.fromSystemValue(sortOrderAndDeterminism); ; } else { int determinismOrdinal = (sortOrderAndDeterminism >> 2) - 1; this.determinism = Determinism.values()[determinismOrdinal]; int sortOrderValue = sortOrderAndDeterminism & ((1 << 2) - 1); // get the least 2 significant bits this.sortOrder = SortOrder.fromSystemValue(sortOrderValue); } int typeOrdinal = WritableUtils.readVInt(input); if (typeOrdinal < 0) { this.type = null; } else { this.type = PDataType.values()[typeOrdinal]; } if (this.byteValue.length == 0) { this.value = null; } else { this.value = this.type.toObject(byteValue, 0, byteValue.length, this.type, sortOrder); } }
@Override public void readFields(DataInput input) throws IOException { // read/write type ordinal, maxLength presence, scale presence and isNullable bit together to // save space int typeAndFlag = WritableUtils.readVInt(input); isNullable = (typeAndFlag & 0x01) != 0; if ((typeAndFlag & 0x02) != 0) { scale = WritableUtils.readVInt(input); } if ((typeAndFlag & 0x04) != 0) { maxLength = WritableUtils.readVInt(input); } type = PDataType.values()[typeAndFlag >>> 3]; sortOrder = SortOrder.fromSystemValue(WritableUtils.readVInt(input)); }