[SPARK-4918][Core] Reuse Text in saveAsTextFile
[SPARK-4918][Core] Reuse Text in saveAsTextFile

Reuse Text in saveAsTextFile to reduce GC.

/cc rxin

Author: zsxwing <zsxwing@gmail.com>

Closes #3762 from zsxwing/SPARK-4918 and squashes the following commits:

59f03eb [zsxwing] Reuse Text in saveAsTextFile

ddna1021/spark,aokolnychyi/spark,actuaryzhang/spark,witgo/spark,shubhamchopra/spark,nchammas/spark,LantaoJin/spark,markhamstra/spark,szhem/spark,debugger87/spark,Aegeaner/spark,actuaryzhang/spark,jlopezmalla/spark,JerryLead/spark,WindCanDie/spark,saltstar/spark,gioenn/xSpark,milliman/spark,kiszk/spark,rezasafi/spark,nlalevee/spark,actuaryzhang/spark,brad-kaiser/spark,jiangxb1987/spark,map222/spark,rikima/spark,MLnick/spark,panfengfeng/spark,taroplus/spark,WindCanDie/spark,someorz/spark,jkbradley/spark,zhouyejoe/spark,andrewor14/iolap,liutang123/spark,narahari92/spark,wangyum/spark,darionyaphet/spark,aokolnychyi/spark,kevinyu98/spark,lxsmnv/spark,HyukjinKwon/spark,milliman/spark,stanzhai/spark,SHASHANKB/spark,andrewor14/iolap,saturday-shi/spark,bOOm-X/spark,sureshthalamati/spark,xflin/spark,alunarbeach/spark,ericvandenbergfb/spark,caneGuy/spark,nchammas/spark,kiszk/spark,akopich/spark,techaddict/spark,ahnqirage/spark,rekhajoshm/spark,lvdongr/spark,ddna1021/spark,highfei2011/spark,dbtsai/spark,jrshust/spark,liutang123/spark,ConeyLiu/spark,bOOm-X/spark,BryanCutler/spark,narahari92/spark,guoxiaolongzte/spark,shaneknapp/spark,mike0sv/spark,darionyaphet/spark,nlalevee/spark,JerryLead/spark,JerryLead/spark,andrewor14/iolap,liyichao/spark,mahak/spark,saltstar/spark,ajaysaini725/spark,Aegeaner/spark,dhruve/spark,apache-spark-on-k8s/spark,saltstar/spark,rednaxelafx/apache-spark,wangyum/spark,ueshin/apache-spark,1haodian/spark,poffuomo/spark,xuanyuanking/spark,jianran/spark,ddna1021/spark,minixalpha/spark,saltstar/spark,ahnqirage/spark,apache-spark-on-k8s/spark,eyalfa/spark,ConeyLiu/spark,BryanCutler/spark,big-pegasus/spark,stanzhai/spark,holdenk/spark,janewangfb/spark,aray/spark,cin/spark,facaiy/spark,skonto/spark,stanzhai/spark,zuotingbing/spark,wangyum/spark,kimoonkim/spark,nchammas/spark,nlalevee/spark,saltstar/spark,liutang123/spark,UndeadBaneGitHub/spark,skonto/spark,WindCanDie/spark,taroplus/spark,zero323/spark,zzcclp/spark,hhbyyh/spark,srowen/spark,joseph-torres/spark,patrick-nicholson/spark,srowen/spark,sahilTakiar/spark,alunarbeach/spark,janewangfb/spark,darionyaphet/spark,spark-test/spark,szhem/spark,kiszk/spark,someorz/spark,yanboliang/spark,poffuomo/spark,ConeyLiu/spark,zero323/spark,taroplus/spark,eyalfa/spark,jianran/spark,jiangxb1987/spark,liutang123/spark,JerryLead/spark,chuckchen/spark,mike0sv/spark,apache-spark-on-k8s/spark,Panos-Bletsos/spark-cost-model-optimizer,brad-kaiser/spark,someorz/spark,HyukjinKwon/spark,byakuinss/spark,mdespriee/spark,hhbyyh/spark,wzhfy/spark,chuckchen/spark,ueshin/apache-spark,mike0sv/spark,aosagie/spark,HyukjinKwon/spark,icexelloss/spark,WeichenXu123/spark,dbtsai/spark,goldmedal/spark,apache/spark,ericvandenbergfb/spark,LantaoJin/spark,cloud-fan/spark,rikima/spark,lxsmnv/spark,sachintyagi22/spark,bOOm-X/spark,kevinyu98/spark,haowu80s/spark,zero323/spark,zhouyejoe/spark,WeichenXu123/spark,ron8hu/spark,saturday-shi/spark,zuotingbing/spark,ahnqirage/spark,zuotingbing/spark,facaiy/spark,milliman/spark,actuaryzhang/spark,huang1900/spark,sureshthalamati/spark,markhamstra/spark,michalsenkyr/spark,maropu/spark,ron8hu/spark,tengpeng/spark,rikima/spark,hhbyyh/spark,minixalpha/spark,liyichao/spark,mzl9039/spark,shubhamchopra/spark,brad-kaiser/spark,pronix/spark,JoshRosen/spark,alunarbeach/spark,shuangshuangwang/spark,yanboliang/spark,huang1900/spark,dbtsai/spark,ibm-research-ireland/sparkoscope,facaiy/spark,huang1900/spark,SnappyDataInc/spark,sachintyagi22/spark,map222/spark,nilsgrabbert/spark,guoxiaolongzte/spark,hvanhovell/spark,dongjoon-hyun/spark,sahilTakiar/spark,andrewor14/iolap,guoxiaolongzte/spark,wangmiao1981/spark,zzcclp/spark,BryanCutler/spark,aray/spark,dhruve/spark,mzl9039/spark,pronix/spark,shuangshuangwang/spark,wzhfy/spark,bravo-zhang/spark,Aegeaner/spark,apache-spark-on-k8s/spark,ahnqirage/spark,aosagie/spark,1haodian/spark,aray/spark,spark-test/spark,yanboliang/spark,liyichao/spark,ioana-delaney/spark,darionyaphet/spark,guoxiaolongzte/spark,WeichenXu123/spark,szhem/spark,pgandhi999/spark,1haodian/spark,mdespriee/spark,ioana-delaney/spark,panfengfeng/spark,szhem/spark,icexelloss/spark,rezasafi/spark,wzhfy/spark,narahari92/spark,nilsgrabbert/spark,shaneknapp/spark,skonto/spark,kiszk/spark,map222/spark,bdrillard/spark,sureshthalamati/spark,taroplus/spark,metamx/spark,bdrillard/spark,kevinyu98/spark,cloud-fan/spark,cloud-fan/spark,someorz/spark,haowu80s/spark,UndeadBaneGitHub/spark,dbtsai/spark,jiangxb1987/spark,debugger87/spark,mdespriee/spark,cloud-fan/spark,adrian-ionescu/apache-spark,techaddict/spark,rezasafi/spark,BryanCutler/spark,gioenn/xSpark,JerryLead/spark,dhruve/spark,zuotingbing/spark,cin/spark,hhbyyh/spark,jlopezmalla/spark,sachintyagi22/spark,jiangxb1987/spark,rekhajoshm/spark,mzl9039/spark,saturday-shi/spark,mzl9039/spark,shaneknapp/spark,SHASHANKB/spark,aray/spark,maropu/spark,aosagie/spark,zzcclp/spark,rekhajoshm/spark,adrian-ionescu/apache-spark,mahak/spark,ajaysaini725/spark,zzcclp/spark,hhbyyh/spark,bOOm-X/spark,esi-mineset/spark,markhamstra/spark,xuanyuanking/spark,tengpeng/spark,tejasapatil/spark,dongjoon-hyun/spark,guoxiaolongzte/spark,chuckchen/spark,cloud-fan/spark,adrian-ionescu/apache-spark,gengliangwang/spark,janewangfb/spark,rikima/spark,map222/spark,joseph-torres/spark,saltstar/spark,publicRoman/spark,xflin/spark,JoshRosen/spark,jiangxb1987/spark,bravo-zhang/spark,highfei2011/spark,saltstar/spark,tengpeng/spark,pgandhi999/spark,liutang123/spark,ddna1021/spark,ueshin/apache-spark,caneGuy/spark,aray/spark,shubhamchopra/spark,bdrillard/spark,srowen/spark,andrewor14/iolap,srowen/spark,ahnqirage/spark,zuotingbing/spark,ericvandenbergfb/spark,cin/spark,setjet/spark,ptkool/spark,UndeadBaneGitHub/spark,aosagie/spark,jianran/spark,markhamstra/spark,mahak/spark,ptkool/spark,poffuomo/spark,publicRoman/spark,sureshthalamati/spark,ioana-delaney/spark,ajaysaini725/spark,actuaryzhang/spark,icexelloss/spark,jkbradley/spark,wzhfy/spark,loneknightpy/spark,joseph-torres/spark,shubhamchopra/spark,ConeyLiu/spark,JerryLead/spark,markhamstra/spark,liyichao/spark,xflin/spark,dongjoon-hyun/spark,caneGuy/spark,dongjoon-hyun/spark,debugger87/spark,liyichao/spark,kimoonkim/spark,joseph-torres/spark,xflin/spark,WindCanDie/spark,kevinyu98/spark,liutang123/spark,ahnqirage/spark,witgo/spark,liyichao/spark,minixalpha/spark,wangmiao1981/spark,highfei2011/spark,apache-spark-on-k8s/spark,aokolnychyi/spark,maropu/spark,akopich/spark,mdespriee/spark,SnappyDataInc/spark,sachintyagi22/spark,shaneknapp/spark,metamx/spark,loneknightpy/spark,nilsgrabbert/spark,caneGuy/spark,ajaysaini725/spark,alunarbeach/spark,nchammas/spark,SHASHANKB/spark,huang1900/spark,debugger87/spark,andrewor14/spark,bdrillard/spark,kissmetrics/spark,brad-kaiser/spark,facaiy/spark,patrick-nicholson/spark,xuanyuanking/spark,ron8hu/spark,someorz/spark,caneGuy/spark,haowu80s/spark,goldmedal/spark,lvdongr/spark,pronix/spark,SHASHANKB/spark,aosagie/spark,chuckchen/spark,big-pegasus/spark,HyukjinKwon/spark,ajaysaini725/spark,wangyum/spark,akopich/spark,ajaysaini725/spark,JerryLead/spark,vinodkc/spark,szhem/spark,milliman/spark,caneGuy/spark,rikima/spark,mzl9039/spark,vinodkc/spark,publicRoman/spark,jkbradley/spark,andrewor14/spark,ibm-research-ireland/sparkoscope,kissmetrics/spark,nchammas/spark,ibm-research-ireland/sparkoscope,andrewor14/spark,hvanhovell/spark,nlalevee/spark,ioana-delaney/spark,jianran/spark,techaddict/spark,maropu/spark,saturday-shi/spark,1haodian/spark,metamx/spark,aokolnychyi/spark,MLnick/spark,HyukjinKwon/spark,gioenn/xSpark,ron8hu/spark,nlalevee/spark,icexelloss/spark,rezasafi/spark,techaddict/spark,darionyaphet/spark,byakuinss/spark,poffuomo/spark,debugger87/spark,1haodian/spark,WindCanDie/spark,shaneknapp/spark,UndeadBaneGitHub/spark,eyalfa/spark,milliman/spark,UndeadBaneGitHub/spark,tengpeng/spark,loneknightpy/spark,andrewor14/iolap,bOOm-X/spark,bravo-zhang/spark,ddna1021/spark,nilsgrabbert/spark,jkbradley/spark,xuanyuanking/spark,wangyum/spark,yanboliang/spark,mike0sv/spark,taroplus/spark,witgo/spark,ueshin/apache-spark,kiszk/spark,andrewor14/spark,brad-kaiser/spark,joseph-torres/spark,brad-kaiser/spark,WeichenXu123/spark,esi-mineset/spark,setjet/spark,michalsenkyr/spark,gengliangwang/spark,SnappyDataInc/spark,jiangxb1987/spark,kimoonkim/spark,holdenk/spark,SnappyDataInc/spark,Aegeaner/spark,maropu/spark,bdrillard/spark,holdenk/spark,gioenn/xSpark,kissmetrics/spark,ajaysaini725/spark,eyalfa/spark,srowen/spark,setjet/spark,dongjoon-hyun/spark,haowu80s/spark,nlalevee/spark,1haodian/spark,Panos-Bletsos/spark-cost-model-optimizer,lvdongr/spark,jkbradley/spark,sahilTakiar/spark,ioana-delaney/spark,metamx/spark,jlopezmalla/spark,ddna1021/spark,adrian-ionescu/apache-spark,zzcclp/spark,aosagie/spark,SnappyDataInc/spark,patrick-nicholson/spark,esi-mineset/spark,kimoonkim/spark,taroplus/spark,gengliangwang/spark,vinodkc/spark,jlopezmalla/spark,jlopezmalla/spark,wangmiao1981/spark,patrick-nicholson/spark,vinodkc/spark,setjet/spark,chuckchen/spark,ConeyLiu/spark,setjet/spark,Panos-Bletsos/spark-cost-model-optimizer,andrewor14/spark,stanzhai/spark,loneknightpy/spark,markhamstra/spark,MLnick/spark,tejasapatil/spark,hhbyyh/spark,ibm-research-ireland/sparkoscope,michalsenkyr/spark,bOOm-X/spark,ptkool/spark,janewangfb/spark,darionyaphet/spark,rekhajoshm/spark,ahnqirage/spark,sahilTakiar/spark,big-pegasus/spark,holdenk/spark,akopich/spark,hhbyyh/spark,JoshRosen/spark,ron8hu/spark,zhouyejoe/spark,saturday-shi/spark,xflin/spark,dongjoon-hyun/spark,huang1900/spark,michalsenkyr/spark,map222/spark,holdenk/spark,narahari92/spark,lvdongr/spark,gioenn/xSpark,map222/spark,haowu80s/spark,mike0sv/spark,shaneknapp/spark,stanzhai/spark,patrick-nicholson/spark,lxsmnv/spark,tengpeng/spark,actuaryzhang/spark,witgo/spark,pgandhi999/spark,gengliangwang/spark,wzhfy/spark,milliman/spark,JoshRosen/spark,icexelloss/spark,ioana-delaney/spark,mahak/spark,kissmetrics/spark,janewangfb/spark,bravo-zhang/spark,UndeadBaneGitHub/spark,jkbradley/spark,shubhamchopra/spark,Panos-Bletsos/spark-cost-model-optimizer,shubhamchopra/spark,lvdongr/spark,ptkool/spark,rednaxelafx/apache-spark,janewangfb/spark,mike0sv/spark,Aegeaner/spark,JoshRosen/spark,panfengfeng/spark,esi-mineset/spark,stanzhai/spark,goldmedal/spark,rednaxelafx/apache-spark,zhouyejoe/spark,poffuomo/spark,apache/spark,sahilTakiar/spark,MLnick/spark,UndeadBaneGitHub/spark,MLnick/spark,highfei2011/spark,srowen/spark,debugger87/spark,jrshust/spark,ibm-research-ireland/sparkoscope,kiszk/spark,akopich/spark,ibm-research-ireland/sparkoscope,sureshthalamati/spark,MLnick/spark,spark-test/spark,holdenk/spark,adrian-ionescu/apache-spark,1haodian/spark,BryanCutler/spark,dongjoon-hyun/spark,kissmetrics/spark,xuanyuanking/spark,techaddict/spark,cloud-fan/spark,kevinyu98/spark,LantaoJin/spark,apache-spark-on-k8s/spark,kimoonkim/spark,shuangshuangwang/spark,liutang123/spark,ddna1021/spark,LantaoJin/spark,xuanyuanking/spark,ericvandenbergfb/spark,srowen/spark,kevinyu98/spark,hvanhovell/spark,chuckchen/spark,spark-test/spark,ron8hu/spark,spark-test/spark,wangmiao1981/spark,ptkool/spark,nlalevee/spark,goldmedal/spark,andrewor14/spark,rekhajoshm/spark,aokolnychyi/spark,wangyum/spark,michalsenkyr/spark,facaiy/spark,jlopezmalla/spark,nilsgrabbert/spark,apache/spark,rednaxelafx/apache-spark,aokolnychyi/spark,maropu/spark,lxsmnv/spark,hvanhovell/spark,tengpeng/spark,cin/spark,jrshust/spark,ericvandenbergfb/spark,byakuinss/spark,metamx/spark,MLnick/spark,chuckchen/spark,mzl9039/spark,apache/spark,lxsmnv/spark,saturday-shi/spark,rednaxelafx/apache-spark,loneknightpy/spark,byakuinss/spark,cin/spark,stanzhai/spark,zero323/spark,matthewfranglen/spark,wangmiao1981/spark,dhruve/spark,nchammas/spark,highfei2011/spark,jrshust/spark,wzhfy/spark,spark-test/spark,rednaxelafx/apache-spark,minixalpha/spark,apache-spark-on-k8s/spark,jiangxb1987/spark,WeichenXu123/spark,minixalpha/spark,highfei2011/spark,jrshust/spark,xflin/spark,alunarbeach/spark,akopich/spark,sureshthalamati/spark,hvanhovell/spark,actuaryzhang/spark,mdespriee/spark,eyalfa/spark,tengpeng/spark,ibm-research-ireland/sparkoscope,kimoonkim/spark,zuotingbing/spark,cin/spark,caneGuy/spark,rednaxelafx/apache-spark,metamx/spark,zzcclp/spark,brad-kaiser/spark,wzhfy/spark,spark-test/spark,witgo/spark,cloud-fan/spark,tejasapatil/spark,vinodkc/spark,ConeyLiu/spark,big-pegasus/spark,eyalfa/spark,tejasapatil/spark,someorz/spark,pgandhi999/spark,pgandhi999/spark,esi-mineset/spark,big-pegasus/spark,bOOm-X/spark,milliman/spark,vinodkc/spark,aosagie/spark,poffuomo/spark,publicRoman/spark,techaddict/spark,minixalpha/spark,setjet/spark,sachintyagi22/spark,xuanyuanking/spark,SnappyDataInc/spark,alunarbeach/spark,rezasafi/spark,cin/spark,publicRoman/spark,highfei2011/spark,kevinyu98/spark,byakuinss/spark,michalsenkyr/spark,tejasapatil/spark,ueshin/apache-spark,nchammas/spark,rezasafi/spark,publicRoman/spark,huang1900/spark,mike0sv/spark,shuangshuangwang/spark,goldmedal/spark,kissmetrics/spark,zuotingbing/spark,zero323/spark,rekhajoshm/spark,alunarbeach/spark,big-pegasus/spark,Panos-Bletsos/spark-cost-model-optimizer,pgandhi999/spark,narahari92/spark,icexelloss/spark,zero323/spark,lxsmnv/spark,WeichenXu123/spark,bdrillard/spark,gengliangwang/spark,guoxiaolongzte/spark,markhamstra/spark,pgandhi999/spark,szhem/spark,sahilTakiar/spark,byakuinss/spark,jianran/spark,yanboliang/spark,goldmedal/spark,gioenn/xSpark,SHASHANKB/spark,byakuinss/spark,zhouyejoe/spark,patrick-nicholson/spark,facaiy/spark,nilsgrabbert/spark,setjet/spark,JoshRosen/spark,lvdongr/spark,facaiy/spark,holdenk/spark,jrshust/spark,joseph-torres/spark,minixalpha/spark,janewangfb/spark,goldmedal/spark,BryanCutler/spark,sachintyagi22/spark,dbtsai/spark,gengliangwang/spark,zzcclp/spark,narahari92/spark,hvanhovell/spark,pronix/spark,adrian-ionescu/apache-spark,akopich/spark,sahilTakiar/spark,guoxiaolongzte/spark,rikima/spark,shuangshuangwang/spark,techaddict/spark,dbtsai/spark,kimoonkim/spark,sachintyagi22/spark,panfengfeng/spark,dhruve/spark,ptkool/spark,ueshin/apache-spark,gengliangwang/spark,wangmiao1981/spark,aokolnychyi/spark,eyalfa/spark,gioenn/xSpark,WindCanDie/spark,yanboliang/spark,kissmetrics/spark,zhouyejoe/spark,bravo-zhang/spark,skonto/spark,JoshRosen/spark,shuangshuangwang/spark,lvdongr/spark,bdrillard/spark,esi-mineset/spark,someorz/spark,apache/spark,michalsenkyr/spark,shubhamchopra/spark,bravo-zhang/spark,zero323/spark,apache/spark,ptkool/spark,darionyaphet/spark,szhem/spark,dbtsai/spark,aray/spark,zhouyejoe/spark,maropu/spark,lxsmnv/spark,wangyum/spark,WeichenXu123/spark,SHASHANKB/spark,bravo-zhang/spark,LantaoJin/spark,WindCanDie/spark,saturday-shi/spark,mahak/spark,rekhajoshm/spark,sureshthalamati/spark,yanboliang/spark,wangmiao1981/spark,pronix/spark,Panos-Bletsos/spark-cost-model-optimizer,jianran/spark,publicRoman/spark,witgo/spark,andrewor14/spark,ueshin/apache-spark,poffuomo/spark,HyukjinKwon/spark,shuangshuangwang/spark,liyichao/spark,ron8hu/spark,esi-mineset/spark,skonto/spark,tejasapatil/spark,icexelloss/spark,BryanCutler/spark,apache/spark,witgo/spark,mahak/spark,loneknightpy/spark,haowu80s/spark,pronix/spark,Aegeaner/spark,SnappyDataInc/spark,map222/spark,ConeyLiu/spark,huang1900/spark,hvanhovell/spark,panfengfeng/spark,patrick-nicholson/spark,metamx/spark,tejasapatil/spark,Aegeaner/spark,jianran/spark,rezasafi/spark,narahari92/spark,debugger87/spark,mahak/spark,jkbradley/spark,mzl9039/spark,adrian-ionescu/apache-spark,kiszk/spark,ioana-delaney/spark,loneknightpy/spark,shaneknapp/spark,vinodkc/spark,panfengfeng/spark,skonto/spark,panfengfeng/spark,andrewor14/iolap,ericvandenbergfb/spark,dhruve/spark,mdespriee/spark,taroplus/spark,SHASHANKB/spark,dhruve/spark,nilsgrabbert/spark,LantaoJin/spark,Panos-Bletsos/spark-cost-model-optimizer,skonto/spark,jlopezmalla/spark,joseph-torres/spark,ericvandenbergfb/spark,big-pegasus/spark,rikima/spark,xflin/spark,HyukjinKwon/spark,mdespriee/spark,aray/spark,jrshust/spark,LantaoJin/spark