/** Gets the page, including metadata, as a byte buffer ready for sending over the network */
  public static ByteBuffer pageToByteBuffer(Page p) {
    int bufLen = encodedPageSize(p);

    ByteBuffer result = ByteBuffer.allocate(bufLen);
    Dlugosz.encode(p.getPageNumber(), result);
    Dlugosz.encode(p.getByteOffset(), result);
    Dlugosz.encode(p.getTimeOffset(), result);
    p.getData().flip();
    result.put(p.getData());

    return result;
  }
 public static void encodePageInfo(PageInfo pi, ByteBuffer buf) {
   Dlugosz.encode(pi.getPageNumber(), buf);
   Dlugosz.encode(pi.getLength(), buf);
   Dlugosz.encode(pi.getByteOffset(), buf);
   Dlugosz.encode(pi.getTimeOffset(), buf);
 }