public static void writeOrdinal(DataOutput out, short ordinal, boolean compressed)
      throws IOException {
    if (compressed && ordinal <= Byte.MAX_VALUE) {
      out.writeByte(ordinal);
    } else {
      out.writeByte(KnownVersion.TOKEN_ORDINAL);
      out.writeShort(ordinal);
    }
  }
Write the given ordinal (result of {@link Version#ordinal()}) to given
{@link DataOutput}. This keeps
the serialization of ordinal compatible with previous versions writing a single byte to
DataOutput when possible, and a token with 2 bytes if it is large.

@param out the {@link DataOutput} to write the ordinal write to
@param ordinal the version to be written
@param compressed if true, then use single byte for ordinal < 128, and three bytes for beyond
       that, else always use three bytes where the first byte is
       {@link KnownVersion#TOKEN_ORDINAL};
       former
       mode is useful for interoperatibility with previous versions while latter to use fixed
       size for writing version; typically former will be used for P2P/client-server
       communications while latter for persisting to disk; we use the token to ensure that
       {@link #readOrdinal(DataInput)} can deal with both compressed/uncompressed cases
       seemlessly
geode-serialization/src/main/java/org/apache/geode/internal/serialization/VersioningIO.java