MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
com.mysql.clusterj.tie.Utility Class Reference
Collaboration diagram for com.mysql.clusterj.tie.Utility:

Classes

interface  CharsetConverter
interface  EndianManager
class  MultiByteCharsetConverter
class  SingleByteCharsetConverter

Static Public Member Functions

static CharsetMap getCharsetMap ()
static boolean isRetriable (ClusterJDatastoreException ex)
static ByteBuffer convertValue (Column storeColumn, byte[] value)
static ByteBuffer convertValue (Column storeColumn, BigDecimal value)
static ByteBuffer convertValue (Column storeColumn, BigInteger value)
static ByteBuffer convertValue (Column storeColumn, double value)
static ByteBuffer convertValue (Column storeColumn, float value)
static ByteBuffer convertValue (Column storeColumn, byte value)
static ByteBuffer convertValue (Column storeColumn, short value)
static ByteBuffer convertValue (Column storeColumn, int value)
static ByteBuffer convertValue (Column storeColumn, long value)
static void fixBufferPrefixLength (String columnName, ByteBuffer byteBuffer, int offset)
static String dumpBytes (byte[] bytes)
static String dumpBytes (ByteBuffer byteBuffer)
static BigDecimal getDecimal (ByteBuffer byteBuffer, int length, int precision, int scale)
static BigInteger getBigInteger (ByteBuffer byteBuffer, int length, int precision, int scale)
static String getDecimalString (ByteBuffer byteBuffer, int length, int precision, int scale)
static long unpackDate (int packedDate)
static long unpackTime (int packedTime)
static String decode (byte[] array, int collation)
static byte[] encode (String string, int collation)
static ByteBuffer encodeToByteBuffer (CharSequence string, int collation, int prefixLength)
static ByteBuffer encode (String input, Column storeColumn, BufferManager bufferManager)
static String decode (ByteBuffer inputByteBuffer, int collation, BufferManager bufferManager)
static int getDecimalColumnSpace (int precision, int scale)
static boolean getBoolean (Column storeColumn, NdbRecAttr ndbRecAttr)
static byte getByte (Column storeColumn, NdbRecAttr ndbRecAttr)
static short getShort (Column storeColumn, NdbRecAttr ndbRecAttr)
static int getInt (Column storeColumn, NdbRecAttr ndbRecAttr)
static long getLong (Column storeColumn, NdbRecAttr ndbRecAttr)
static long convertLongValueForStorage (Column storeColumn, long value)
static int convertByteValueForStorage (Column storeColumn, byte value)
static int convertShortValueForStorage (Column storeColumn, short value)

Static Protected Member Functions

static short swap (short value)
static int swap (int value)
static long swap (long value)
static void throwError (Object returnCode, NdbErrorConst ndbError)
static void throwError (Object returnCode, NdbErrorConst ndbError, String extra)
static ByteBuffer convertValue (Column storeColumn, String value)
static ByteBuffer convertValueForLikeFilter (Column storeColumn, String value)
static ByteBuffer convertValueForLikeFilter (Column storeColumn, byte[] value)
static long packDatetime (long value)
static long unpackDatetime (long packedDatetime)
static String decode (ByteBuffer inputByteBuffer, int collation)

Static Protected Attributes

static final int collationUTF16 = charsetMap.getUTF16CharsetNumber()

Detailed Description

This class provides utility methods.

Definition at line 57 of file Utility.java.

Member Function Documentation

static int com.mysql.clusterj.tie.Utility.convertByteValueForStorage ( Column  storeColumn,
byte  value 
)
inlinestatic

Convert a byte value into an int for storage. The value parameter may be a bit, a bit array (BIT(1..8) needs to be stored as an int) or a byte value. The storage format depends on the type of the column and the endian-ness of the host.

Parameters
storeColumnthe column
valuethe java value
Returns
the storage value

Definition at line 1881 of file Utility.java.

static long com.mysql.clusterj.tie.Utility.convertLongValueForStorage ( Column  storeColumn,
long  value 
)
inlinestatic

Convert a long value into a long for storage. The value parameter may be a date (milliseconds since the epoch), a bit array, or simply a long value. The storage format depends on the type of the column and the endian-ness of the host.

Parameters
storeColumnthe column
valuethe java value
Returns
the storage value

Definition at line 1869 of file Utility.java.

static int com.mysql.clusterj.tie.Utility.convertShortValueForStorage ( Column  storeColumn,
short  value 
)
inlinestatic

Convert a short value into an int for storage. The value parameter may be a bit array (BIT(1..16) needs to be stored as an int) or a short value. The storage format depends on the type of the column and the endian-ness of the host.

Parameters
storeColumnthe column
valuethe java value
Returns
the storage value

Definition at line 1893 of file Utility.java.

static ByteBuffer com.mysql.clusterj.tie.Utility.convertValue ( Column  storeColumn,
byte[]  value 
)
inlinestatic

Convert the parameter value to a ByteBuffer that can be passed to ndbjtie.

Parameters
storeColumnthe column definition
valuethe value to be converted
Returns
the ByteBuffer

Definition at line 794 of file Utility.java.

Here is the call graph for this function:

static ByteBuffer com.mysql.clusterj.tie.Utility.convertValue ( Column  storeColumn,
BigDecimal  value 
)
inlinestatic

Convert a BigDecimal value to the binary decimal form used by MySQL. Use the precision and scale of the column to convert. Values that don't fit into the column throw a ClusterJUserException.

Parameters
storeColumnthe column metadata
valuethe value to be converted
Returns
the ByteBuffer

Definition at line 854 of file Utility.java.

Here is the call graph for this function:

static ByteBuffer com.mysql.clusterj.tie.Utility.convertValue ( Column  storeColumn,
BigInteger  value 
)
inlinestatic

Convert a BigInteger value to the binary decimal form used by MySQL. Use the precision and scale of the column to convert. Values that don't fit into the column throw a ClusterJUserException.

Parameters
storeColumnthe column metadata
valuethe value to be converted
Returns
the ByteBuffer

Definition at line 887 of file Utility.java.

Here is the call graph for this function:

static ByteBuffer com.mysql.clusterj.tie.Utility.convertValue ( Column  storeColumn,
double  value 
)
inlinestatic

Convert the parameter value to a ByteBuffer that can be passed to ndbjtie.

Parameters
storeColumnthe column definition
valuethe value to be converted
Returns
the ByteBuffer

Definition at line 916 of file Utility.java.

static ByteBuffer com.mysql.clusterj.tie.Utility.convertValue ( Column  storeColumn,
float  value 
)
inlinestatic

Convert the parameter value to a ByteBuffer that can be passed to ndbjtie.

Parameters
storeColumnthe column definition
valuethe value to be converted
Returns
the ByteBuffer

Definition at line 930 of file Utility.java.

static ByteBuffer com.mysql.clusterj.tie.Utility.convertValue ( Column  storeColumn,
byte  value 
)
inlinestatic

Convert the parameter value to a ByteBuffer that can be passed to ndbjtie.

Parameters
storeColumnthe column definition
valuethe value to be converted
Returns
the ByteBuffer

Definition at line 944 of file Utility.java.

static ByteBuffer com.mysql.clusterj.tie.Utility.convertValue ( Column  storeColumn,
short  value 
)
inlinestatic

Convert the parameter value to a ByteBuffer that can be passed to ndbjtie.

Parameters
storeColumnthe column definition
valuethe value to be converted
Returns
the ByteBuffer

Definition at line 954 of file Utility.java.

static ByteBuffer com.mysql.clusterj.tie.Utility.convertValue ( Column  storeColumn,
int  value 
)
inlinestatic

Convert the parameter value to a ByteBuffer that can be passed to ndbjtie.

Parameters
storeColumnthe column definition
valuethe value to be converted
Returns
the ByteBuffer

Definition at line 964 of file Utility.java.

static ByteBuffer com.mysql.clusterj.tie.Utility.convertValue ( Column  storeColumn,
long  value 
)
inlinestatic

Convert the parameter value to a ByteBuffer that can be passed to ndbjtie.

Parameters
storeColumnthe column definition
valuethe value to be converted
Returns
the ByteBuffer

Definition at line 974 of file Utility.java.

static ByteBuffer com.mysql.clusterj.tie.Utility.convertValue ( Column  storeColumn,
String  value 
)
inlinestaticprotected

Encode a String as a ByteBuffer that can be passed to ndbjtie. Put the length information in the beginning of the buffer. Pad fixed length strings with blanks.

Parameters
storeColumnthe column definition
valuethe value to be converted
Returns
the ByteBuffer

Definition at line 985 of file Utility.java.

Here is the call graph for this function:

static ByteBuffer com.mysql.clusterj.tie.Utility.convertValueForLikeFilter ( Column  storeColumn,
String  value 
)
inlinestaticprotected

Encode a String as a ByteBuffer that can be passed to ndbjtie in a COND_LIKE filter. There is no length information in the beginning of the buffer.

Parameters
storeColumnthe column definition
valuethe value to be converted
Returns
the ByteBuffer

Definition at line 1006 of file Utility.java.

Here is the call graph for this function:

static ByteBuffer com.mysql.clusterj.tie.Utility.convertValueForLikeFilter ( Column  storeColumn,
byte[]  value 
)
inlinestaticprotected

Encode a byte[] as a ByteBuffer that can be passed to ndbjtie in a COND_LIKE filter. There is no length information in the beginning of the buffer.

Parameters
storeColumnthe column definition
valuethe value to be converted
Returns
the ByteBuffer

Definition at line 1022 of file Utility.java.

static String com.mysql.clusterj.tie.Utility.decode ( byte[]  array,
int  collation 
)
inlinestatic

Decode a byte[] into a String using the charset. The return value is in UTF16 format.

Parameters
arraythe byte[] to be decoded
collationthe collation
Returns
the decoded String

Definition at line 1343 of file Utility.java.

Here is the call graph for this function:

static String com.mysql.clusterj.tie.Utility.decode ( ByteBuffer  inputByteBuffer,
int  collation 
)
inlinestaticprotected

Decode a ByteBuffer into a String using the charset. The return value is in UTF16 format.

Parameters
inputByteBufferthe byte buffer to be decoded
collationthe collation
Returns
the decoded String

Definition at line 1382 of file Utility.java.

Here is the call graph for this function:

static String com.mysql.clusterj.tie.Utility.decode ( ByteBuffer  inputByteBuffer,
int  collation,
BufferManager  bufferManager 
)
inlinestatic

Decode a ByteBuffer into a String using the charset. The return value is in UTF16 format.

Parameters
inputByteBufferthe byte buffer to be decoded positioned past the length prefix
collationthe collation
bufferManagerthe buffer manager with shared buffers
Returns
the decoded String

Definition at line 1491 of file Utility.java.

static String com.mysql.clusterj.tie.Utility.dumpBytes ( byte[]  bytes)
inlinestatic

Convert the byte[] into a String to be used for logging and debugging.

Parameters
bytesthe byte[] to be dumped
Returns
the String representation

Definition at line 1160 of file Utility.java.

Here is the caller graph for this function:

static String com.mysql.clusterj.tie.Utility.dumpBytes ( ByteBuffer  byteBuffer)
inlinestatic

Convert the byteBuffer into a String to be used for logging and debugging.

Parameters
byteBufferthe byteBuffer to be dumped
Returns
the String representation

Definition at line 1177 of file Utility.java.

Here is the call graph for this function:

static byte [] com.mysql.clusterj.tie.Utility.encode ( String  string,
int  collation 
)
inlinestatic

Encode a String into a byte[] for storage. This is used by character large objects when mapping text columns.

Parameters
stringthe String to encode
collationthe collation
Returns
the encoded byte[]

Definition at line 1417 of file Utility.java.

Here is the call graph for this function:

static ByteBuffer com.mysql.clusterj.tie.Utility.encode ( String  input,
Column  storeColumn,
BufferManager  bufferManager 
)
inlinestatic

Encode a String into a ByteBuffer for storage.

Parameters
inputthe input String
storeColumnthe store column
bufferManagerthe buffer manager with shared buffers
Returns
a byte buffer with prefix length

Definition at line 1472 of file Utility.java.

Here is the call graph for this function:

static ByteBuffer com.mysql.clusterj.tie.Utility.encodeToByteBuffer ( CharSequence  string,
int  collation,
int  prefixLength 
)
inlinestatic

Encode a String into a ByteBuffer using the mysql native encoding method.

Parameters
stringthe String to encode
collationthe collation
prefixLengththe length of the length prefix
Returns
the encoded ByteBuffer with position set to prefixLength and limit one past the last converted byte

Definition at line 1433 of file Utility.java.

Here is the call graph for this function:

Here is the caller graph for this function:

static void com.mysql.clusterj.tie.Utility.fixBufferPrefixLength ( String  columnName,
ByteBuffer  byteBuffer,
int  offset 
)
inlinestatic

Fix the length information in a buffer based on the length prefix, either 0, 1, or 2 bytes that hold the length information.

Parameters
byteBufferthe byte buffer to fix
offsetthe size of the length prefix

Definition at line 1060 of file Utility.java.

Here is the call graph for this function:

Here is the caller graph for this function:

static boolean com.mysql.clusterj.tie.Utility.getBoolean ( Column  storeColumn,
NdbRecAttr  ndbRecAttr 
)
inlinestatic

Get a boolean from this ndbRecAttr.

Parameters
storeColumnthe Column
ndbRecAttrthe NdbRecAttr
Returns
the boolean

Definition at line 1817 of file Utility.java.

static byte com.mysql.clusterj.tie.Utility.getByte ( Column  storeColumn,
NdbRecAttr  ndbRecAttr 
)
inlinestatic

Get a byte from this ndbRecAttr.

Parameters
storeColumnthe Column
ndbRecAttrthe NdbRecAttr
Returns
the byte

Definition at line 1827 of file Utility.java.

static CharsetMap com.mysql.clusterj.tie.Utility.getCharsetMap ( )
inlinestatic

The mysql charset map

Definition at line 152 of file Utility.java.

static int com.mysql.clusterj.tie.Utility.getDecimalColumnSpace ( int  precision,
int  scale 
)
inlinestatic

Get the number of bytes needed in memory to represent the decimal number.

Parameters
precisionthe precision of the number
scalethe scale
Returns
the number of bytes needed for the binary representation of the number

Definition at line 1804 of file Utility.java.

Here is the caller graph for this function:

static String com.mysql.clusterj.tie.Utility.getDecimalString ( ByteBuffer  byteBuffer,
int  length,
int  precision,
int  scale 
)
inlinestatic

Get a Decimal String from the byte buffer.

Parameters
byteBufferthe byte buffer with the raw data, starting at position()
lengththe length of the data
precisionthe precision of the data
scalethe scale of the data
Returns
the Decimal String representation of the value

Definition at line 1232 of file Utility.java.

Here is the call graph for this function:

static int com.mysql.clusterj.tie.Utility.getInt ( Column  storeColumn,
NdbRecAttr  ndbRecAttr 
)
inlinestatic

Get an int from this ndbRecAttr.

Parameters
storeColumnthe Column
ndbRecAttrthe NdbRecAttr
Returns
the int

Definition at line 1847 of file Utility.java.

static long com.mysql.clusterj.tie.Utility.getLong ( Column  storeColumn,
NdbRecAttr  ndbRecAttr 
)
inlinestatic

Get a long from this ndbRecAttr.

Parameters
storeColumnthe Column
ndbRecAttrthe NdbRecAttr
Returns
the long

Definition at line 1857 of file Utility.java.

static short com.mysql.clusterj.tie.Utility.getShort ( Column  storeColumn,
NdbRecAttr  ndbRecAttr 
)
inlinestatic

Get a short from this ndbRecAttr.

Parameters
storeColumnthe Column
ndbRecAttrthe NdbRecAttr
Returns
the short

Definition at line 1837 of file Utility.java.

static boolean com.mysql.clusterj.tie.Utility.isRetriable ( ClusterJDatastoreException  ex)
inlinestatic

Determine if the exception is retriable

Parameters
exthe exception
Returns
if the status is retriable

Definition at line 215 of file Utility.java.

static long com.mysql.clusterj.tie.Utility.packDatetime ( long  value)
inlinestaticprotected

Pack milliseconds since the Epoch into a long in database Datetime format. The Datetime contains a eight-byte date and time packed as YYYYx10000000000 + MMx100000000 + DDx1000000 + HHx10000 + MMx100 + SS Calendar month is 0 origin so add 1 to get packed month

Parameters
valuemilliseconds since the Epoch
Returns
the long in packed Datetime format

Definition at line 1140 of file Utility.java.

static short com.mysql.clusterj.tie.Utility.swap ( short  value)
inlinestaticprotected

Swap the bytes in the value, thereby converting a big-endian value into a little-endian value (or vice versa).

Parameters
valuethe value to be swapped
Returns
the swapped value

Definition at line 737 of file Utility.java.

static int com.mysql.clusterj.tie.Utility.swap ( int  value)
inlinestaticprotected

Swap the bytes in the value, thereby converting a big-endian value into a little-endian value (or vice versa).

Parameters
valuethe value to be swapped
Returns
the swapped value

Definition at line 747 of file Utility.java.

static long com.mysql.clusterj.tie.Utility.swap ( long  value)
inlinestaticprotected

Swap the bytes in the value, thereby converting a big-endian value into a little-endian value (or vice versa).

Parameters
valuethe value to be swapped
Returns
the swapped value

Definition at line 759 of file Utility.java.

static long com.mysql.clusterj.tie.Utility.unpackDate ( int  packedDate)
inlinestatic

Unpack a Date from its packed int representation. Date is a three-byte integer packed as YYYYx16x32 + MMx32 + DD

Parameters
packedDatethe packed representation
Returns
the long value as milliseconds since the Epoch

Definition at line 1268 of file Utility.java.

static long com.mysql.clusterj.tie.Utility.unpackDatetime ( long  packedDatetime)
inlinestaticprotected

Unpack a Datetime from its packed long representation. The Datetime contains a long packed as YYYYx10000000000 + MMx100000000 + DDx1000000 + HHx10000 + MMx100 + SS Calendar month is 0 origin so subtract 1 from packed month

Parameters
packedDatetimethe packed representation
Returns
the value as milliseconds since the Epoch

Definition at line 1312 of file Utility.java.

static long com.mysql.clusterj.tie.Utility.unpackTime ( int  packedTime)
inlinestatic

Unpack a Time from its packed int representation. Time is a three-byte integer packed as DDx240000 + HHx10000 + MMx100 + SS

Parameters
packedTimethe packed representation
Returns
the long value as milliseconds since the Epoch

Definition at line 1284 of file Utility.java.

Here is the call graph for this function:

Member Data Documentation

final int com.mysql.clusterj.tie.Utility.collationUTF16 = charsetMap.getUTF16CharsetNumber()
staticprotected

The mysql collation number for UTF16

Definition at line 149 of file Utility.java.


The documentation for this class was generated from the following file: