こんにちはスカラーのマップメソッドに "for"を使いたいです。スカラを使ってSparkを使ってループにマップする方法
どうすればいいですか?例えば
ここでは、各ラインの私は、ランダムな単語を生成したい読み:
val rdd = file.map(line => (line,{
val chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
val word = new String;
val res = new String;
val rnd = new Random;
val len = 4 + rnd.nextInt((6-4)+1);
for(i <- 1 to len){
val char = chars(rnd.nextInt(51));
word.concat(char.toString);
}
word;
}))
を私の現在の出力は、次のとおりです。
Array[(String, String)] = Array((1,""), (2,""), (3,""), (4,""), (5,""), (6,""), (7,""), (8,""), (9,""), (10,""), (11,""), (12,""), (13,""), (14,""), (15,""), (16,""), (17,""), (18,""), (19,""), (20,""), (21,""), (22,""), (23,""), (24,""), (25,""), (26,""), (27,""), (28,""), (29,""), (30,""), (31,""), (32,""), (33,""), (34,""), (35,""), (36,""), (37,""), (38,""), (39,""), (40,""), (41,""), (42,""), (43,""), (44,""), (45,""), (46,""), (47,""), (48,""), (49,""), (50,""), (51,""), (52,""), (53,""), (54,""), (55,""), (56,""), (57,""), (58,""), (59,""), (60,""), (61,""), (62,""), (63,""), (64,""), (65,""), (66,""), (67,""), (68,""), (69,""), (70,""), (71,""), (72,""), (73,""), (74,""), (75,""), (76,""), (77,""), (78,""), (79,""), (80,""), (81,""), (82,""), (83,""), (84,""), (85,""), (86...
右側が空になった理由を私は知りません。
:値+ =は、あなたが宣言する必要が+ = char.toString – user7375007
文字列 単語のメンバーではありません
は、このようにあなたは、このような何かを得るでしょう'word'を変数として使用します。 'val'の代わりに' word'の前に 'var'キーワードがあることに注意してください。これは不変です。 – Psidom
ええ、あなたは本当に多くのthxです! – user7375007