DESCRIPTION

JCBC-1098 : N1qlQueryExecutor is allocating twice the memory it needs

Motivation
----------
When the netty ByteBuf is not backed by a byte array.
N1qlQueryExecutor#executeQuery is allocating the byte array twice.
the first time in TranscoderUtils#byteBufToByteArray
the second with Arrays#copyOfRange

Modifications
-------------
this patch add a specialized version of
TranscoderUtils#byteBufToByteArray (copyByteBufToByteArray) that only
call Arrays#copyOfRange if the ByteBuf is backed by a byte array.

Result
------
greatly reduce the n1ql memory allocation

Change-Id: I96e22d864fbb527f3d0cf2448d741e9d6965d387


COMMENTS

author: Natasha Sullivan
date: 2017-08-07 15:39:30.624000000

Uploaded patch set 1.

-------------------------------------
author: Hugo Blankenship
date: 2017-08-07 15:39:39.004000000

Patch Set 1:

Build Started http://sdkbuilds.sc.couchbase.com/job/couchbase-java-client-test/157/

-------------------------------------
author: Hugo Blankenship
date: 2017-08-07 15:39:43.096000000

Patch Set 1: Code-Review-2

Build Failed 

http://sdkbuilds.sc.couchbase.com/job/couchbase-java-client-test/157/ : FAILURE

-------------------------------------
author: Natasha Sullivan
date: 2017-08-07 15:39:51.366000000

Removed Code-Review-2 by Hugo Blankenship xxx@xxx.xxx


-------------------------------------
author: Carmen Buckley
date: 2017-08-07 20:41:12.063000000

Patch Set 1: Code-Review+1

(2 comments)

Line:299, src/main/java/com/couchbase/client/java/transcoder/TranscoderUtils.java -> NIT: `offset` is only used in the first branch; it could be declared there to narrow its scope.

Line:302, src/main/java/com/couchbase/client/java/transcoder/TranscoderUtils.java -> NIT: Are we concerned about hard tabs?

-------------------------------------
author: Natasha Sullivan
date: 2017-08-08 05:25:56.297000000

MISMATCHED INLINE COMMENT
Line:299, src/main/java/com/couchbase/client/java/transcoder/TranscoderUtils.java -> good point, fixing.

-------------------------------------
author: Natasha Sullivan
date: 2017-08-08 05:25:56.297000000

MISMATCHED INLINE COMMENT
Line:302, src/main/java/com/couchbase/client/java/transcoder/TranscoderUtils.java -> yup we are, I'll fix the formatting

-------------------------------------
