@Override
 public void close() throws IOException {
   if (closed) {
     return;
   }
   if (null != writer) {
     writer.close(null);
   }
   if (null != nativeReader) {
     nativeReader.close();
   }
   closed = true;
 }
 @SuppressWarnings("unchecked")
 private boolean write(InputBuffer input) throws IOException {
   if (closed) {
     return false;
   }
   int totalRead = 0;
   final int remain = input.remaining();
   this.nativeReader.reset(input);
   while (remain > totalRead) {
     final int read = deserializer.deserializeKV(nativeReader, tmpOutputKey, tmpOutputValue);
     if (read != 0) {
       totalRead += read;
       writer.write((OK) (tmpOutputKey.v), (OV) (tmpOutputValue.v));
     }
   }
   if (remain != totalRead) {
     throw new IOException("We expect to read " + remain + ", but we actually read: " + totalRead);
   }
   return true;
 }