|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectorg.h2.dev.store.btree.DataUtils
public class DataUtils
Utility methods
| Field Summary | |
|---|---|
static int |
MAX_VAR_INT_LEN
The maximum length of a variable size int. |
static int |
MAX_VAR_LONG_LEN
The maximum length of a variable size long. |
static int |
PAGE_COMPRESSED
The bit mask for compressed pages. |
static int |
PAGE_TYPE_LEAF
The type for leaf page. |
static int |
PAGE_TYPE_NODE
The type for node page. |
| Constructor Summary | |
|---|---|
DataUtils()
|
|
| Method Summary | |
|---|---|
static void |
appendMap(java.lang.StringBuilder buff,
java.lang.String key,
java.lang.Object value)
Append a key-value pair to the string buffer. |
static void |
copyExcept(java.lang.Object src,
java.lang.Object dst,
int oldSize,
int removeIndex)
Copy the elements of an array, and remove one element. |
static void |
copyWithGap(java.lang.Object src,
java.lang.Object dst,
int oldSize,
int gapIndex)
Copy the elements of an array, with a gap. |
static int |
encodeLength(int len)
Convert the length to a length code 0..31. 31 means more than 1 MB. |
static short |
getCheckValue(int x)
Calculate a check value for the given integer. |
static int |
getPageChunkId(long pos)
Get the chunk id from the position. |
static int |
getPageMaxLength(long pos)
Get the maximum length for the given code. |
static int |
getPageOffset(long pos)
Get the offset from the position. |
static long |
getPagePos(int chunkId,
int offset,
int length,
int type)
Get the position of this page. |
static int |
getPageType(long pos)
Get the page type from the position. |
static int |
getVarIntLen(int x)
Get the length of the variable size int. |
static int |
getVarLongLen(long x)
Get the length of the variable size long. |
static java.util.HashMap<java.lang.String,java.lang.String> |
parseMap(java.lang.String s)
Parse a key-value pair list. |
static void |
readFully(java.nio.channels.FileChannel file,
java.nio.ByteBuffer buff)
Read from a file channel until the target buffer is full, or end-of-file has been reached. |
static int |
readVarInt(java.nio.ByteBuffer buff)
Read a variable size int. |
static long |
readVarLong(java.nio.ByteBuffer buff)
Read a variable size long. |
static void |
writeVarInt(java.nio.ByteBuffer buff,
int x)
Write a variable size int. |
static void |
writeVarLong(java.nio.ByteBuffer buff,
long x)
Write a variable size int. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int PAGE_TYPE_LEAF
public static final int PAGE_TYPE_NODE
public static final int PAGE_COMPRESSED
public static final int MAX_VAR_INT_LEN
public static final int MAX_VAR_LONG_LEN
| Constructor Detail |
|---|
public DataUtils()
| Method Detail |
|---|
public static int getVarIntLen(int x)
x - the value
public static int getVarLongLen(long x)
x - the value
public static int readVarInt(java.nio.ByteBuffer buff)
buff - the source buffer
public static long readVarLong(java.nio.ByteBuffer buff)
buff - the source buffer
public static void writeVarInt(java.nio.ByteBuffer buff,
int x)
buff - the target bufferx - the value
public static void writeVarLong(java.nio.ByteBuffer buff,
long x)
buff - the target bufferx - the value
public static void copyWithGap(java.lang.Object src,
java.lang.Object dst,
int oldSize,
int gapIndex)
src - the source arraydst - the target arrayoldSize - the size of the old arraygapIndex - the index of the gap
public static void copyExcept(java.lang.Object src,
java.lang.Object dst,
int oldSize,
int removeIndex)
src - the source arraydst - the target arrayoldSize - the size of the old arrayremoveIndex - the index of the entry to remove
public static void readFully(java.nio.channels.FileChannel file,
java.nio.ByteBuffer buff)
throws java.io.IOException
file - the file channelbuff - the target buffer
java.io.IOExceptionpublic static int encodeLength(int len)
len - the length
public static int getPageChunkId(long pos)
pos - the position
public static int getPageMaxLength(long pos)
pos - the position
public static int getPageOffset(long pos)
pos - the position
public static int getPageType(long pos)
pos - the position
public static long getPagePos(int chunkId,
int offset,
int length,
int type)
chunkId - the chunk idoffset - the offsetlength - the lengthtype - the page type (1 for node, 0 for leaf)
public static short getCheckValue(int x)
x - the value
public static void appendMap(java.lang.StringBuilder buff,
java.lang.String key,
java.lang.Object value)
buff - the target bufferkey - the keyvalue - the valuepublic static java.util.HashMap<java.lang.String,java.lang.String> parseMap(java.lang.String s)
s - the list
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||