, : -Dsun.io.serialization.extendedDebugInfo=true , .
, . A JavaSparkContext ( , ). , , Function , , . , , , , JavaSparkContext, , . , , JavaSparkContext , .
, , JavaSparkContext , - ( ), . , , JavaSparkContext :
public static void main(String[] args) {
JavaSparkContext sc = new JavaSparkContext();
JavaRDD<String> csv = sc.textFile("data/matrix.csv").cache();
JavaRDD<IndexedRow> entries = csv.zipWithIndex().map(
new Function<scala.Tuple2<String, Long>, IndexedRow>() {
private static final long serialVersionUID = 4795273163954440089L;
@Override
public IndexedRow call(Tuple2<String, Long> tuple)
throws Exception {
String line = tuple._1;
long index = tuple._2;
String[] strings = line.split(",");
double[] doubles = new double[strings.length];
for (int i = 0; i < strings.length; i++) {
doubles[i] = Double.parseDouble(strings[i]);
}
Vector v = new DenseVector(doubles);
return new IndexedRow(index, v);
}
});
}
, , , , serialVersionUID ( - ).