public void write(DataOutput out) throws IOException { Encoder kvEncoder = codec.getEncoder((DataOutputStream) out); out.writeInt(VERSION_2); //write out the keyvalues out.writeInt(kvs.size()); for(KeyValue kv: kvs){ kvEncoder.write(kv); } kvEncoder.flush(); out.writeInt(scopes.size()); for (byte[] key : scopes.keySet()) { Bytes.writeByteArray(out, key); out.writeInt(scopes.get(key)); } }
public void write(DataOutput out) throws IOException { Encoder kvEncoder = codec.getEncoder((DataOutputStream) out); out.writeInt(VERSION_2); //write out the keyvalues out.writeInt(kvs.size()); for(KeyValue kv: kvs){ kvEncoder.write(kv); } kvEncoder.flush(); if (scopes == null) { out.writeInt(0); } else { out.writeInt(scopes.size()); for (byte[] key : scopes.keySet()) { Bytes.writeByteArray(out, key); out.writeInt(scopes.get(key)); } } }
@Override public Encoder getEncoder(OutputStream os) { return (compression == null) ? new KeyValueCodec.KeyValueEncoder((DataOutputStream) os) : new CompressedKvEncoder((DataOutputStream) os, compression); }