Exemple #1
0
  @Override
  public void copy(DataInputView in, DataOutputView target) throws IOException {
    int len = in.readUnsignedByte();
    target.writeByte(len);

    if (len >= HIGH_BIT) {
      int shift = 7;
      int curr;
      len = len & 0x7f;
      while ((curr = in.readUnsignedByte()) >= HIGH_BIT) {
        len |= (curr & 0x7f) << shift;
        shift += 7;
        target.writeByte(curr);
      }
      len |= curr << shift;
      target.writeByte(curr);
    }

    for (int i = 0; i < len; i++) {
      int c = in.readUnsignedByte();
      target.writeByte(c);
      while (c >= HIGH_BIT) {
        c = in.readUnsignedByte();
        target.writeByte(c);
      }
    }
  }
Exemple #2
0
 @Override
 public void serialize(TaggedUnion<T1, T2> record, DataOutputView target) throws IOException {
   if (record.isOne()) {
     target.writeByte(1);
     oneSerializer.serialize(record.getOne(), target);
   } else {
     target.writeByte(2);
     twoSerializer.serialize(record.getTwo(), target);
   }
 }
Exemple #3
0
 @Override
 public void copy(DataInputView source, DataOutputView target) throws IOException {
   byte tag = source.readByte();
   target.writeByte(tag);
   if (tag == 1) {
     oneSerializer.copy(source, target);
   } else {
     twoSerializer.copy(source, target);
   }
 }
 protected void writeKeyAndNamespace(DataOutputView out) throws IOException {
   keySerializer.serialize(currentKey, out);
   out.writeByte(42);
   namespaceSerializer.serialize(currentNamespace, out);
 }