/** 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 int encodedPageSize(Page p) { return Dlugosz.bytesToEncode(p.getPageNumber()) + Dlugosz.bytesToEncode(p.getByteOffset()) + Dlugosz.bytesToEncode(p.getTimeOffset()) + p.getData().limit(); }