Re: JE --> BDB migration -
10-12-2005
, 09:41 PM
Hi Petra,
I hope this will answer your questions -- it's from
java/src/som/sleepycat/bind/TupleOutput.java, and explains the encoding
of Java types:
* Signed numbers are stored in the buffer in MSB (most significant
byte
* first) order with their sign bit (high-order bit) inverted to cause
negative
* numbers to be sorted first when comparing values as unsigned byte
arrays,
* as done in a database. Unsigned numbers, including characters, are
stored
* in MSB order with no change to their sign bit.
*
* Strings and character arrays are stored either as a fixed length
array of
* unicode characters, where the length must be known by the
application, or as
* a null-terminated UTF byte array.
*
* Null strings are UTF encoded as { 0xFF }, which is not allowed in a
* standard UTF encoding. This allows null strings, as distinct from
empty or
* zero length strings, to be represented in a tuple. Using the
default
* comparator, null strings will be ordered last.
*
* Zero (0x0000) character values are UTF encoded as non-zero values,
and
* therefore embedded zeros in the string are supported. The sequence
{ 0xC0,
* 0x80 } is used to encode a zero character. This UTF encoding is the
same
* one used by native Java UTF libraries. However, this encoding of
zero does
* impact the lexicographical ordering, and zeros will not be sorted
first (the
* natural order) or last. For all character values other than zero,
the
* default UTF byte ordering is the same as the Unicode lexicographical
* character ordering.
*
* Floats and doubles are stored in standard Java integer-bit
representation
* (IEEE 754). Non-negative numbers are correctly ordered by numeric
value.
* However, negative numbers are not correctly ordered; therefore, if
you use
* negative floating point numbers in a key, you'll need to implement
and
* configure a custom comparator to get correct numeric ordering.
Regards,
Michael. |