-
Notifications
You must be signed in to change notification settings - Fork 324
msgpack-core v07 API #82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* using a smaller types. For example, calling MessageUnpacker.unpackInt() for an integer value | ||
* that is larger than Integer.MAX_VALUE will cause this exception. | ||
*/ | ||
public class MessageIntegerOverflowException extends MessageTypeException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Consistent name with MessageStringCodingException
Should we add license information to headers?
|
this.writeBufferChunkSize = builder.getWriteBufferChunkSize(); | ||
this.readReferenceThreshold = builder.getReadReferenceThreshold(); | ||
} | ||
private AtomicInteger referenceCounter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable looks unused variable. Do you have any plan to support GC-like feature by using reference counter in this class? If the answer is positive, should we write it down as TODO comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm considering managing allocated MssageBuffer(s) via GC or releasing explicitly, but this feature is not yet implemented. right. It should be marked as TODO.
Can we add javax.annotation.Nullable annotation to user-facing APIs? It's useful for users to understand whether arguments and return values can be null or not. |
private final WritableByteChannel channel; | ||
|
||
MessageBufferOutputChannel(WritableByteChannel channel) { | ||
this.channel = channel; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as MessageBufferOutputStream's constructor(need null check?).
…at.valueOf().getValueType() to translate byte codes. #82 (diff)
ArrayList<MessageBuffer> bufferList = new ArrayList<MessageBuffer>(); | ||
while(bufferTotal < readSize) { | ||
MessageBuffer next = in.next(); | ||
if(next == null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't you set reachedEOF to true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really good point. I actually modified this in another PR: https://github.com/msgpack/msgpack-java/pull/86/files#diff-6a54557ce799041aa918fa8fa48bc78dR134
Other than those minor comments, it looks good. GJ! |
I extracted several remaining issues discussed here as tickets: I'm going to merge these changes into v07 branch. |
GJ, @xerial! |
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 classes:
MessageBuffer
sun.misc.Unsafe
API to read the data in memory as fast as possibleshort/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.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 valueswritePayload
for writing binary/raw string dataMessageBufferOutput
MessageUnpacker
unpackInt
,unpackBoolean
, ... for reading message-packed valuesreadPayload
for reading binary/raw string datagetMessageType
. The user need to select an appropriate unpackXXX method according to the given MessageType (enum).MesasgeBufferInput
MesasgePackException
MessageFormat
ValueType
MessagePack