Ok, but I'd still use a TrustedByteArrayOutputStream. Just create a
ImmutableBytesWritable pointer at the end and use
ByteUtil.copyKeyBytesIfNecessary() at the end - it won't make a copy unless
necessary.


On Sun, Feb 23, 2014 at 8:14 PM, ramkrish86 <notifications@github.com>wrote:

> In
> phoenix-core/src/main/java/org/apache/phoenix/schema/PArrayDataType.java:
>
> >  	}
> >
> > +	// Estimates the size of the given array and also calculates the number of nulls and its repetition factor
> > +    public int estimateByteSize(Object o, Pair<Integer, Integer> nullsVsNullRepeationCounter, PDataType baseType) {
>
> I did this and removed that code because I felt we will not get the exact
> size and we may need to do a byte copy for getting the exact length of the
> byte[]. If not the byte[] that is used in recreation of the array would not
> work correctly because we have moved the headers to the last. If not
> TrustedByteArrayOutputSTream would have been fine. So let me calculate the
> exact size considering nulls > 255.
>
> --
> Reply to this email directly or view it on GitHub<https://github.com/apache/incubator-phoenix/pull/8/files#r9980816>
> .
>