[
https://issues.apache.org/jira/browse/PHOENIX-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13904240#comment-13904240
]
James Taylor commented on PHOENIX-37:
-------------------------------------
Use org.apache.phoenix.util.TrustedByteArrayOutputStream as it let's you access
both the byte[] and the number of bytes written so you can set the
ImmutableBytesWritable without copying:
{code}
@Override
public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) {
int estimatedSize =
PArrayType.getEstimatedSize(this.getChildren().size(), this.getDataType());
TrustedByteArrayOutputStream out = new
TrustedByteArrayOutputStream(estimatedSize);
// write data
ptr.set(out.getBuffer(), 0, out.getSize());
{code}
> Prevent deserialize and re-serialize all array elements in construction of
> array
> --------------------------------------------------------------------------------
>
> Key: PHOENIX-37
> URL: https://issues.apache.org/jira/browse/PHOENIX-37
> Project: Phoenix
> Issue Type: Bug
> Affects Versions: 3.0.0
> Reporter: James Taylor
> Assignee: ramkrishna.s.vasudevan
> Fix For: 3.0.0
>
>
> ArrayConstructorExpression.evaluate() currently deserializes into object form
> all array elements only to serialize them back again as bytes. Instead, just
> use a TrustedByteArrayOuputStream (initially sized based on the number of
> child elements) to serialize the data into. If variable length, track the
> offset information as the data is written.
> Second, we should put the header information (offsets, length, and version)
> at the end of the array instead of the start. This will make it possible to
> compare arrays against each other in their byte form.
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)