WiredTiger's data packing uses format strings similar to those specified in the Python struct module: http://docs.python.org/library/struct
The first character of the format string can be used to indicate the byte order, size and alignment of the packed data, according to the following table:
Character | Byte order | Size | Alignment |
---|---|---|---|
. | big-endian | packed | none |
> | big-endian | standard | none |
< | little-endian | standard | none |
@ | native | native | native |
If the first character is not one of these, '.' (big-endian, packed) is assumed: it naturally sorts in lexicographic order, and the packed format uses variable-sized encoding of values to reduce the data size.
Not yet supported in WiredTiger.
Only the default big-endian, packed format is currently supported.
The remaining characters in the format string specify the type of each field to be packed into or unpacked from a byte array. See Column types for the list of supported types.
The code below is taken from the complete example program ex_pack.c. It demonstrates how to pack three integer values into a buffer and then unpack them again.