Spark Java错误打印数组列表

时间:2018-04-18 02:58:24

标签: java apache-spark spark-java

我使用Spark with Java从我存储在文档中的文本文件中读取文件。 然后我逐字逐句拆分文件。

但是当我打印出来的话时

[[Ljava.lang.String;@2819c460]
[[Ljava.lang.String;@30364216]
[[Ljava.lang.String;@38bb9d7a]
[[Ljava.lang.String;@1e8ab90f]
[[Ljava.lang.String;@78d6447a]

以下是我的代码

JavaRDD<String> documents = sc.textFile(path, 1000);
        
        JavaRDD<ArrayList<String[]>> lines = documents.map(document -> {
        	return document.split("\\r?\\n");
        }).map(_lines -> {


			ArrayList<String[]> parsedLines = new ArrayList<>();

			Arrays.asList(_lines).stream().parallel().forEach(line -> {
				parsedLines.add(line.split("\\t"));
			});
			return parsedLines;

        });

        lines.take(5).forEach(column -> {
        		System.out.println(column);
        });

System.out.println(Arrays.toString(column))给出了这个错误:

Error:(62, 50) java: no suitable method found for toString(java.util.ArrayList<java.lang.String[]>)
    method java.util.Arrays.toString(long[]) is not applicable
      (argument mismatch; java.util.ArrayList<java.lang.String[]> cannot be converted to long[])
    method java.util.Arrays.toString(int[]) is not applicable
      (argument mismatch; java.util.ArrayList<java.lang.String[]> cannot be converted to int[])
    method java.util.Arrays.toString(short[]) is not applicable
      (argument mismatch; java.util.ArrayList<java.lang.String[]> cannot be converted to short[])
    method java.util.Arrays.toString(char[]) is not applicable
      (argument mismatch; java.util.ArrayList<java.lang.String[]> cannot be converted to char[])
    method java.util.Arrays.toString(byte[]) is not applicable
      (argument mismatch; java.util.ArrayList<java.lang.String[]> cannot be converted to byte[])
    method java.util.Arrays.toString(boolean[]) is not applicable
      (argument mismatch; java.util.ArrayList<java.lang.String[]> cannot be converted to boolean[])
    method java.util.Arrays.toString(float[]) is not applicable
      (argument mismatch; java.util.ArrayList<java.lang.String[]> cannot be converted to float[])
    method java.util.Arrays.toString(double[]) is not applicable
      (argument mismatch; java.util.ArrayList<java.lang.String[]> cannot be converted to double[])
    method java.util.Arrays.toString(java.lang.Object[]) is not applicable
      (argument mismatch; java.util.ArrayList<java.lang.String[]> cannot be converted to java.lang.Object[])

0 个答案:

没有答案