public class Page extends Object
| Modifier and Type | Field and Description | 
|---|---|
static int | 
pageSize  | 
| Constructor and Description | 
|---|
Page(FileChannel fc,
    int blockNum,
    int pageNum)
Create a new page using fc with at offset blockNum with virtual page number pageNum 
 | 
Page(FileChannel fc,
    int blockNum,
    int pageNum,
    boolean durable)  | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
flush()
Force the page to disk. 
 | 
int | 
getPageNum()  | 
byte | 
readByte(int position)
Read the single byte at offset position. 
 | 
byte[] | 
readBytes()
Read all the bytes in file. 
 | 
byte[] | 
readBytes(int position,
         int num)
Reads num bytes from offset position and returns them in a new byte array. 
 | 
void | 
readBytes(int position,
         int num,
         byte[] buf)
Reads num bytes from offset position into buf. 
 | 
int | 
readInt(int startPos)
Read a 4-byte integer from the page at offset startPos. 
 | 
void | 
wipe()
Completely wipe (zero out) the page. 
 | 
void | 
writeByte(int position,
         byte b)
Write a single byte into the file at offset position. 
 | 
void | 
writeBytes(int position,
          int num,
          byte[] buf)
Write num bytes from buf at offset position. 
 | 
void | 
writeInt(int startPos,
        int value)
Write a 4-byte integer into the page at offset startPos. 
 | 
public static final int pageSize
public Page(FileChannel fc, int blockNum, int pageNum)
fc - the file channel for this PageblockNum - the block in the file for this pagepageNum - the virtual page numberpublic Page(FileChannel fc, int blockNum, int pageNum, boolean durable)
public void readBytes(int position,
             int num,
             byte[] buf)
position - the offset in the page to read fromnum - the number of bytes to readbuf - the buffer to put the bytes intopublic byte[] readBytes(int position,
               int num)
position - the offset in the page to read fromnum - the number of bytes to readpublic byte[] readBytes()
public byte readByte(int position)
position - the offest in the page to read frompublic void writeBytes(int position,
              int num,
              byte[] buf)
position - the offest in the file to write tonum - the number of bytes to writebuf - the source for the writepublic void writeByte(int position,
             byte b)
position - the offset in the file to write tob - the byte to writepublic void writeInt(int startPos,
            int value)
startPos - the offset in the file to write tovalue - the value to writepublic int readInt(int startPos)
startPos - the offset in the file to read frompublic void wipe()
public void flush()
public int getPageNum()
Copyright © 2017. All rights reserved.