|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.h2.store.DataPage
public class DataPage
A data page is a byte buffer that contains persistent data of a row or index page.
Field Summary | |
---|---|
protected byte[] |
data
The data itself. |
protected DataHandler |
handler
The data handler responsible for lob objects. |
static int |
LENGTH_FILLER
The space required for the checksum and additional fillers. |
static int |
LENGTH_INT
The length of an integer value. |
static int |
LENGTH_LONG
The length of a long value. |
protected int |
pos
The current write or read position. |
Constructor Summary | |
---|---|
protected |
DataPage(DataHandler handler,
byte[] data)
|
Method Summary | |
---|---|
void |
check(int len)
Test if the checksum is correct. |
void |
checkCapacity(int plus)
Check if there is still enough capacity in the buffer. |
static DataPage |
create(DataHandler handler,
byte[] buff)
Create a new data page using the given data for the given handler. |
static DataPage |
create(DataHandler handler,
int capacity)
Create a new data page for the given handler. |
void |
fill(int len)
Increase the size to the given length. |
void |
fillAligned()
Fill up the buffer with empty space and an (initially empty) checksum until the size is a multiple of Constants.FILE_BLOCK_SIZE. |
byte[] |
getBytes()
Get the byte array used for this page. |
int |
getStringLen(java.lang.String s)
Get the length of a String value. |
int |
getValueLen(Value v)
Calculate the number of bytes required to encode the given value. |
int |
length()
Get the current write position of this data page, which is the current length. |
void |
read(byte[] buff,
int off,
int len)
Copy a number of bytes to the given buffer from the current position. |
int |
readByte()
Read one single byte. |
DataPage |
readDataPageNoSize()
Read a data page from this page. |
int |
readInt()
Read an integer at the current position. |
long |
readLong()
Read a long value. |
int |
readShortInt()
Read an short integer at the current position. |
java.lang.String |
readString()
Read a String value. |
Value |
readValue()
Read a value. |
void |
reset()
Set the position to 0. |
void |
setInt(int pos,
int x)
Update an integer at the given position. |
void |
setPos(int pos)
Set the current read / write position. |
void |
updateChecksum()
Calculate the checksum and write. |
void |
write(byte[] buff,
int off,
int len)
Append a number of bytes to this data page. |
void |
writeByte(byte x)
Append one single byte. |
void |
writeDataPageNoSize(DataPage page)
Append the contents of the given data page to this page. |
void |
writeInt(int x)
Write an integer at the current position. |
void |
writeLong(long x)
Append a long value. |
void |
writeShortInt(int x)
Write a short integer at the current position. |
void |
writeString(java.lang.String s)
Write a String value. |
void |
writeValue(Value v)
Append a value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int LENGTH_FILLER
public static final int LENGTH_INT
public static final int LENGTH_LONG
protected DataHandler handler
protected byte[] data
protected int pos
Constructor Detail |
---|
protected DataPage(DataHandler handler, byte[] data)
Method Detail |
---|
public void updateChecksum()
public void check(int len) throws java.sql.SQLException
len
- the number of bytes
java.sql.SQLException
- if the checksum does not matchpublic void setInt(int pos, int x)
pos
- the positionx
- the valuepublic void writeInt(int x)
x
- the valuepublic int readInt()
public int getStringLen(java.lang.String s)
s
- the value
public java.lang.String readString()
public void writeString(java.lang.String s)
s
- the valuepublic void fill(int len)
len
- the new lengthpublic static DataPage create(DataHandler handler, int capacity)
handler
- the data handlercapacity
- the initial capacity of the buffer
public static DataPage create(DataHandler handler, byte[] buff)
handler
- the data handlerbuff
- the data
public void checkCapacity(int plus)
plus
- the number of additional bytes requiredpublic int length()
public byte[] getBytes()
public void reset()
public void writeDataPageNoSize(DataPage page)
page
- the page that will be appendedpublic DataPage readDataPageNoSize()
public void write(byte[] buff, int off, int len)
buff
- the dataoff
- the offset in the datalen
- the length in bytespublic void read(byte[] buff, int off, int len)
buff
- the output bufferoff
- the offset in the output bufferlen
- the number of bytes to copypublic void writeByte(byte x)
x
- the valuepublic int readByte()
public long readLong()
public void writeLong(long x)
x
- the valuepublic void writeValue(Value v) throws java.sql.SQLException
v
- the value
java.sql.SQLException
public int getValueLen(Value v) throws java.sql.SQLException
v
- the value
java.sql.SQLException
public Value readValue() throws java.sql.SQLException
java.sql.SQLException
public void fillAligned()
public void setPos(int pos)
pos
- the new positionpublic void writeShortInt(int x)
x
- the valuepublic int readShortInt()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |