| java.lang.Object com.quadcap.sql.file.Cacheable com.quadcap.sql.file.Block
Block | public class Block extends Cacheable implements Page(Code) | | This class represents a block/page of data in a random access file,
which may be cached. The key is an Integer specifying the block
number, while the data is a byte array containing the actual
data.
author: Stan Bailes |
Method Summary | |
public void | clear() | final public void | flush() Write the contents of the buffer back to the underlying store. | final public Object | getData() From the Cacheable class, return the underlying data object. | public byte[] | getDataAndReset() Return a reference to the array containing the data for this
block, and create a new buffer, so that the reference returned
can be used in a subsequent setData call to another
buffer. | public long | getPageNum() | public void | init(Object store, long key) Initialize this block. | void | init() | public static void | main(String args) | final public int | read(int pos, byte[] pbuf, int offset, int len) Read a range of bytes from the page. | final public byte | readByte(int pos) | final public int | readInt(int pos) Read an integer (4-byte) value from the page. | final public long | readLong(int pos) Read a long (8-byte) value from the page. | final public short | readShort(int pos) Read a short (2-byte) value from the page. | public void | setData(Object obj) From the Cacheable class, set the underlying data object. | public String | signature() | public static String | signature(byte[] buf) | public static String | signature(byte[] buf, int off, int cnt) | final public void | takeData(Page p) | public String | toString() Only a debugging version implemented so far... | final public int | write(int pos, byte[] pbuf, int offset, int len) Write a range of bytes to the page. | final public void | writeByte(int pos, byte val) | final public void | writeInt(int pos, int val) Write an integer (4-byte) value to the page. | final public void | writeLong(int pos, long val) Write a long (8-byte) value to the page. | final public void | writeShort(int pos, short val) Write a short (2-byte) value to the page. |
clear | public void clear()(Code) | | |
flush | final public void flush() throws IOException(Code) | | Write the contents of the buffer back to the underlying store.
|
getData | final public Object getData()(Code) | | From the Cacheable class, return the underlying data object.
When used as a Block, we typically use the read()
and write methods to access the underlying data...
|
getDataAndReset | public byte[] getDataAndReset()(Code) | | Return a reference to the array containing the data for this
block, and create a new buffer, so that the reference returned
can be used in a subsequent setData call to another
buffer. This allows the contents of one block to be moved to
another block with a minimum of array copying.
|
getPageNum | public long getPageNum()(Code) | | |
init | public void init(Object store, long key) throws IOException(Code) | | Initialize this block. Create the buffer if necessary, and initialize
the buffer contents from the underlying store. We assume that the
BlockStore.read() method will fill the buffer with zeros
if we're attempting to "read" a block that doesn't exist yet.
Parameters: store - the underlying BlockStore which managesthe blocks. Parameters: key - an Integer specifying the block number. |
read | final public int read(int pos, byte[] pbuf, int offset, int len)(Code) | | Read a range of bytes from the page.
Parameters: pos - the offset in the page of the first byte to read Parameters: pbuf - the buffer into which the bytes are placed. Parameters: offset - the offset in pbuf where the first byteis placed. Parameters: len - the number of bytes to read |
readByte | final public byte readByte(int pos)(Code) | | |
readInt | final public int readInt(int pos)(Code) | | Read an integer (4-byte) value from the page.
Parameters: pos - the offset in the page of the integer. |
readLong | final public long readLong(int pos)(Code) | | Read a long (8-byte) value from the page.
Parameters: pos - the offset in the page of the long. |
readShort | final public short readShort(int pos)(Code) | | Read a short (2-byte) value from the page.
Parameters: pos - the offset in the page of the short. |
setData | public void setData(Object obj)(Code) | | From the Cacheable class, set the underlying data object.
When used as a Block, we typically use the read()
and write methods to access the underlying data...
|
signature | public static String signature(byte[] buf, int off, int cnt)(Code) | | |
toString | public String toString()(Code) | | Only a debugging version implemented so far...
|
write | final public int write(int pos, byte[] pbuf, int offset, int len)(Code) | | Write a range of bytes to the page.
Parameters: pos - the offset in the page of the first byte to write Parameters: pbuf - the buffer from which the bytes are obtained Parameters: offset - the offset in pbuf of the first byteto write Parameters: len - the number of bytes to write |
writeByte | final public void writeByte(int pos, byte val)(Code) | | |
writeInt | final public void writeInt(int pos, int val)(Code) | | Write an integer (4-byte) value to the page.
Parameters: pos - the offset in the page of the integer. Parameters: val - the integer value to write. |
writeLong | final public void writeLong(int pos, long val)(Code) | | Write a long (8-byte) value to the page.
Parameters: pos - the offset in the page of the long. Parameters: val - the long value to write. |
writeShort | final public void writeShort(int pos, short val)(Code) | | Write a short (2-byte) value to the page.
Parameters: pos - the offset in the page of the short. Parameters: val - the short value to write. |
|
|