@Override
  public void write(DataOutput out) throws IOException {
    Buffer buffer = page.buffer();
    out.writeInt(buffer.limit());
    out.write(buffer.array(), buffer.offset(), buffer.limit());

    List<String> stringReferences = page.getStringReferences();
    WritableUtils.writeVInt(out, stringReferences.size());
    for (String s : stringReferences) {
      out.writeUTF(s);
    }
  }
Example #2
0
 public Buffer poll() {
   if (current == null) {
     throw new IllegalStateException("nextFile() must be called before poll()");
   }
   Buffer buffer = allocator.allocate();
   try {
     int n = current.read(buffer.array(), buffer.offset(), buffer.capacity());
     if (n < 0) {
       return null;
     }
     buffer.limit(n);
     Buffer b = buffer;
     buffer = null;
     return b;
   } catch (IOException ex) {
     throw new RuntimeException(ex);
   } finally {
     if (buffer != null) {
       buffer.release();
       buffer = null;
     }
   }
 }