Top Description Fields Constructors Methods
org.h2.mvstore

public final Class DataUtils

extends Object
Class Inheritance
Imports
java.io.EOFException, .IOException, .OutputStream, java.nio.ByteBuffer, java.nio.channels.FileChannel, java.nio.charset.StandardCharsets, java.text.MessageFormat, java.util.Arrays, .HashMap, .Map, org.h2.engine.Constants, org.h2.jdbc.JdbcException, org.h2.util.StringUtils

Utility methods

Field Summary

Modifier and TypeField and Description
public static final int
COMPRESSED_VAR_INT_MAX

The maximum integer that needs less space when using variable size encoding (only 3 bytes instead of 4).

public static final long
COMPRESSED_VAR_LONG_MAX

The maximum long that needs less space when using variable size encoding (only 7 bytes instead of 8).

public static final int
ERROR_BLOCK_NOT_FOUND

The block in the stream store was not found.

public static final int
ERROR_CHUNK_NOT_FOUND

The application was trying to read data from a chunk that is no longer available.

public static final int
ERROR_CLOSED

The object is already closed.

public static final int
ERROR_FILE_CORRUPT

The file is corrupt or (for encrypted files) the encryption key is wrong.

public static final int
ERROR_FILE_LOCKED

The file is locked.

public static final int
ERROR_INTERNAL

An internal error occurred.

public static final int
ERROR_READING_FAILED

An error occurred while reading from the file.

public static final int
ERROR_SERIALIZATION

An error occurred when serializing or de-serializing.

public static final int
ERROR_TOO_MANY_OPEN_TRANSACTIONS

There are too many open transactions.

public static final int
ERROR_TRANSACTION_CORRUPT

The transaction store is corrupt.

public static final int
ERROR_TRANSACTION_ILLEGAL_STATE

The transaction store is in an illegal state (for example, not yet initialized).

public static final int
ERROR_TRANSACTION_LOCKED

An entry is still locked by another transaction.

public static final int
ERROR_TRANSACTION_TOO_BIG

The transaction contains too many changes.

public static final int
ERROR_TRANSACTIONS_DEADLOCK

Deadlock discovered and one of transactions involved chosen as victim and rolled back.

public static final int
ERROR_UNKNOWN_DATA_TYPE

The transaction store can not be initialized because data type is not found in type registry.

public static final int
ERROR_UNSUPPORTED_FORMAT

The file format is not supported.

public static final int
ERROR_WRITING_FAILED

An error occurred when trying to write to the file.

public static final String
META_CHUNK

The prefix for chunks ("chunk.").

public static final String
META_MAP

The prefix for maps ("map.").

public static final String
META_NAME

The prefix for names ("name.").

public static final String
META_ROOT

The prefix for root positions of maps ("root.").

public static final int
PAGE_COMPRESSED

The bit mask for compressed pages (compression level fast).

public static final int
PAGE_COMPRESSED_HIGH

The bit mask for compressed pages (compression level high).

public static final int
PAGE_LARGE

The marker size of a very large page.

public static final int
PAGE_TYPE_LEAF

The type for leaf page.

public static final int
PAGE_TYPE_NODE

The type for node page.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static StringBuilder

Returns:

the string builder
appendMap
(StringBuilder
the target buffer
buff
,
HashMap<String, ?>
the map
map
)

Append a map to the string builder, sorted by key.

public static void
appendMap(StringBuilder
the target buffer
buff
,
String
the key
key
,
String
the value
value
)

Append a key-value pair to the string builder.

public static void
appendMap(StringBuilder
the target buffer
buff
,
String
the key
key
,
long
the value
value
)

Append a key-value pair to the string builder.

public static void
appendMap(StringBuilder
the target buffer
buff
,
String
the key
key
,
int
the value
value
)

Append a key-value pair to the string builder.

private static StringBuilder
public static void
checkArgument(boolean
true if the argument is valid
test
,
String
the message
message
,
Object...
the arguments
arguments
)

Throw an IllegalArgumentException if the argument is invalid.

public static long

Returns:

the position
composePagePos
(int
the chunk id
chunkId
,
int
the offset
offset
,
int
the length
length
,
int
the page type (1 for node, 0 for leaf)
type
)

Get the position of this page.

public static long

Returns:

the page position
composePagePos
(int
the chunk id
chunkId
,
long
the element
tocElement
)

Convert tocElement into pagePos by replacing mapId with chunkId.

public static long

Returns:

the position
composeTocElement
(int
the chunk id
mapId
,
int
the offset
offset
,
int
the length
length
,
int
the page type (1 for node, 0 for leaf)
type
)

Create table of content element.

public static IOException

Returns:

the IO exception
convertToIOException
(Throwable
the root cause
e
)

Convert an exception to an IO exception.

public static void
copyExcept(Object
the source array
src
,
Object
the target array
dst
,
int
the size of the old array
oldSize
,
int
the index of the entry to remove
removeIndex
)

Copy the elements of an array, and remove one element.

public static void
copyWithGap(Object
the source array
src
,
Object
the target array
dst
,
int
the size of the old array
oldSize
,
int
the index of the gap
gapIndex
)

Copy the elements of an array, with a gap.

public static int

Returns:

the maximum length
decodePageLength
(int
encoded page length
code
)

Get the maximum length for the given code.

public static int

Returns:

the length code
encodeLength
(int
the length
len
)

Convert the length to a length code 0..31.

public static String

Returns:

the formatted message
formatMessage
(int
the error code
errorCode
,
String
the message
message
,
Object...
the arguments
arguments
)

Format an error message.

public static short

Returns:

the check value
getCheckValue
(int
the value
x
)

Calculate a check value for the given integer.

pack-priv static int

Returns:

the configured value or default
getConfigParam
(Map<String, ?>
the configuration
config
,
String
the key
key
,
int
the default
defaultValue
)

Get the configuration parameter value, or default.

public static int

Returns:

the checksum
getFletcher32
(byte[]
the bytes
bytes
,
int
initial offset
offset
,
int
the message length (if odd, 0 is appended)
length
)

Calculate the Fletcher32 checksum.

public static String

Returns:

value of the specified item, or null
getFromMap
(String
the list
s
,
String
the name of the key
key
)

Parse a specified pair from key-value pair list.

public static String

Returns:

value of name item, or null
getMapName
(String
the list
s
)

Parse a name from key-value pair list.

public static int

Returns:

the chunk id
getPageChunkId
(long
the position
pos
)

Get the chunk id from the position.

public static int

Returns:

the map id
getPageMapId
(long
packed table of content element
tocElement
)

Get the map id from the chunk's table of content element.

public static int

Returns:

the maximum length
getPageMaxLength
(long
the position
pos
)

Get the maximum length for the given page position.

public static int

Returns:

the offset
getPageOffset
(long
packed table of content element
tocElement
)

Get the offset from the position.

public static int

Returns:

the page type (PAGE_TYPE_NODE or PAGE_TYPE_LEAF)
getPageType
(long
the position
pos
)

Get the page type from the position.

public static int

Returns:

the length in bytes
getVarIntLen
(int
the value
x
)

Get the length of the variable size int.

public static int

Returns:

the length in bytes
getVarLongLen
(long
the value
x
)

Get the length of the variable size long.

private static <T extends Exception> T
initCause(T e, Object... arguments)

public static boolean

Returns:

true if it is a leaf, false otherwise
isLeafPosition
(long
the position
pos
)

Determines whether specified file position corresponds to a leaf page

pack-priv static boolean

Returns:

true if page has been removed (no longer accessible from the current root of the tree)
isPageRemoved
(long
the position
pos
)

Find out if page was removed.

public static boolean

Returns:

true if page has been saved
isPageSaved
(long
the position
pos
)

Find out if page was saved.

public static IllegalArgumentException

Returns:

the exception
newIllegalArgumentException
(String
the message
message
,
Object...
the arguments
arguments
)

Create a new IllegalArgumentException.

public static MVStoreException

Returns:

the exception
newMVStoreException
(int
the error code
errorCode
,
String
the message
message
,
Object...
the arguments
arguments
)

Create a new MVStoreException.

public static UnsupportedOperationException

Returns:

the exception
newUnsupportedOperationException
(String
the message
message
)

Create a new UnsupportedOperationException.

pack-priv static HashMap<String, String>

Returns:

the map without mapping for "fletcher", or null if checksum is wrong or parameter do not represent a properly formatted map serialization
parseChecksummedMap
(byte[]
encoded map
bytes
)

Parse a key-value pair list and checks its checksum.

pack-priv static byte[]

Returns:

the byte array, or null if not in the map
parseHexBytes
(Map<String, ?>
the map
map
,
String
the key
key
)

Parse the hex-encoded bytes of an entry in the map.

public static int

Returns:

the parsed value
parseHexInt
(String
the string
x
)

Parse an unsigned, hex long.

public static long

Returns:

the parsed value
parseHexLong
(String
the string
x
)

Parse an unsigned, hex long.

public static HashMap<String, String>

Returns:

the map
parseMap
(String
the list
s
)

Parse a key-value pair list.

private static int

Returns:

new offset
parseMapValue
(StringBuilder
output buffer, should be empty
buff
,
String
parsed string
s
,
int
offset to parse from
i
,
int
stop offset (exclusive)
size
)

public static void
readFully(FileChannel
the file channel
file
,
long
the absolute position within the file
pos
,
ByteBuffer
the byte buffer
dst
)

Read from a file channel until the buffer is full.

pack-priv static int

Returns:

the parsed value
readHexInt
(Map<String, ?>
the map
map
,
String
the key
key
,
int
if the value is null
defaultValue
)

Read a hex int value from a map.

public static long

Returns:

the parsed value
readHexLong
(Map<String, ?>
the map
map
,
String
the key
key
,
long
if the value is null
defaultValue
)

Read a hex long value from a map.

public static String

Returns:

the value
readString
(ByteBuffer
the source buffer
buff
)

Read a string.

public static String

Returns:

the value
readString
(ByteBuffer
the source buffer
buff
,
int
the number of characters
len
)

Read a string.

public static int

Returns:

the value
readVarInt
(ByteBuffer
the source buffer
buff
)

Read a variable size int.

private static int
public static long

Returns:

the value
readVarLong
(ByteBuffer
the source buffer
buff
)

Read a variable size long.

public static void
writeFully(FileChannel
the file channel
file
,
long
the absolute position within the file
pos
,
ByteBuffer
the source buffer
src
)

Write to a file channel.

public static void
writeStringData(ByteBuffer
the target buffer (must be large enough)
buff
,
String
the string
s
,
int
the number of characters
len
)

Write characters from a string (without the length).

public static void
writeVarInt(OutputStream
the output stream
out
,
int
the value
x
)

Write a variable size int.

public static void
writeVarInt(ByteBuffer
the source buffer
buff
,
int
the value
x
)

Write a variable size int.

public static void
writeVarLong(ByteBuffer
the target buffer
buff
,
long
the value
x
)

Write a variable size long.

public static void
writeVarLong(OutputStream
the output stream
out
,
long
the value
x
)

Write a variable size long.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

COMPRESSED_VAR_INT_MAXback to summary
public static final int COMPRESSED_VAR_INT_MAX

The maximum integer that needs less space when using variable size encoding (only 3 bytes instead of 4).

COMPRESSED_VAR_LONG_MAXback to summary
public static final long COMPRESSED_VAR_LONG_MAX

The maximum long that needs less space when using variable size encoding (only 7 bytes instead of 8).

ERROR_BLOCK_NOT_FOUNDback to summary
public static final int ERROR_BLOCK_NOT_FOUND

The block in the stream store was not found.

ERROR_CHUNK_NOT_FOUNDback to summary
public static final int ERROR_CHUNK_NOT_FOUND

The application was trying to read data from a chunk that is no longer available.

ERROR_CLOSEDback to summary
public static final int ERROR_CLOSED

The object is already closed.

ERROR_FILE_CORRUPTback to summary
public static final int ERROR_FILE_CORRUPT

The file is corrupt or (for encrypted files) the encryption key is wrong.

ERROR_FILE_LOCKEDback to summary
public static final int ERROR_FILE_LOCKED

The file is locked.

ERROR_INTERNALback to summary
public static final int ERROR_INTERNAL

An internal error occurred. This could be a bug, or a memory corruption (for example caused by out of memory).

ERROR_READING_FAILEDback to summary
public static final int ERROR_READING_FAILED

An error occurred while reading from the file.

ERROR_SERIALIZATIONback to summary
public static final int ERROR_SERIALIZATION

An error occurred when serializing or de-serializing.

ERROR_TOO_MANY_OPEN_TRANSACTIONSback to summary
public static final int ERROR_TOO_MANY_OPEN_TRANSACTIONS

There are too many open transactions.

ERROR_TRANSACTION_CORRUPTback to summary
public static final int ERROR_TRANSACTION_CORRUPT

The transaction store is corrupt.

ERROR_TRANSACTION_ILLEGAL_STATEback to summary
public static final int ERROR_TRANSACTION_ILLEGAL_STATE

The transaction store is in an illegal state (for example, not yet initialized).

ERROR_TRANSACTION_LOCKEDback to summary
public static final int ERROR_TRANSACTION_LOCKED

An entry is still locked by another transaction.

ERROR_TRANSACTION_TOO_BIGback to summary
public static final int ERROR_TRANSACTION_TOO_BIG

The transaction contains too many changes.

ERROR_TRANSACTIONS_DEADLOCKback to summary
public static final int ERROR_TRANSACTIONS_DEADLOCK

Deadlock discovered and one of transactions involved chosen as victim and rolled back.

ERROR_UNKNOWN_DATA_TYPEback to summary
public static final int ERROR_UNKNOWN_DATA_TYPE

The transaction store can not be initialized because data type is not found in type registry.

ERROR_UNSUPPORTED_FORMATback to summary
public static final int ERROR_UNSUPPORTED_FORMAT

The file format is not supported.

ERROR_WRITING_FAILEDback to summary
public static final int ERROR_WRITING_FAILED

An error occurred when trying to write to the file.

META_CHUNKback to summary
public static final String META_CHUNK

The prefix for chunks ("chunk."). This, plus the chunk id (hex encoded) is the key, and the serialized chunk metadata is the value.

META_MAPback to summary
public static final String META_MAP

The prefix for maps ("map."). This, plus the map id (hex encoded) is the key, and the serialized in the map metadata is the value.

META_NAMEback to summary
public static final String META_NAME

The prefix for names ("name."). This, plus the name of the map, is the key, and the map id (hex encoded) is the value.

META_ROOTback to summary
public static final String META_ROOT

The prefix for root positions of maps ("root."). This, plus the map id (hex encoded) is the key, and the position (hex encoded) is the value.

PAGE_COMPRESSEDback to summary
public static final int PAGE_COMPRESSED

The bit mask for compressed pages (compression level fast).

PAGE_COMPRESSED_HIGHback to summary
public static final int PAGE_COMPRESSED_HIGH

The bit mask for compressed pages (compression level high).

PAGE_LARGEback to summary
public static final int PAGE_LARGE

The marker size of a very large page.

PAGE_TYPE_LEAFback to summary
public static final int PAGE_TYPE_LEAF

The type for leaf page.

PAGE_TYPE_NODEback to summary
public static final int PAGE_TYPE_NODE

The type for node page.

Constructor Detail

DataUtilsback to summary
public DataUtils()

Method Detail

appendMapback to summary
public static StringBuilder appendMap(StringBuilder buff, HashMap<String, ?> map)

Append a map to the string builder, sorted by key.

Parameters
buff:StringBuilder

the target buffer

map:HashMap<String, ?>

the map

Returns:StringBuilder

the string builder

appendMapback to summary
public static void appendMap(StringBuilder buff, String key, String value)

Append a key-value pair to the string builder. Keys may not contain a colon. Values that contain a comma or a double quote are enclosed in double quotes, with special characters escaped using a backslash.

Parameters
buff:StringBuilder

the target buffer

key:String

the key

value:String

the value

appendMapback to summary
public static void appendMap(StringBuilder buff, String key, long value)

Append a key-value pair to the string builder. Keys may not contain a colon.

Parameters
buff:StringBuilder

the target buffer

key:String

the key

value:long

the value

appendMapback to summary
public static void appendMap(StringBuilder buff, String key, int value)

Append a key-value pair to the string builder. Keys may not contain a colon.

Parameters
buff:StringBuilder

the target buffer

key:String

the key

value:int

the value

appendMapKeyback to summary
private static StringBuilder appendMapKey(StringBuilder buff, String key)
checkArgumentback to summary
public static void checkArgument(boolean test, String message, Object... arguments)

Throw an IllegalArgumentException if the argument is invalid.

Parameters
test:boolean

true if the argument is valid

message:String

the message

arguments:Object[]

the arguments

Exceptions
IllegalArgumentException:
if the argument is invalid
composePagePosback to summary
public static long composePagePos(int chunkId, int offset, int length, int type)

Get the position of this page. The following information is encoded in the position: the chunk id, the page sequential number, the maximum length, and the type (node or leaf).

Parameters
chunkId:int

the chunk id

offset:int

the offset

length:int

the length

type:int

the page type (1 for node, 0 for leaf)

Returns:long

the position

composePagePosback to summary
public static long composePagePos(int chunkId, long tocElement)

Convert tocElement into pagePos by replacing mapId with chunkId.

Parameters
chunkId:int

the chunk id

tocElement:long

the element

Returns:long

the page position

composeTocElementback to summary
public static long composeTocElement(int mapId, int offset, int length, int type)

Create table of content element. The following information is encoded in it: the map id, the page offset, the maximum length, and the type (node or leaf).

Parameters
mapId:int

the chunk id

offset:int

the offset

length:int

the length

type:int

the page type (1 for node, 0 for leaf)

Returns:long

the position

convertToIOExceptionback to summary
public static IOException convertToIOException(Throwable e)

Convert an exception to an IO exception.

Parameters
e:Throwable

the root cause

Returns:IOException

the IO exception

copyExceptback to summary
public static void copyExcept(Object src, Object dst, int oldSize, int removeIndex)

Copy the elements of an array, and remove one element.

Parameters
src:Object

the source array

dst:Object

the target array

oldSize:int

the size of the old array

removeIndex:int

the index of the entry to remove

copyWithGapback to summary
public static void copyWithGap(Object src, Object dst, int oldSize, int gapIndex)

Copy the elements of an array, with a gap.

Parameters
src:Object

the source array

dst:Object

the target array

oldSize:int

the size of the old array

gapIndex:int

the index of the gap

decodePageLengthback to summary
public static int decodePageLength(int code)

Get the maximum length for the given code. For the code 31, PAGE_LARGE is returned.

Parameters
code:int

encoded page length

Returns:int

the maximum length

encodeLengthback to summary
public static int encodeLength(int len)

Convert the length to a length code 0..31. 31 means more than 1 MB.

Parameters
len:int

the length

Returns:int

the length code

formatMessageback to summary
public static String formatMessage(int errorCode, String message, Object... arguments)

Format an error message.

Parameters
errorCode:int

the error code

message:String

the message

arguments:Object[]

the arguments

Returns:String

the formatted message

getCheckValueback to summary
public static short getCheckValue(int x)

Calculate a check value for the given integer. A check value is mean to verify the data is consistent with a high probability, but not meant to protect against media failure or deliberate changes.

Parameters
x:int

the value

Returns:short

the check value

getConfigParamback to summary
pack-priv static int getConfigParam(Map<String, ?> config, String key, int defaultValue)

Get the configuration parameter value, or default.

Parameters
config:Map<String, ?>

the configuration

key:String

the key

defaultValue:int

the default

Returns:int

the configured value or default

getFletcher32back to summary
public static int getFletcher32(byte[] bytes, int offset, int length)

Calculate the Fletcher32 checksum.

Parameters
bytes:byte[]

the bytes

offset:int

initial offset

length:int

the message length (if odd, 0 is appended)

Returns:int

the checksum

getFromMapback to summary
public static String getFromMap(String s, String key)

Parse a specified pair from key-value pair list.

Parameters
s:String

the list

key:String

the name of the key

Returns:String

value of the specified item, or null

Exceptions
MVStoreException:
if parsing failed
getMapNameback to summary
public static String getMapName(String s)

Parse a name from key-value pair list.

Parameters
s:String

the list

Returns:String

value of name item, or null

Exceptions
MVStoreException:
if parsing failed
getPageChunkIdback to summary
public static int getPageChunkId(long pos)

Get the chunk id from the position.

Parameters
pos:long

the position

Returns:int

the chunk id

getPageMapIdback to summary
public static int getPageMapId(long tocElement)

Get the map id from the chunk's table of content element.

Parameters
tocElement:long

packed table of content element

Returns:int

the map id

getPageMaxLengthback to summary
public static int getPageMaxLength(long pos)

Get the maximum length for the given page position.

Parameters
pos:long

the position

Returns:int

the maximum length

getPageOffsetback to summary
public static int getPageOffset(long tocElement)

Get the offset from the position.

Parameters
tocElement:long

packed table of content element

Returns:int

the offset

getPageTypeback to summary
public static int getPageType(long pos)

Get the page type from the position.

Parameters
pos:long

the position

Returns:int

the page type (PAGE_TYPE_NODE or PAGE_TYPE_LEAF)

getVarIntLenback to summary
public static int getVarIntLen(int x)

Get the length of the variable size int.

Parameters
x:int

the value

Returns:int

the length in bytes

getVarLongLenback to summary
public static int getVarLongLen(long x)

Get the length of the variable size long.

Parameters
x:long

the value

Returns:int

the length in bytes

initCauseback to summary
private static <T extends Exception> T initCause(T e, Object... arguments)
isLeafPositionback to summary
public static boolean isLeafPosition(long pos)

Determines whether specified file position corresponds to a leaf page

Parameters
pos:long

the position

Returns:boolean

true if it is a leaf, false otherwise

isPageRemovedback to summary
pack-priv static boolean isPageRemoved(long pos)

Find out if page was removed.

Parameters
pos:long

the position

Returns:boolean

true if page has been removed (no longer accessible from the current root of the tree)

isPageSavedback to summary
public static boolean isPageSaved(long pos)

Find out if page was saved.

Parameters
pos:long

the position

Returns:boolean

true if page has been saved

newIllegalArgumentExceptionback to summary
public static IllegalArgumentException newIllegalArgumentException(String message, Object... arguments)

Create a new IllegalArgumentException.

Parameters
message:String

the message

arguments:Object[]

the arguments

Returns:IllegalArgumentException

the exception

newMVStoreExceptionback to summary
public static MVStoreException newMVStoreException(int errorCode, String message, Object... arguments)

Create a new MVStoreException.

Parameters
errorCode:int

the error code

message:String

the message

arguments:Object[]

the arguments

Returns:MVStoreException

the exception

newUnsupportedOperationExceptionback to summary
public static UnsupportedOperationException newUnsupportedOperationException(String message)

Create a new UnsupportedOperationException.

Parameters
message:String

the message

Returns:UnsupportedOperationException

the exception

parseChecksummedMapback to summary
pack-priv static HashMap<String, String> parseChecksummedMap(byte[] bytes)

Parse a key-value pair list and checks its checksum.

Parameters
bytes:byte[]

encoded map

Returns:HashMap<String, String>

the map without mapping for "fletcher", or null if checksum is wrong or parameter do not represent a properly formatted map serialization

parseHexBytesback to summary
pack-priv static byte[] parseHexBytes(Map<String, ?> map, String key)

Parse the hex-encoded bytes of an entry in the map.

Parameters
map:Map<String, ?>

the map

key:String

the key

Returns:byte[]

the byte array, or null if not in the map

parseHexIntback to summary
public static int parseHexInt(String x)

Parse an unsigned, hex long.

Parameters
x:String

the string

Returns:int

the parsed value

Exceptions
MVStoreException:
if parsing fails
parseHexLongback to summary
public static long parseHexLong(String x)

Parse an unsigned, hex long.

Parameters
x:String

the string

Returns:long

the parsed value

Exceptions
MVStoreException:
if parsing fails
parseMapback to summary
public static HashMap<String, String> parseMap(String s)

Parse a key-value pair list.

Parameters
s:String

the list

Returns:HashMap<String, String>

the map

Exceptions
MVStoreException:
if parsing failed
parseMapValueback to summary
private static int parseMapValue(StringBuilder buff, String s, int i, int size)
Parameters
buff:StringBuilder

output buffer, should be empty

s:String

parsed string

i:int

offset to parse from

size:int

stop offset (exclusive)

Returns:int

new offset

readFullyback to summary
public static void readFully(FileChannel file, long pos, ByteBuffer dst)

Read from a file channel until the buffer is full. The buffer is rewind after reading.

Parameters
file:FileChannel

the file channel

pos:long

the absolute position within the file

dst:ByteBuffer

the byte buffer

Exceptions
MVStoreException:
if some data could not be read
readHexIntback to summary
pack-priv static int readHexInt(Map<String, ?> map, String key, int defaultValue)

Read a hex int value from a map.

Parameters
map:Map<String, ?>

the map

key:String

the key

defaultValue:int

if the value is null

Returns:int

the parsed value

Exceptions
MVStoreException:
if parsing fails
readHexLongback to summary
public static long readHexLong(Map<String, ?> map, String key, long defaultValue)

Read a hex long value from a map.

Parameters
map:Map<String, ?>

the map

key:String

the key

defaultValue:long

if the value is null

Returns:long

the parsed value

Exceptions
MVStoreException:
if parsing fails
readStringback to summary
public static String readString(ByteBuffer buff)

Read a string.

Parameters
buff:ByteBuffer

the source buffer

Returns:String

the value

readStringback to summary
public static String readString(ByteBuffer buff, int len)

Read a string.

Parameters
buff:ByteBuffer

the source buffer

len:int

the number of characters

Returns:String

the value

readVarIntback to summary
public static int readVarInt(ByteBuffer buff)

Read a variable size int.

Parameters
buff:ByteBuffer

the source buffer

Returns:int

the value

readVarIntRestback to summary
private static int readVarIntRest(ByteBuffer buff, int b)
readVarLongback to summary
public static long readVarLong(ByteBuffer buff)

Read a variable size long.

Parameters
buff:ByteBuffer

the source buffer

Returns:long

the value

writeFullyback to summary
public static void writeFully(FileChannel file, long pos, ByteBuffer src)

Write to a file channel.

Parameters
file:FileChannel

the file channel

pos:long

the absolute position within the file

src:ByteBuffer

the source buffer

writeStringDataback to summary
public static void writeStringData(ByteBuffer buff, String s, int len)

Write characters from a string (without the length).

Parameters
buff:ByteBuffer

the target buffer (must be large enough)

s:String

the string

len:int

the number of characters

writeVarIntback to summary
public static void writeVarInt(OutputStream out, int x) throws IOException

Write a variable size int.

Parameters
out:OutputStream

the output stream

x:int

the value

Exceptions
IOException:
if some data could not be written
writeVarIntback to summary
public static void writeVarInt(ByteBuffer buff, int x)

Write a variable size int.

Parameters
buff:ByteBuffer

the source buffer

x:int

the value

writeVarLongback to summary
public static void writeVarLong(ByteBuffer buff, long x)

Write a variable size long.

Parameters
buff:ByteBuffer

the target buffer

x:long

the value

writeVarLongback to summary
public static void writeVarLong(OutputStream out, long x) throws IOException

Write a variable size long.

Parameters
out:OutputStream

the output stream

x:long

the value

Exceptions
IOException:
if some data could not be written