msgpack/msgpack-java — pull request #82 by xerial (2014-05-09 23:22:11+00:00)
Title: msgpack-core v07 API

I wrote a draft code of msgpack-core for v07, which is a low-level module for reading/writing data in the Message Pack format (https://github.com/msgpack/msgpack/blob/master/spec.md).

Please review the design of this msgpack-core API in terms of the performance, usability and class/method naming. After the review I will add some test code to complete the implementation.

The goal of msgpack-core is to provide a low-level packer and unpacker implementation that is faster than v06. So, several rich functions (e.g., Template generation, JSON support) will not be implemented in msgpack-core v07.

msgpack-core API includes the following clases:
### MessageBuffer
- For reading/writing primitive type values in a memory
- getXXX for reading values, putXXX for writing values
- This class uses `sun.misc.Unsafe` API to read the data in memory as fast as possible
- The specification of message pack requires writing `short/int/float/long/double` values in big-endian. The default implementation translates little-endian values into big-endian. MessageBufferBE that does not translate the endian will be used for big-endian machine.
- This API tries to remove `invokeinterface` call to achieve the highest performance. So MessageBuffer does not implement any interface, and also to avoid the cost of TypeProfile lookup in JVM, only one of MessageBuffer or MessageBufferBE classes is loaded at runtime (using reflection).

### MessagePacker
- `packInt`, `packBoolean`, ... for writing message-packed values
- `writePayload` for writing binary/raw string data

### MessageBufferOutput
- Used in MessagePacker to output message-packed data to a stream or buffer
- This is an adapter to OutputStream or WritableByteChannel

### MessageUnpacker
- `unpackInt`, `unpackBoolean`, ... for reading message-packed values
- `readPayload` for reading binary/raw string data
- To read message pack data, first call `getMessageType`. The user need to select an appropriate unpackXXX method according to the given MessageType (enum).

### MesasgeBufferInput
- Used in MessageUnpacker to retrieve a sequence of MessageBuffer that contains message packed data
- This is an adapter to InputStream or ReadableByteChannel

### MesasgePackException
- The base class of all message-pack exceptions.
- MessageTypeException for type mismatch errors
- MessageFormatException for invalid inputs

### MessageType
- Enum definition that covers all of the value types in the specification
- MessageTypeFamily (previously, it was named ValueType) is a group of MessageTypes. For example MessageTypeFamily.INTEGER is a group of MessageType.INT8, INT16, .. UINT8, etc.