最近因为工作需要,研究了下spark,因为scala还不熟,所以先学习了java的spark程序写法,下面是我的简单测试程序的代码,大部分函数的用法已在注释里面注明。

我的环境:hadoop 2.2.0

spark-0.9.0

scala-2.10.3

jdk1.7

[java] view plain copy print?
  1. import org.apache.spark.api.java.JavaPairRDD;
  2. import org.apache.spark.api.java.JavaRDD;
  3. import org.apache.spark.api.java.JavaSparkContext;
  4. import org.apache.spark.api.java.function.FlatMapFunction;
  5. import org.apache.spark.api.java.function.Function;
  6. import org.apache.spark.api.java.function.Function2;
  7. import org.apache.spark.api.java.function.PairFunction;
  8. import scala.Tuple2;
  9. import java.util.Arrays;
  10. import java.util.List;
  11. import java.util.regex.Pattern;
  12. public final class mysparktest {
  13. public static void main(String[] args) throws Exception {
  14. //context ,用于读文件 ,类似于scala的sc
  15. //格式为:
  16. // JavaSparkContext(master: String, appName: String, sparkHome: String, jars: Array[String], environment: Map[String, String])
  17. JavaSparkContext ctx = new JavaSparkContext("yarn-standalone", "JavaWordCount",
  18. System.getenv("SPARK_HOME"), JavaSparkContext.jarOfClass(mysparktest.class));
  19. //也可以使用ctx获取环境变量,例如下面的语句
  20. System.out.println("spark home:"+ctx.getSparkHome());
  21. //一次一行,String类型    ,还有hadoopfile,sequenceFile什么的  ,可以直接用sc.textFile("path")
  22. JavaRDD<String> lines = ctx.textFile(args[1], 1);  //java.lang.String path, int minSplits
  23. lines.cache();   //cache,暂时放在缓存中,一般用于哪些可能需要多次使用的RDD,据说这样会减少运行时间
  24. //collect方法,用于将RDD类型转化为java基本类型,如下
  25. List<String> line = lines.collect();
  26. for(String val:line)
  27. System.out.println(val);
  28. //下面这些也是RDD的常用函数
  29. // lines.collect();  List<String>
  30. // lines.union();     javaRDD<String>
  31. // lines.top(1);     List<String>
  32. // lines.count();      long
  33. // lines.countByValue();
  34. /**
  35. *   filter test
  36. *   定义一个返回bool类型的函数,spark运行filter的时候会过滤掉那些返回只为false的数据
  37. *   String s,中的变量s可以认为就是变量lines(lines可以理解为一系列的String类型数据)的每一条数据
  38. */
  39. JavaRDD<String> contaninsE = lines.filter(new Function<String, Boolean>() {
  40. @Override
  41. public Boolean call(String s) throws Exception {
  42. return (s.contains("they"));
  43. }
  44. });
  45. System.out.println("--------------next filter's  result------------------");
  46. line = contaninsE.collect();
  47. for(String val:line)
  48. System.out.println(val);
  49. /**
  50. * sample test
  51. * sample函数使用很简单,用于对数据进行抽样
  52. * 参数为:withReplacement: Boolean, fraction: Double, seed: Int
  53. *
  54. */
  55. JavaRDD<String> sampletest = lines.sample(false,0.1,5);
  56. System.out.println("-------------next sample-------------------");
  57. line = sampletest.collect();
  58. for(String val:line)
  59. System.out.println(val);
  60. /**
  61. *
  62. * new FlatMapFunction<String, String>两个string分别代表输入和输出类型
  63. * Override的call方法需要自己实现一个转换的方法,并返回一个Iterable的结构
  64. *
  65. * flatmap属于一类非常常用的spark函数,简单的说作用就是将一条rdd数据使用你定义的函数给分解成多条rdd数据
  66. * 例如,当前状态下,lines这个rdd类型的变量中,每一条数据都是一行String,我们现在想把他拆分成1个个的词的话,
  67. * 可以这样写 :
  68. */
  69. JavaRDD<String> words = lines.flatMap(new FlatMapFunction<String, String>() {
  70. @Override
  71. public Iterable<String> call(String s) {
  72. String[] words=s.split(" ");
  73. return Arrays.asList(words);
  74. }
  75. });
  76. /**
  77. * map 键值对 ,类似于MR的map方法
  78. * pairFunction<T,K,V>: T:输入类型;K,V:输出键值对
  79. * 需要重写call方法实现转换
  80. */
  81. JavaPairRDD<String, Integer> ones = words.map(new PairFunction<String, String, Integer>() {
  82. @Override
  83. public Tuple2<String, Integer> call(String s) {
  84. return new Tuple2<String, Integer>(s, 1);
  85. }
  86. });
  87. //A two-argument function that takes arguments
  88. // of type T1 and T2 and returns an R.
  89. /**
  90. *  reduceByKey方法,类似于MR的reduce
  91. *  要求被操作的数据(即下面实例中的ones)是KV键值对形式,该方法会按照key相同的进行聚合,在两两运算
  92. */
  93. JavaPairRDD<String, Integer> counts = ones.reduceByKey(new Function2<Integer, Integer, Integer>() {
  94. @Override
  95. public Integer call(Integer i1, Integer i2) {  //reduce阶段,key相同的value怎么处理的问题
  96. return i1 + i2;
  97. }
  98. });
  99. //备注:spark也有reduce方法,输入数据是RDD类型就可以,不需要键值对,
  100. // reduce方法会对输入进来的所有数据进行两两运算
  101. /**
  102. * sort,顾名思义,排序
  103. */
  104. JavaPairRDD<String,Integer> sort = counts.sortByKey();
  105. System.out.println("----------next sort----------------------");
  106. /**
  107. * collect方法其实之前已经出现了多次,该方法用于将spark的RDD类型转化为我们熟知的java常见类型
  108. */
  109. List<Tuple2<String, Integer>> output = sort.collect();
  110. for (Tuple2<?,?> tuple : output) {
  111. System.out.println(tuple._1 + ": " + tuple._2());
  112. }
  113. /**
  114. * 保存函数,数据输出,spark为结果输出提供了很多接口
  115. */
  116. sort.saveAsTextFile("/tmp/spark-tmp/test");
  117. // sort.saveAsNewAPIHadoopFile();
  118. //  sort.saveAsHadoopFile();
  119. System.exit(0);
  120. }
  121. }
import org.apache.spark.api.java.JavaPairRDD;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.api.java.function.FlatMapFunction;
import org.apache.spark.api.java.function.Function;
import org.apache.spark.api.java.function.Function2;
import org.apache.spark.api.java.function.PairFunction;
import scala.Tuple2;import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;public final class mysparktest {public static void main(String[] args) throws Exception {//context ,用于读文件 ,类似于scala的sc//格式为:// JavaSparkContext(master: String, appName: String, sparkHome: String, jars: Array[String], environment: Map[String, String])JavaSparkContext ctx = new JavaSparkContext("yarn-standalone", "JavaWordCount",System.getenv("SPARK_HOME"), JavaSparkContext.jarOfClass(mysparktest.class));//也可以使用ctx获取环境变量,例如下面的语句System.out.println("spark home:"+ctx.getSparkHome());//一次一行,String类型    ,还有hadoopfile,sequenceFile什么的  ,可以直接用sc.textFile("path")JavaRDD<String> lines = ctx.textFile(args[1], 1);  //java.lang.String path, int minSplitslines.cache();   //cache,暂时放在缓存中,一般用于哪些可能需要多次使用的RDD,据说这样会减少运行时间//collect方法,用于将RDD类型转化为java基本类型,如下List<String> line = lines.collect();for(String val:line)System.out.println(val);//下面这些也是RDD的常用函数// lines.collect();  List<String>// lines.union();     javaRDD<String>// lines.top(1);     List<String>// lines.count();      long// lines.countByValue();/***   filter test*   定义一个返回bool类型的函数,spark运行filter的时候会过滤掉那些返回只为false的数据*   String s,中的变量s可以认为就是变量lines(lines可以理解为一系列的String类型数据)的每一条数据*/JavaRDD<String> contaninsE = lines.filter(new Function<String, Boolean>() {@Overridepublic Boolean call(String s) throws Exception {return (s.contains("they"));}});System.out.println("--------------next filter's  result------------------");line = contaninsE.collect();for(String val:line)System.out.println(val);/*** sample test* sample函数使用很简单,用于对数据进行抽样* 参数为:withReplacement: Boolean, fraction: Double, seed: Int**/JavaRDD<String> sampletest = lines.sample(false,0.1,5);System.out.println("-------------next sample-------------------");line = sampletest.collect();for(String val:line)System.out.println(val);/**** new FlatMapFunction<String, String>两个string分别代表输入和输出类型* Override的call方法需要自己实现一个转换的方法,并返回一个Iterable的结构** flatmap属于一类非常常用的spark函数,简单的说作用就是将一条rdd数据使用你定义的函数给分解成多条rdd数据* 例如,当前状态下,lines这个rdd类型的变量中,每一条数据都是一行String,我们现在想把他拆分成1个个的词的话,* 可以这样写 :*/JavaRDD<String> words = lines.flatMap(new FlatMapFunction<String, String>() {@Overridepublic Iterable<String> call(String s) {String[] words=s.split(" ");return Arrays.asList(words);}});/*** map 键值对 ,类似于MR的map方法* pairFunction<T,K,V>: T:输入类型;K,V:输出键值对* 需要重写call方法实现转换*/JavaPairRDD<String, Integer> ones = words.map(new PairFunction<String, String, Integer>() {@Overridepublic Tuple2<String, Integer> call(String s) {return new Tuple2<String, Integer>(s, 1);}});//A two-argument function that takes arguments// of type T1 and T2 and returns an R./***  reduceByKey方法,类似于MR的reduce*  要求被操作的数据(即下面实例中的ones)是KV键值对形式,该方法会按照key相同的进行聚合,在两两运算*/JavaPairRDD<String, Integer> counts = ones.reduceByKey(new Function2<Integer, Integer, Integer>() {@Overridepublic Integer call(Integer i1, Integer i2) {  //reduce阶段,key相同的value怎么处理的问题return i1 + i2;}});//备注:spark也有reduce方法,输入数据是RDD类型就可以,不需要键值对,// reduce方法会对输入进来的所有数据进行两两运算/*** sort,顾名思义,排序*/JavaPairRDD<String,Integer> sort = counts.sortByKey();System.out.println("----------next sort----------------------");/*** collect方法其实之前已经出现了多次,该方法用于将spark的RDD类型转化为我们熟知的java常见类型*/List<Tuple2<String, Integer>> output = sort.collect();for (Tuple2<?,?> tuple : output) {System.out.println(tuple._1 + ": " + tuple._2());}/*** 保存函数,数据输出,spark为结果输出提供了很多接口*/sort.saveAsTextFile("/tmp/spark-tmp/test");// sort.saveAsNewAPIHadoopFile();//  sort.saveAsHadoopFile();System.exit(0);}
}

代码编写完成之后,打包上传到Linux上,编写spark程序的执行脚本:

[plain] view plain copy print?
  1. #! /bin/bash
  2. export YARN_CONF_DIR=/usr/lib/cloud/hadoop/hadoop-2.2.0/etc/hadoop
  3. export SPARK_JAR=/usr/lib/cloud/spark/spark-0.9.0-incubating-bin-hadoop2/assembly/target/scala-2.10/spark-assembly_2.10-0.9.0-incubating-hadoop2.2.0.jar
  4. /usr/lib/cloud/spark/spark-0.9.0-incubating-bin-hadoop2/bin/spark-class org.apache.spark.deploy.yarn.Client \
  5. --jar mysparktest.jar \
  6. --class mysparktest.jar \
  7. --args yarn-standalone \
  8. --args /user/zhangdeyang/testspark \
  9. --num-workers 3 \
  10. --master-memory 485m \
  11. --worker-memory 485m \
  12. --worker-cores 2
#! /bin/bash
export YARN_CONF_DIR=/usr/lib/cloud/hadoop/hadoop-2.2.0/etc/hadoop
export SPARK_JAR=/usr/lib/cloud/spark/spark-0.9.0-incubating-bin-hadoop2/assembly/target/scala-2.10/spark-assembly_2.10-0.9.0-incubating-hadoop2.2.0.jar/usr/lib/cloud/spark/spark-0.9.0-incubating-bin-hadoop2/bin/spark-class org.apache.spark.deploy.yarn.Client \
--jar mysparktest.jar \
--class mysparktest.jar \
--args yarn-standalone \
--args /user/zhangdeyang/testspark \
--num-workers 3 \
--master-memory 485m \
--worker-memory 485m \
--worker-cores 2

其中输入数据保存在

/user/zhangdeyang/testspark中,测试数据如下:

[plain] view plain copy print?
  1. Look! at the window there leans an old maid. She plucks the
  2. withered leaf from the balsam, and looks at the grass-covered rampart,
  3. on which many children are playing. What is the old maid thinking
  4. of? A whole life drama is unfolding itself before her inward gaze.
  5. "The poor little children, how happy they are- how merrily they
  6. play and romp together! What red cheeks and what angels' eyes! but
  7. they have no shoes nor stockings. They dance on the green rampart,
  8. just on the place where, according to the old story, the ground always
  9. sank in, and where a sportive, frolicsome child had been lured by
  10. means of flowers, toys and sweetmeats into an open grave ready dug for
  11. it, and which was afterwards closed over the child; and from that
  12. moment, the old story says, the ground gave way no longer, the mound
  13. remained firm and fast, and was quickly covered with the green turf.
  14. The little people who now play on that spot know nothing of the old
  15. tale, else would they fancy they heard a child crying deep below the
  16. earth, and the dewdrops on each blade of grass would be to them
  17. tears of woe. Nor do they know anything of the Danish King who here,
  18. in the face of the coming foe, took an oath before all his trembling
  19. courtiers that he would hold out with the citizens of his capital, and
  20. die here in his nest; they know nothing of the men who have fought
  21. here, or of the women who from here have drenched with boiling water
  22. the enemy, clad in white, and 'biding in the snow to surprise the
  23. city.
  24. .
    Look! at the window there leans an old maid. She plucks thewithered leaf from the balsam, and looks at the grass-covered rampart,on which many children are playing. What is the old maid thinkingof? A whole life drama is unfolding itself before her inward gaze."The poor little children, how happy they are- how merrily theyplay and romp together! What red cheeks and what angels' eyes! butthey have no shoes nor stockings. They dance on the green rampart,just on the place where, according to the old story, the ground alwayssank in, and where a sportive, frolicsome child had been lured bymeans of flowers, toys and sweetmeats into an open grave ready dug forit, and which was afterwards closed over the child; and from thatmoment, the old story says, the ground gave way no longer, the moundremained firm and fast, and was quickly covered with the green turf.The little people who now play on that spot know nothing of the oldtale, else would they fancy they heard a child crying deep below theearth, and the dewdrops on each blade of grass would be to themtears of woe. Nor do they know anything of the Danish King who here,in the face of the coming foe, took an oath before all his tremblingcourtiers that he would hold out with the citizens of his capital, anddie here in his nest; they know nothing of the men who have foughthere, or of the women who from here have drenched with boiling waterthe enemy, clad in white, and 'biding in the snow to surprise thecity..

运行我们编写的运行脚本,可得结果如下:

[plain] view plain copy print?
  1. spark home:Optional.of(/usr/lib/cloud/spark/spark-0.9.0-incubating-bin-hadoop2)
  2. Look! at the window there leans an old maid. She plucks the
  3. withered leaf from the balsam, and looks at the grass-covered rampart,
  4. on which many children are playing. What is the old maid thinking
  5. of? A whole life drama is unfolding itself before her inward gaze.
  6. "The poor little children, how happy they are- how merrily they
  7. play and romp together! What red cheeks and what angels' eyes! but
  8. they have no shoes nor stockings. They dance on the green rampart,
  9. just on the place where, according to the old story, the ground always
  10. sank in, and where a sportive, frolicsome child had been lured by
  11. means of flowers, toys and sweetmeats into an open grave ready dug for
  12. it, and which was afterwards closed over the child; and from that
  13. moment, the old story says, the ground gave way no longer, the mound
  14. remained firm and fast, and was quickly covered with the green turf.
  15. The little people who now play on that spot know nothing of the old
  16. tale, else would they fancy they heard a child crying deep below the
  17. earth, and the dewdrops on each blade of grass would be to them
  18. tears of woe. Nor do they know anything of the Danish King who here,
  19. in the face of the coming foe, took an oath before all his trembling
  20. courtiers that he would hold out with the citizens of his capital, and
  21. die here in his nest; they know nothing of the men who have fought
  22. here, or of the women who from here have drenched with boiling water
  23. the enemy, clad in white, and 'biding in the snow to surprise the
  24. city.
  25. --------------next filter's  result------------------
  26. "The poor little children, how happy they are- how merrily they
  27. they have no shoes nor stockings. They dance on the green rampart,
  28. tale, else would they fancy they heard a child crying deep below the
  29. tears of woe. Nor do they know anything of the Danish King who here,
  30. die here in his nest; they know nothing of the men who have fought
  31. -------------next sample-------------------
  32. "The poor little children, how happy they are- how merrily they
  33. it, and which was afterwards closed over the child; and from that
  34. in the face of the coming foe, took an oath before all his trembling
  35. ----------next sort----------------------
  36. : 27
  37. "The: 1
  38. 'biding: 1
  39. A: 1
  40. Danish: 1
  41. King: 1
  42. Look!: 1
  43. Nor: 1
  44. She: 1
  45. The: 1
  46. They: 1
  47. What: 2
  48. a: 2
  49. according: 1
  50. afterwards: 1
  51. all: 1
  52. always: 1
  53. an: 3
  54. and: 12
  55. angels': 1
  56. anything: 1
  57. are: 1
  58. are-: 1
  59. at: 2
  60. balsam,: 1
  61. be: 1
  62. been: 1
  63. before: 2
  64. below: 1
  65. blade: 1
  66. boiling: 1
  67. but: 1
  68. by: 1
  69. capital,: 1
  70. cheeks: 1
  71. child: 2
  72. child;: 1
  73. children: 1
  74. children,: 1
  75. citizens: 1
  76. city.: 1
  77. clad: 1
  78. closed: 1
  79. coming: 1
  80. courtiers: 1
  81. covered: 1
  82. crying: 1
  83. dance: 1
  84. deep: 1
  85. dewdrops: 1
  86. die: 1
  87. do: 1
  88. drama: 1
  89. drenched: 1
  90. dug: 1
  91. each: 1
  92. earth,: 1
  93. else: 1
  94. enemy,: 1
  95. eyes!: 1
  96. face: 1
  97. fancy: 1
  98. fast,: 1
  99. firm: 1
  100. flowers,: 1
  101. foe,: 1
  102. for: 1
  103. fought: 1
  104. frolicsome: 1
  105. from: 3
  106. gave: 1
  107. gaze.: 1
  108. grass: 1
  109. grass-covered: 1
  110. grave: 1
  111. green: 2
  112. ground: 2
  113. had: 1
  114. happy: 1
  115. have: 3
  116. he: 1
  117. heard: 1
  118. her: 1
  119. here: 2
  120. here,: 2
  121. his: 3
  122. hold: 1
  123. how: 2
  124. in: 4
  125. in,: 1
  126. into: 1
  127. inward: 1
  128. is: 2
  129. it,: 1
  130. itself: 1
  131. just: 1
  132. know: 3
  133. leaf: 1
  134. leans: 1
  135. life: 1
  136. little: 2
  137. longer,: 1
  138. looks: 1
  139. lured: 1
  140. maid: 1
  141. maid.: 1
  142. many: 1
  143. means: 1
  144. men: 1
  145. merrily: 1
  146. moment,: 1
  147. mound: 1
  148. nest;: 1
  149. no: 2
  150. nor: 1
  151. nothing: 2
  152. now: 1
  153. oath: 1
  154. of: 9
  155. of?: 1
  156. old: 5
  157. on: 5
  158. open: 1
  159. or: 1
  160. out: 1
  161. over: 1
  162. people: 1
  163. place: 1
  164. play: 2
  165. playing.: 1
  166. plucks: 1
  167. poor: 1
  168. quickly: 1
  169. rampart,: 2
  170. ready: 1
  171. red: 1
  172. remained: 1
  173. romp: 1
  174. sank: 1
  175. says,: 1
  176. shoes: 1
  177. snow: 1
  178. sportive,: 1
  179. spot: 1
  180. stockings.: 1
  181. story: 1
  182. story,: 1
  183. surprise: 1
  184. sweetmeats: 1
  185. tale,: 1
  186. tears: 1
  187. that: 3
  188. the: 26
  189. them: 1
  190. there: 1
  191. they: 7
  192. thinking: 1
  193. to: 3
  194. together!: 1
  195. took: 1
  196. toys: 1
  197. trembling: 1
  198. turf.: 1
  199. unfolding: 1
  200. was: 2
  201. water: 1
  202. way: 1
  203. what: 1
  204. where: 1
  205. where,: 1
  206. which: 2
  207. white,: 1
  208. who: 4
  209. whole: 1
  210. window: 1
  211. with: 3
  212. withered: 1
  213. woe.: 1
  214. women: 1
  215. would: 3
spark home:Optional.of(/usr/lib/cloud/spark/spark-0.9.0-incubating-bin-hadoop2)Look! at the window there leans an old maid. She plucks thewithered leaf from the balsam, and looks at the grass-covered rampart,on which many children are playing. What is the old maid thinkingof? A whole life drama is unfolding itself before her inward gaze."The poor little children, how happy they are- how merrily theyplay and romp together! What red cheeks and what angels' eyes! butthey have no shoes nor stockings. They dance on the green rampart,just on the place where, according to the old story, the ground alwayssank in, and where a sportive, frolicsome child had been lured bymeans of flowers, toys and sweetmeats into an open grave ready dug forit, and which was afterwards closed over the child; and from thatmoment, the old story says, the ground gave way no longer, the moundremained firm and fast, and was quickly covered with the green turf.The little people who now play on that spot know nothing of the oldtale, else would they fancy they heard a child crying deep below theearth, and the dewdrops on each blade of grass would be to themtears of woe. Nor do they know anything of the Danish King who here,in the face of the coming foe, took an oath before all his tremblingcourtiers that he would hold out with the citizens of his capital, anddie here in his nest; they know nothing of the men who have foughthere, or of the women who from here have drenched with boiling waterthe enemy, clad in white, and 'biding in the snow to surprise thecity.
--------------next filter's  result------------------"The poor little children, how happy they are- how merrily they
they have no shoes nor stockings. They dance on the green rampart,
tale, else would they fancy they heard a child crying deep below the
tears of woe. Nor do they know anything of the Danish King who here,
die here in his nest; they know nothing of the men who have fought
-------------next sample-------------------"The poor little children, how happy they are- how merrily theyit, and which was afterwards closed over the child; and from that
in the face of the coming foe, took an oath before all his trembling
----------next sort----------------------
: 27
"The: 1
'biding: 1
A: 1
Danish: 1
King: 1
Look!: 1
Nor: 1
She: 1
The: 1
They: 1
What: 2
a: 2
according: 1
afterwards: 1
all: 1
always: 1
an: 3
and: 12
angels': 1
anything: 1
are: 1
are-: 1
at: 2
balsam,: 1
be: 1
been: 1
before: 2
below: 1
blade: 1
boiling: 1
but: 1
by: 1
capital,: 1
cheeks: 1
child: 2
child;: 1
children: 1
children,: 1
citizens: 1
city.: 1
clad: 1
closed: 1
coming: 1
courtiers: 1
covered: 1
crying: 1
dance: 1
deep: 1
dewdrops: 1
die: 1
do: 1
drama: 1
drenched: 1
dug: 1
each: 1
earth,: 1
else: 1
enemy,: 1
eyes!: 1
face: 1
fancy: 1
fast,: 1
firm: 1
flowers,: 1
foe,: 1
for: 1
fought: 1
frolicsome: 1
from: 3
gave: 1
gaze.: 1
grass: 1
grass-covered: 1
grave: 1
green: 2
ground: 2
had: 1
happy: 1
have: 3
he: 1
heard: 1
her: 1
here: 2
here,: 2
his: 3
hold: 1
how: 2
in: 4
in,: 1
into: 1
inward: 1
is: 2
it,: 1
itself: 1
just: 1
know: 3
leaf: 1
leans: 1
life: 1
little: 2
longer,: 1
looks: 1
lured: 1
maid: 1
maid.: 1
many: 1
means: 1
men: 1
merrily: 1
moment,: 1
mound: 1
nest;: 1
no: 2
nor: 1
nothing: 2
now: 1
oath: 1
of: 9
of?: 1
old: 5
on: 5
open: 1
or: 1
out: 1
over: 1
people: 1
place: 1
play: 2
playing.: 1
plucks: 1
poor: 1
quickly: 1
rampart,: 2
ready: 1
red: 1
remained: 1
romp: 1
sank: 1
says,: 1
shoes: 1
snow: 1
sportive,: 1
spot: 1
stockings.: 1
story: 1
story,: 1
surprise: 1
sweetmeats: 1
tale,: 1
tears: 1
that: 3
the: 26
them: 1
there: 1
they: 7
thinking: 1
to: 3
together!: 1
took: 1
toys: 1
trembling: 1
turf.: 1
unfolding: 1
was: 2
water: 1
way: 1
what: 1
where: 1
where,: 1
which: 2
white,: 1
who: 4
whole: 1
window: 1
with: 3
withered: 1
woe.: 1
women: 1
would: 3

用java编写spark程序,简单示例及运行相关推荐

  1. 如何在IDEA上编写Spark程序?(本地+集群+java三种模式书写代码)

    本篇博客,Alice为大家带来关于如何在IDEA上编写Spark程序的教程. 文章目录 写在前面 准备材料 图解WordCount pom.xml 本地执行 集群上运行 Java8版[了解] 写在前面 ...

  2. java编写应用程序_为您的Java应用程序编写数据驱动的测试

    java编写应用程序 JUnit是一个功能非常强大的测试框架,它不仅为其用户提供了编写快速简便的测试的功能,而且还为用户提供了扩展它并使其按其期望的方式工作的机会. 在JUnit之上构建了许多框架,这 ...

  3. 在IntelliJ IDEA中创建和运行java/scala/spark程序

    本文将分两部分来介绍如何在IntelliJ IDEA中运行Java/Scala/Spark程序: 基本概念介绍 在IntelliJ IDEA中创建和运行java/scala/spark程序 基本概念介 ...

  4. java编写应用程序_使用Java API编写应用程序

    java编写应用程序 总览 介绍 DB2JSON可用于DB2 Linux,Unix和Windows 10.5以及用于z / OS V3.1的IBM DB2 Accessories Suite与DB2 ...

  5. 使用Scala编写Spark程序求基站下移动用户停留时长TopN

    使用Scala编写Spark程序求基站下移动用户停留时长TopN 1. 需求:根据手机基站日志计算停留时长的TopN 我们的手机之所以能够实现移动通信,是因为在全国各地有许许多多的基站,只要手机一开机 ...

  6. 用java编写验证码程序_编写,验证和分析实时Java应用程序

    本文是" 用实时Java开发"系列的第三篇也是最后一部分,展示了如何设计,编写,验证和分析基本的实时应用程序. 我们将说明: 应用程序的时间和性能要求. 为什么传统的非实时Java ...

  7. 好程序员大数据教程:SparkShell和IDEA中编写Spark程序

    好程序员大数据教程:SparkShell和IDEA中编写Spark程序,spark-shell是Spark自带的交互式Shell程序,方便用户进行交互式编程,用户可以在该命令行下用Scala编写Spa ...

  8. Java搭建Spark程序,提交到Yarn

    文章目录 Java搭建Spark程序,提交到Yarn测试 Demo Java搭建Spark程序,提交到Yarn测试 Demo pow文件依赖 <?xml version="1.0&qu ...

  9. Java TCP 抓包简单示例

    Java TCP 抓包简单示例 由于目前网上没有一篇能真正方便读者操作的此类文章,本文对此通过示例做个简单介绍. 缘起 有一天本来在看头条,然后看到一则游戏的广告,看画面可能是我喜欢的建造类型(纪元1 ...

最新文章

  1. centos7上搭建http服务器以及设置目录访问
  2. 安卓程序员永远不懂iOS程序员的痛? | 每日趣闻
  3. 第01课:深度学习概述
  4. Blazor.Server以正确的方式集成Ids4
  5. C++primer第十一章 关联容器 11.3关联容器操作 11.4 无序容器
  6. Nagios(八)—— Nagios Web 端管理工具Nagiosql
  7. unity三维地图的经纬度如何在二维地图上表示_安全数据分析:数据点—地图—线性回归...
  8. SQL注入漏洞 攻击
  9. ASO优化续:详解appstore的排名规则
  10. 多项式求值秦九韶算法
  11. Html5 css3 导航箭头,HTML – CSS3导航箭头
  12. 什么是次世代游戏?次世代游戏前景怎么样?
  13. 【React Native】react-native-vector-icons用法避坑
  14. 计算机打印机安装步骤,打印机安装步骤
  15. 氧含量测量方法:燃料电池法
  16. 计算机编程英语发音,计算机编程常用英语
  17. EasyUI 系列之 combobox 默认选中第一个 添加请选择选项
  18. html正则表达式验证字母,正则表达式校验字母和字符串组合
  19. Outlook Connector用途
  20. 什么是DDOS高防IP

热门文章

  1. Stata分享:一个在线-Stata-教程网站
  2. 音视频最新技术有哪些
  3. java163邮箱服务器地址,JavaEmail发送网易163邮箱和QQ邮箱
  4. 3 个鲜为人知的 Python 特性
  5. SCAU 猜数字游戏
  6. ORA-01653: unable to extend table OGGADM.GGS_MARKER by 8192 in tablespace OGG
  7. 思绪尘埃梦婉花舞,心事微风彩蝶翩跹
  8. 【干货】阿里创业史内部视频开放,55分钟超强震撼!
  9. cherry机械键盘维修记
  10. floyed 算法计算最短路径