Should I use a StringBuilder or a StringBuffer in Spark?

This question already has an answer here:

  • Difference between StringBuilder and StringBuffer 31 answers

  • The only difference between the two is that StringBuffer has synchronized methods (which is something you almost never need). So keep the valueString a local variable and go with StringBuilder .

    valueString=valueString.concat(trimmedLine.concat("n"));

    This kind of code makes me wonder if you want to concatenate a multi-line String at all. Maybe you can produce an RDD with a List of lines instead and move some of the current pre-processing into a Spark job itself?

    链接地址: http://www.djcxy.com/p/72350.html

    上一篇: JVM,JDK,JRE和OpenJDK有什么区别?

    下一篇: 我应该在Spark中使用StringBuilder还是一个StringBuffer?