Rafael Schloming wrote:
Rupert Smith wrote:
On 24/09/2007, Rafael Schloming <[EMAIL PROTECTED]> wrote:
So if we were to fix AMQShortString to just use bulk put/get operations
all the time then the only issue is whether it is possible to implement
an aggregating ByteBuffer with efficient bulk put/get operations, and
the answer to this question depends entirely on the details of the
internal implementation of the various nio Buffer classes, which likely
means it is impossible to do without tying yourself to a specific JDK
implementation.
Its an aggregator, so bulk operations just map down onto the bulk
operations
of the aggregated buffers underneath it. So if a bulk get overlaps two
buffers underneath, the get it split into two calls, one to fetch the
relevant bit from each of the underlying buffers.
Yes, this is exactly what FragmentDecoder does.
I don't follow where the
JDK specific part comes from?
The JDK specific part comes in trying to do this as a subclass of
ByteBuffer. The various buffer implementations in the java.nio package
share internal implementations via package protected members and code.
In order to be able to create a subclass of ByteBuffer you would need to
obey all the various package protected contracts. These contracts are
implementation details of the JDK and may change between releases.
A quick google on "extending ByteBuffer" also reveals the issues
mentioned here:
http://forum.java.sun.com/thread.jspa?threadID=693259&messageID=4028590
Basically ByteBuffer, although not final, has entirely private
constructors. This prevents it from being extend from outside the
java.nio package.
This link would also seem to indicate that there is no intention to ever
make ByteBuffer extensible:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4712383
--Rafael