Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Plain View
Pig >> mail # user >> Question regarding DefaultTuple(size) implementation

Copy link to this message
Question regarding DefaultTuple(size) implementation
I rambled across this while reviewing one of Jon's patches. Here is the
code from DefaultTuple

     * Construct a tuple with a known number of fields. Package level so
that callers cannot directly invoke it.
     * <br>Resulting tuple is filled pre-filled with null elements. Time
complexity: O(N), after allocation
     * @param size
     *            Number of fields to allocate in the tuple.
    DefaultTuple(int size) {
        mFields = new ArrayList<Object>(size);
        for (int i = 0; i < size; i++)
Why are we walking through the list to add nulls? Wouldn't the initial
creation of ArrayList suffice?
mFields = new ArrayList<Object>(size) should be enough.

highpointe 2012-05-27, 04:50
Subir S 2012-05-27, 07:50