@Override
 public int write(OutputStream out, boolean withTags) throws IOException {
   int lenToWrite =
       KeyValueUtil.length(
           rowLength, familyLength, qualifierLength, valueLength, tagsLength, withTags);
   ByteBufferUtils.putInt(out, lenToWrite);
   ByteBufferUtils.putInt(out, keyBuffer.capacity());
   ByteBufferUtils.putInt(out, valueLength);
   // Write key
   out.write(keyBuffer.array());
   // Write value
   ByteBufferUtils.writeByteBuffer(out, this.valueBuffer, this.valueOffset, this.valueLength);
   if (withTags) {
     // 2 bytes tags length followed by tags bytes
     // tags length is serialized with 2 bytes only(short way) even if the type is int.
     // As this is non -ve numbers, we save the sign bit. See HBASE-11437
     out.write((byte) (0xff & (this.tagsLength >> 8)));
     out.write((byte) (0xff & this.tagsLength));
     ByteBufferUtils.writeByteBuffer(out, this.tagsBuffer, this.tagsOffset, this.tagsLength);
   }
   return lenToWrite + Bytes.SIZEOF_INT;
 }
Пример #2
0
 @Override
 public SingleByteBuff putInt(int value) {
   ByteBufferUtils.putInt(this.buf, value);
   return this;
 }