Hi,

On 6/11/06, G.S.S. Mahadevan <[EMAIL PROTECTED]> wrote:

Hi,

I was planning to use MINA ByteBuffer for replacement of
java.nio.ByteBuffer.

Is there any reason in MINA has not provided java.nio.ByteBuffer.array
and java.nio.ByteBuffer.arrayOffSet methods(apart from the following
reasons):
* Releasing of mina ByteBuffers may become complicated, if we expose
the Backing byte[[] store to outside as in Sun's
java.nio.ByteBuffer.array
* Exposing the Backing store is against the good coding
practices.(But  nio.ByteBuffer and MIN.ByteBuffer to violate that by
ByteBuffer.wrap methods)


That's why we stated explicitly that wrapping existing array or buffer can
be dangerous and should be used at your own risk.

------------------------------------------------------------------------------------------
Why I need this array/arrayoffset in backing store is:
* I have lots of small allocations of headers(around 64 bytes), I
want to do some calculations(like SHA1 digest,etc) at high rate. I
want to avoid high rate of GC  for ' new byte[]' creations OR
ByteBuffer/byte[] create-copy-operations.


It seems like we forgot to add those methods.  It will be fixed.  Meanwhile,
you can work around:

org.apache.mina.common.ByteBuffer buf = ...;
byte[] array = buf.buf().array();

Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP key fingerprints:
* E167 E6AF E73A CBCE EE41  4A29 544D DE48 FE95 4E7E
* B693 628E 6047 4F8F CFA4  455E 1C62 A7DC 0255 ECA6

Reply via email to