}
// Play area
public static void main(String[] args) {
final JavaSparkContext sc = new JavaSparkContext("local[1]", "optiq");
final JavaRDD<String> file = sc.textFile("/usr/share/dict/words");
System.out.println(
file.map(
new Function<String, Object>() {
@Override
public Object call(String s) throws Exception {
return s.substring(0, Math.min(s.length(), 1));
}
}).distinct().count());
file.cache();
String s =
file.groupBy(
new Function<String, String>() {
@Override
public String call(String s) throws Exception {
return s.substring(0, Math.min(s.length(), 1));
}
}
//CHECKSTYLE: IGNORE 1
).map(
new Function<Tuple2<String, List<String>>, Object>() {
@Override
public Object call(Tuple2<String, List<String>> pair) {
return pair._1() + ":" + pair._2().size();
}
}).collect().toString();
System.out.print(s);
final JavaRDD<Integer> rdd = sc.parallelize(
new AbstractList<Integer>() {
final Random random = new Random();
@Override
public Integer get(int index) {
System.out.println("get(" + index + ")");