Should I use a StringBuilder or a StringBuffer in Spark?
This question already has an answer here:
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