[ 
https://issues.apache.org/jira/browse/PIG-2001?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Woody Anderson updated PIG-2001:
--------------------------------

    Attachment: 2001.patch

> DefaultTuple(List) constructor is inefficient, causes List.size() 
> System.arraycopy() calls (though they are 0 byte copies), DefaultTuple(int) 
> constructor is a bit misleading wrt time complexity
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: PIG-2001
>                 URL: https://issues.apache.org/jira/browse/PIG-2001
>             Project: Pig
>          Issue Type: Improvement
>          Components: impl
>    Affects Versions: 0.8.0, 0.9.0
>            Reporter: Woody Anderson
>            Assignee: Woody Anderson
>            Priority: Minor
>             Fix For: 0.10
>
>         Attachments: 2001.patch
>
>
> I was perusing the Tuple created by the default Tuple factory, when I wanted 
> it to copy my input list.
> here i noticed that the List constructor uses List.add(index, element), which 
> is different from set(index, element) in that it shifts the right side of the 
> list, with ArrayList this causes an no-op System.arraycopy call which is 
> completely unnecessary.
> Even though the array copy call isn't actually copying any bytes, it's still 
> unnecessary, and can be easily avoided.
> it's also N iterate/add function calls, that can be avoided by using:
> {code}
> new ArrayList<Object>(c);
> {code}
> which, is more efficient. For arbitrary collection inputs this is at worst N 
> iterator calls (same as existing code); when constructing from ArrayLists or 
> Arrays.asList, the construction is accomplished via a single System.arraycopy 
> call, which is an actual improvement.
> There do not seem to be DefaultTuple tests.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to