[ 
https://issues.apache.org/jira/browse/APEXMALHAR-2126?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15356525#comment-15356525
 ] 

Vlad Rozov commented on APEXMALHAR-2126:
----------------------------------------

Why is it necessary to have Slice here? Slice allows referring to a portion of 
byte array without allocating individual byte arrays and creating many byte 
array objects. The example tries to solve a completely different problem - 
concatenate existing byte arrays into a single large byte array. There is no 
need for Slice here at all and Slice is misused in SpillableByteMapImpl. 
Instead of using Slice, it will be better to use Collection (for example 
ArrayList) of identifiers and serialized keys pairs and create byte array after 
all pairs are added to the collection.

> Suggest: Share Slice Buffer
> ---------------------------
>
>                 Key: APEXMALHAR-2126
>                 URL: https://issues.apache.org/jira/browse/APEXMALHAR-2126
>             Project: Apache Apex Malhar
>          Issue Type: Improvement
>            Reporter: bright chen
>
> I think the intention of Slice(com.datatorrent.netlet.util.Slice) was to 
> share the buffer and avoid unnecessary memory allocation/deallocation. But 
> the intension is not self-explain and lack of method to share the memory. And 
> the util class org.apache.apex.malhar.lib.utils.serde.SliceUtils also create 
> new memory and copy the data.
> I suggest to implement another class(Say BufferSlice), which 
> - initialize buffer with relative large buffer
> - support append(byte[] data, int offset, int length)
> - dynamic reallocated buffer or throw exception when buffer is full ( based 
> on the management strategy)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to