You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pig.apache.org by "Benjamin Francisoud (JIRA)" <ji...@apache.org> on 2008/02/12 17:39:11 UTC

[jira] Created: (PIG-106) Improve use of StringBuffer in TestBuiltin.java to reduce memory footprint and increase speed

Improve use of StringBuffer in TestBuiltin.java to reduce memory footprint and increase speed
---------------------------------------------------------------------------------------------

                 Key: PIG-106
                 URL: https://issues.apache.org/jira/browse/PIG-106
             Project: Pig
          Issue Type: Improvement
    Affects Versions: 0.1.0
            Reporter: Benjamin Francisoud
            Priority: Minor


While investigating PIG-99, in TestBuiltin.java line 315:
{code:java}
for (int i = 0; i < LOOP_COUNT; i++) {
    for (int j = 0; j < LOOP_COUNT; j++) {
        sb.append(i + "\t" + i + "\t" + j % 2 + "\n");
    }
}
{code}

doing "i + "\t" + i + "\t" + j % 2 + "\n"" creates temporary String(s) reducing the advantages of using a StringBuffer.

Could be replace with:
{code:java}
for (int i = 0; i < LOOP_COUNT; i++) {
    for (int j = 0; j < LOOP_COUNT; j++) {
        sb.append(i);
        sb.append("\t");
        sb.append(i);
        sb.append("\t");
        sb.append(j % 2);
        sb.append("\n");
    }
}
{code}


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (PIG-106) Optimize Pig by replacing String '+' and StringBuffer with StringBuilder

Posted by "Benjamin Francisoud (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIG-106?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benjamin Francisoud updated PIG-106:
------------------------------------

    Attachment: PIG-106-v02.patch

Replaced every patterns:
* String s =  "something" + value + "else";
* usage of StringBuffer

with StringBuilder

Also used log.isDebugEnable() method to avoid computing String(s) when log level is not debug.

There must be some String accumulation left but that's already a good start.

> Optimize Pig by replacing String '+' and StringBuffer with StringBuilder
> ------------------------------------------------------------------------
>
>                 Key: PIG-106
>                 URL: https://issues.apache.org/jira/browse/PIG-106
>             Project: Pig
>          Issue Type: Improvement
>          Components: impl
>    Affects Versions: 0.1.0
>            Reporter: Benjamin Francisoud
>            Assignee: Benjamin Francisoud
>         Attachments: PIG-106-v01.patch, PIG-106-v02.patch
>
>
> While investigating PIG-99, in TestBuiltin.java line 315:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
>     for (int j = 0; j < LOOP_COUNT; j++) {
>         sb.append(i + "\t" + i + "\t" + j % 2 + "\n");
>     }
> }
> {code}
> doing "i + "\t" + i + "\t" + j % 2 + "\n"" creates temporary String(s) reducing the advantages of using a StringBuffer.
> Could be replace with:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
>     for (int j = 0; j < LOOP_COUNT; j++) {
>         sb.append(i);
>         sb.append("\t");
>         sb.append(i);
>         sb.append("\t");
>         sb.append(j % 2);
>         sb.append("\n");
>     }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PIG-106) Improve use of StringBuffer in TestBuiltin.java to reduce memory footprint and increase speed

Posted by "Benjamin Reed (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIG-106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12568230#action_12568230 ] 

Benjamin Reed commented on PIG-106:
-----------------------------------

It will probably run even faster with StringBuilder instead of StringBuffer.

> Improve use of StringBuffer in TestBuiltin.java to reduce memory footprint and increase speed
> ---------------------------------------------------------------------------------------------
>
>                 Key: PIG-106
>                 URL: https://issues.apache.org/jira/browse/PIG-106
>             Project: Pig
>          Issue Type: Improvement
>    Affects Versions: 0.1.0
>            Reporter: Benjamin Francisoud
>            Priority: Minor
>         Attachments: PIG-106-v01.patch
>
>
> While investigating PIG-99, in TestBuiltin.java line 315:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
>     for (int j = 0; j < LOOP_COUNT; j++) {
>         sb.append(i + "\t" + i + "\t" + j % 2 + "\n");
>     }
> }
> {code}
> doing "i + "\t" + i + "\t" + j % 2 + "\n"" creates temporary String(s) reducing the advantages of using a StringBuffer.
> Could be replace with:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
>     for (int j = 0; j < LOOP_COUNT; j++) {
>         sb.append(i);
>         sb.append("\t");
>         sb.append(i);
>         sb.append("\t");
>         sb.append(j % 2);
>         sb.append("\n");
>     }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PIG-106) Improve use of StringBuffer in TestBuiltin.java to reduce memory footprint and increase speed

Posted by "Benjamin Francisoud (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIG-106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12568632#action_12568632 ] 

Benjamin Francisoud commented on PIG-106:
-----------------------------------------

I was more concern in replacing String with StringBuffer
But if StringBuilder is even more efficient let's replace both String and StringBuffer with it :)
Except in case when there is no need, no string accumulations, of course...

> Improve use of StringBuffer in TestBuiltin.java to reduce memory footprint and increase speed
> ---------------------------------------------------------------------------------------------
>
>                 Key: PIG-106
>                 URL: https://issues.apache.org/jira/browse/PIG-106
>             Project: Pig
>          Issue Type: Improvement
>    Affects Versions: 0.1.0
>            Reporter: Benjamin Francisoud
>            Priority: Minor
>         Attachments: PIG-106-v01.patch
>
>
> While investigating PIG-99, in TestBuiltin.java line 315:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
>     for (int j = 0; j < LOOP_COUNT; j++) {
>         sb.append(i + "\t" + i + "\t" + j % 2 + "\n");
>     }
> }
> {code}
> doing "i + "\t" + i + "\t" + j % 2 + "\n"" creates temporary String(s) reducing the advantages of using a StringBuffer.
> Could be replace with:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
>     for (int j = 0; j < LOOP_COUNT; j++) {
>         sb.append(i);
>         sb.append("\t");
>         sb.append(i);
>         sb.append("\t");
>         sb.append(j % 2);
>         sb.append("\n");
>     }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PIG-106) Optimize Pig by replacing String '+' and StringBuffer with StringBuilder

Posted by "Benjamin Francisoud (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIG-106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12574429#action_12574429 ] 

Benjamin Francisoud commented on PIG-106:
-----------------------------------------

I was up-to-date with the latest svn rev when I did the patch, I'm sorry you got errors :(

I will take a look at the if/else you are mentioning... if I did that that was be mistake.

Few cases where I add to modify code:

When there was this kind of code:
{code:java}
if (boolean)
    something("a" + "b" + "c");
else
    else("a" + "b" + "c");
{code}
I had to put brackets when using the StringBuilder
{code:java}

if (boolean) {
    StringBuilder sb = new StringBuilder();
    sb.append("a");
    sb.append("b");
    sb.append("c");
    something(sb.toString());
} else {
    StringBuilder sb = new StringBuilder();
    sb.append("a");
    sb.append("b");
    sb.append("c");
    else(sb.toString());
}
{code}

Other case:
{code:java}
log.debug("a" + "b" + "c");
{code}
replaced with
{code:java}
if (log.isDebugEnable()) {
    StringBuilder sb = new StringBuilder();
    sb.append("a");
    sb.append("b");
    sb.append("c");
    log.debug(sb.toString());
}
{code}

> Optimize Pig by replacing String '+' and StringBuffer with StringBuilder
> ------------------------------------------------------------------------
>
>                 Key: PIG-106
>                 URL: https://issues.apache.org/jira/browse/PIG-106
>             Project: Pig
>          Issue Type: Improvement
>          Components: impl
>    Affects Versions: 0.1.0
>            Reporter: Benjamin Francisoud
>            Assignee: Benjamin Francisoud
>         Attachments: PIG-106-v01.patch, PIG-106-v02.patch
>
>
> While investigating PIG-99, in TestBuiltin.java line 315:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
>     for (int j = 0; j < LOOP_COUNT; j++) {
>         sb.append(i + "\t" + i + "\t" + j % 2 + "\n");
>     }
> }
> {code}
> doing "i + "\t" + i + "\t" + j % 2 + "\n"" creates temporary String(s) reducing the advantages of using a StringBuffer.
> Could be replace with:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
>     for (int j = 0; j < LOOP_COUNT; j++) {
>         sb.append(i);
>         sb.append("\t");
>         sb.append(i);
>         sb.append("\t");
>         sb.append(j % 2);
>         sb.append("\n");
>     }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (PIG-106) Improve use of StringBuffer in TestBuiltin.java to reduce memory footprint and increase speed

Posted by "Benjamin Francisoud (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIG-106?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benjamin Francisoud updated PIG-106:
------------------------------------

    Attachment: PIG-106-v01.patch

> Improve use of StringBuffer in TestBuiltin.java to reduce memory footprint and increase speed
> ---------------------------------------------------------------------------------------------
>
>                 Key: PIG-106
>                 URL: https://issues.apache.org/jira/browse/PIG-106
>             Project: Pig
>          Issue Type: Improvement
>    Affects Versions: 0.1.0
>            Reporter: Benjamin Francisoud
>            Priority: Minor
>         Attachments: PIG-106-v01.patch
>
>
> While investigating PIG-99, in TestBuiltin.java line 315:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
>     for (int j = 0; j < LOOP_COUNT; j++) {
>         sb.append(i + "\t" + i + "\t" + j % 2 + "\n");
>     }
> }
> {code}
> doing "i + "\t" + i + "\t" + j % 2 + "\n"" creates temporary String(s) reducing the advantages of using a StringBuffer.
> Could be replace with:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
>     for (int j = 0; j < LOOP_COUNT; j++) {
>         sb.append(i);
>         sb.append("\t");
>         sb.append(i);
>         sb.append("\t");
>         sb.append(j % 2);
>         sb.append("\n");
>     }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (PIG-106) Optimize Pig by replacing String '+' and StringBuffer with StringBuilder

Posted by "Benjamin Francisoud (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIG-106?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benjamin Francisoud updated PIG-106:
------------------------------------

    Component/s: impl
       Priority: Major  (was: Minor)
     Patch Info: [Patch Available]
       Assignee: Benjamin Francisoud
        Summary: Optimize Pig by replacing String '+' and StringBuffer with StringBuilder  (was: Improve use of StringBuffer in TestBuiltin.java to reduce memory footprint and increase speed)

Changing the name since it's drifting from the original purpose...

> Optimize Pig by replacing String '+' and StringBuffer with StringBuilder
> ------------------------------------------------------------------------
>
>                 Key: PIG-106
>                 URL: https://issues.apache.org/jira/browse/PIG-106
>             Project: Pig
>          Issue Type: Improvement
>          Components: impl
>    Affects Versions: 0.1.0
>            Reporter: Benjamin Francisoud
>            Assignee: Benjamin Francisoud
>         Attachments: PIG-106-v01.patch
>
>
> While investigating PIG-99, in TestBuiltin.java line 315:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
>     for (int j = 0; j < LOOP_COUNT; j++) {
>         sb.append(i + "\t" + i + "\t" + j % 2 + "\n");
>     }
> }
> {code}
> doing "i + "\t" + i + "\t" + j % 2 + "\n"" creates temporary String(s) reducing the advantages of using a StringBuffer.
> Could be replace with:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
>     for (int j = 0; j < LOOP_COUNT; j++) {
>         sb.append(i);
>         sb.append("\t");
>         sb.append(i);
>         sb.append("\t");
>         sb.append(j % 2);
>         sb.append("\n");
>     }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PIG-106) Improve use of StringBuffer in TestBuiltin.java to reduce memory footprint and increase speed

Posted by "Pi Song (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIG-106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12573249#action_12573249 ] 

Pi Song commented on PIG-106:
-----------------------------

Pig is a total single-threaded frontend. StringBuilder should be definitely more appropriate.
Though, is there any plan to move Pig to multithreaded client-server model?

> Improve use of StringBuffer in TestBuiltin.java to reduce memory footprint and increase speed
> ---------------------------------------------------------------------------------------------
>
>                 Key: PIG-106
>                 URL: https://issues.apache.org/jira/browse/PIG-106
>             Project: Pig
>          Issue Type: Improvement
>    Affects Versions: 0.1.0
>            Reporter: Benjamin Francisoud
>            Priority: Minor
>         Attachments: PIG-106-v01.patch
>
>
> While investigating PIG-99, in TestBuiltin.java line 315:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
>     for (int j = 0; j < LOOP_COUNT; j++) {
>         sb.append(i + "\t" + i + "\t" + j % 2 + "\n");
>     }
> }
> {code}
> doing "i + "\t" + i + "\t" + j % 2 + "\n"" creates temporary String(s) reducing the advantages of using a StringBuffer.
> Could be replace with:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
>     for (int j = 0; j < LOOP_COUNT; j++) {
>         sb.append(i);
>         sb.append("\t");
>         sb.append(i);
>         sb.append("\t");
>         sb.append(j % 2);
>         sb.append("\n");
>     }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (PIG-106) Optimize Pig by replacing String '+' and StringBuffer with StringBuilder

Posted by "Benjamin Francisoud (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIG-106?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benjamin Francisoud updated PIG-106:
------------------------------------

    Attachment: PIG-106-v03.patch

Regenerate the patch.
Fixed svn conflict in Tuple.java and removed the extra else that Olga was mentioning (tanks for pointing it).

> Optimize Pig by replacing String '+' and StringBuffer with StringBuilder
> ------------------------------------------------------------------------
>
>                 Key: PIG-106
>                 URL: https://issues.apache.org/jira/browse/PIG-106
>             Project: Pig
>          Issue Type: Improvement
>          Components: impl
>    Affects Versions: 0.1.0
>            Reporter: Benjamin Francisoud
>            Assignee: Benjamin Francisoud
>         Attachments: PIG-106-v01.patch, PIG-106-v02.patch, PIG-106-v03.patch
>
>
> While investigating PIG-99, in TestBuiltin.java line 315:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
>     for (int j = 0; j < LOOP_COUNT; j++) {
>         sb.append(i + "\t" + i + "\t" + j % 2 + "\n");
>     }
> }
> {code}
> doing "i + "\t" + i + "\t" + j % 2 + "\n"" creates temporary String(s) reducing the advantages of using a StringBuffer.
> Could be replace with:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
>     for (int j = 0; j < LOOP_COUNT; j++) {
>         sb.append(i);
>         sb.append("\t");
>         sb.append(i);
>         sb.append("\t");
>         sb.append(j % 2);
>         sb.append("\n");
>     }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PIG-106) Improve use of StringBuffer in TestBuiltin.java to reduce memory footprint and increase speed

Posted by "Benjamin Francisoud (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIG-106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12568203#action_12568203 ] 

Benjamin Francisoud commented on PIG-106:
-----------------------------------------

Execution time:
before: 687 ms - after: 515 ms
other runs give almost the same numbers...

> Improve use of StringBuffer in TestBuiltin.java to reduce memory footprint and increase speed
> ---------------------------------------------------------------------------------------------
>
>                 Key: PIG-106
>                 URL: https://issues.apache.org/jira/browse/PIG-106
>             Project: Pig
>          Issue Type: Improvement
>    Affects Versions: 0.1.0
>            Reporter: Benjamin Francisoud
>            Priority: Minor
>         Attachments: PIG-106-v01.patch
>
>
> While investigating PIG-99, in TestBuiltin.java line 315:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
>     for (int j = 0; j < LOOP_COUNT; j++) {
>         sb.append(i + "\t" + i + "\t" + j % 2 + "\n");
>     }
> }
> {code}
> doing "i + "\t" + i + "\t" + j % 2 + "\n"" creates temporary String(s) reducing the advantages of using a StringBuffer.
> Could be replace with:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
>     for (int j = 0; j < LOOP_COUNT; j++) {
>         sb.append(i);
>         sb.append("\t");
>         sb.append(i);
>         sb.append("\t");
>         sb.append(j % 2);
>         sb.append("\n");
>     }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (PIG-106) Improve use of StringBuffer in TestBuiltin.java to reduce memory footprint and increase speed

Posted by "Olga Natkovich (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIG-106?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Olga Natkovich updated PIG-106:
-------------------------------

    Patch Info:   (was: [Patch Available])

cleared "patch available" flags since the agreement is to use StringBuilder rather than StringBuffer

> Improve use of StringBuffer in TestBuiltin.java to reduce memory footprint and increase speed
> ---------------------------------------------------------------------------------------------
>
>                 Key: PIG-106
>                 URL: https://issues.apache.org/jira/browse/PIG-106
>             Project: Pig
>          Issue Type: Improvement
>    Affects Versions: 0.1.0
>            Reporter: Benjamin Francisoud
>            Priority: Minor
>         Attachments: PIG-106-v01.patch
>
>
> While investigating PIG-99, in TestBuiltin.java line 315:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
>     for (int j = 0; j < LOOP_COUNT; j++) {
>         sb.append(i + "\t" + i + "\t" + j % 2 + "\n");
>     }
> }
> {code}
> doing "i + "\t" + i + "\t" + j % 2 + "\n"" creates temporary String(s) reducing the advantages of using a StringBuffer.
> Could be replace with:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
>     for (int j = 0; j < LOOP_COUNT; j++) {
>         sb.append(i);
>         sb.append("\t");
>         sb.append(i);
>         sb.append("\t");
>         sb.append(j % 2);
>         sb.append("\n");
>     }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PIG-106) Improve use of StringBuffer in TestBuiltin.java to reduce memory footprint and increase speed

Posted by "Craig Macdonald (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIG-106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12568234#action_12568234 ] 

Craig Macdonald commented on PIG-106:
-------------------------------------

I count 84 uses of StringBuffer in the src/ and test/ folders currently. One mega patch, similar to the space/tab patch replace all of these. Best done by someone with commit priv - any patch would quickly become dated.

> Improve use of StringBuffer in TestBuiltin.java to reduce memory footprint and increase speed
> ---------------------------------------------------------------------------------------------
>
>                 Key: PIG-106
>                 URL: https://issues.apache.org/jira/browse/PIG-106
>             Project: Pig
>          Issue Type: Improvement
>    Affects Versions: 0.1.0
>            Reporter: Benjamin Francisoud
>            Priority: Minor
>         Attachments: PIG-106-v01.patch
>
>
> While investigating PIG-99, in TestBuiltin.java line 315:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
>     for (int j = 0; j < LOOP_COUNT; j++) {
>         sb.append(i + "\t" + i + "\t" + j % 2 + "\n");
>     }
> }
> {code}
> doing "i + "\t" + i + "\t" + j % 2 + "\n"" creates temporary String(s) reducing the advantages of using a StringBuffer.
> Could be replace with:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
>     for (int j = 0; j < LOOP_COUNT; j++) {
>         sb.append(i);
>         sb.append("\t");
>         sb.append(i);
>         sb.append("\t");
>         sb.append(j % 2);
>         sb.append("\n");
>     }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (PIG-106) Optimize Pig by replacing String '+' and StringBuffer with StringBuilder

Posted by "Benjamin Francisoud (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIG-106?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benjamin Francisoud updated PIG-106:
------------------------------------

    Patch Info: [Patch Available]

> Optimize Pig by replacing String '+' and StringBuffer with StringBuilder
> ------------------------------------------------------------------------
>
>                 Key: PIG-106
>                 URL: https://issues.apache.org/jira/browse/PIG-106
>             Project: Pig
>          Issue Type: Improvement
>          Components: impl
>    Affects Versions: 0.1.0
>            Reporter: Benjamin Francisoud
>            Assignee: Benjamin Francisoud
>         Attachments: PIG-106-v01.patch, PIG-106-v02.patch, PIG-106-v03.patch
>
>
> While investigating PIG-99, in TestBuiltin.java line 315:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
>     for (int j = 0; j < LOOP_COUNT; j++) {
>         sb.append(i + "\t" + i + "\t" + j % 2 + "\n");
>     }
> }
> {code}
> doing "i + "\t" + i + "\t" + j % 2 + "\n"" creates temporary String(s) reducing the advantages of using a StringBuffer.
> Could be replace with:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
>     for (int j = 0; j < LOOP_COUNT; j++) {
>         sb.append(i);
>         sb.append("\t");
>         sb.append(i);
>         sb.append("\t");
>         sb.append(j % 2);
>         sb.append("\n");
>     }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (PIG-106) Optimize Pig by replacing String '+' and StringBuffer with StringBuilder

Posted by "Olga Natkovich (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIG-106?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Olga Natkovich updated PIG-106:
-------------------------------

    Patch Info:   (was: [Patch Available])

> Optimize Pig by replacing String '+' and StringBuffer with StringBuilder
> ------------------------------------------------------------------------
>
>                 Key: PIG-106
>                 URL: https://issues.apache.org/jira/browse/PIG-106
>             Project: Pig
>          Issue Type: Improvement
>          Components: impl
>    Affects Versions: 0.1.0
>            Reporter: Benjamin Francisoud
>            Assignee: Benjamin Francisoud
>         Attachments: PIG-106-v01.patch, PIG-106-v02.patch
>
>
> While investigating PIG-99, in TestBuiltin.java line 315:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
>     for (int j = 0; j < LOOP_COUNT; j++) {
>         sb.append(i + "\t" + i + "\t" + j % 2 + "\n");
>     }
> }
> {code}
> doing "i + "\t" + i + "\t" + j % 2 + "\n"" creates temporary String(s) reducing the advantages of using a StringBuffer.
> Could be replace with:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
>     for (int j = 0; j < LOOP_COUNT; j++) {
>         sb.append(i);
>         sb.append("\t");
>         sb.append(i);
>         sb.append("\t");
>         sb.append(j % 2);
>         sb.append("\n");
>     }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PIG-106) Optimize Pig by replacing String '+' and StringBuffer with StringBuilder

Posted by "Olga Natkovich (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIG-106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12574013#action_12574013 ] 

Olga Natkovich commented on PIG-106:
------------------------------------

I tried to apply the patch to the latest trunk and got failures. Also, as I was looking at the failures, some of the changes specifically in Tuple.java go beyond just String Builder. For instance, it adds if-else construct into the getField call. We don't want to do that - we don't want an extra branch on the critical path.

Could you regenerate the patch with just changes to to string formatting, thanks.

> Optimize Pig by replacing String '+' and StringBuffer with StringBuilder
> ------------------------------------------------------------------------
>
>                 Key: PIG-106
>                 URL: https://issues.apache.org/jira/browse/PIG-106
>             Project: Pig
>          Issue Type: Improvement
>          Components: impl
>    Affects Versions: 0.1.0
>            Reporter: Benjamin Francisoud
>            Assignee: Benjamin Francisoud
>         Attachments: PIG-106-v01.patch, PIG-106-v02.patch
>
>
> While investigating PIG-99, in TestBuiltin.java line 315:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
>     for (int j = 0; j < LOOP_COUNT; j++) {
>         sb.append(i + "\t" + i + "\t" + j % 2 + "\n");
>     }
> }
> {code}
> doing "i + "\t" + i + "\t" + j % 2 + "\n"" creates temporary String(s) reducing the advantages of using a StringBuffer.
> Could be replace with:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
>     for (int j = 0; j < LOOP_COUNT; j++) {
>         sb.append(i);
>         sb.append("\t");
>         sb.append(i);
>         sb.append("\t");
>         sb.append(j % 2);
>         sb.append("\n");
>     }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (PIG-106) Optimize Pig by replacing String '+' and StringBuffer with StringBuilder

Posted by "Alan Gates (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIG-106?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alan Gates updated PIG-106:
---------------------------

       Resolution: Fixed
    Fix Version/s: 0.1.0
           Status: Resolved  (was: Patch Available)

Fix checked in.  Thanks Benjamin.

> Optimize Pig by replacing String '+' and StringBuffer with StringBuilder
> ------------------------------------------------------------------------
>
>                 Key: PIG-106
>                 URL: https://issues.apache.org/jira/browse/PIG-106
>             Project: Pig
>          Issue Type: Improvement
>          Components: impl
>    Affects Versions: 0.1.0
>            Reporter: Benjamin Francisoud
>            Assignee: Benjamin Francisoud
>             Fix For: 0.1.0
>
>         Attachments: PIG-106-v01.patch, PIG-106-v02.patch, PIG-106-v03.patch
>
>
> While investigating PIG-99, in TestBuiltin.java line 315:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
>     for (int j = 0; j < LOOP_COUNT; j++) {
>         sb.append(i + "\t" + i + "\t" + j % 2 + "\n");
>     }
> }
> {code}
> doing "i + "\t" + i + "\t" + j % 2 + "\n"" creates temporary String(s) reducing the advantages of using a StringBuffer.
> Could be replace with:
> {code:java}
> for (int i = 0; i < LOOP_COUNT; i++) {
>     for (int j = 0; j < LOOP_COUNT; j++) {
>         sb.append(i);
>         sb.append("\t");
>         sb.append(i);
>         sb.append("\t");
>         sb.append(j % 2);
>         sb.append("\n");
>     }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.