|
26 | 26 |
|
27 | 27 | import org.apache.commons.lang3.StringUtils; |
28 | 28 | import org.apache.commons.lang3.tuple.Pair; |
29 | | -import org.apache.hadoop.fs.Options; |
30 | 29 | import org.apache.sysds.api.DMLScript; |
31 | | -import org.apache.sysds.api.mlcontext.MatrixMetadata; |
32 | 30 | import org.apache.sysds.common.Opcodes; |
33 | 31 | import org.apache.sysds.common.Types.DataType; |
34 | 32 | import org.apache.sysds.common.Types.FileFormat; |
|
50 | 48 | import org.apache.sysds.runtime.instructions.Instruction; |
51 | 49 | import org.apache.sysds.runtime.instructions.InstructionUtils; |
52 | 50 | import org.apache.sysds.runtime.instructions.spark.data.IndexedMatrixValue; |
53 | | -import org.apache.sysds.runtime.io.*; |
| 51 | +import org.apache.sysds.runtime.io.FileFormatProperties; |
| 52 | +import org.apache.sysds.runtime.io.FileFormatPropertiesCSV; |
| 53 | +import org.apache.sysds.runtime.io.FileFormatPropertiesHDF5; |
| 54 | +import org.apache.sysds.runtime.io.FileFormatPropertiesLIBSVM; |
| 55 | +import org.apache.sysds.runtime.io.ListReader; |
| 56 | +import org.apache.sysds.runtime.io.ListWriter; |
| 57 | +import org.apache.sysds.runtime.io.MatrixWriter; |
| 58 | +import org.apache.sysds.runtime.io.MatrixWriterFactory; |
| 59 | +import org.apache.sysds.runtime.io.WriterHDF5; |
| 60 | +import org.apache.sysds.runtime.io.WriterMatrixMarket; |
| 61 | +import org.apache.sysds.runtime.io.WriterTextCSV; |
54 | 62 | import org.apache.sysds.runtime.lineage.LineageItem; |
55 | 63 | import org.apache.sysds.runtime.lineage.LineageItemUtils; |
56 | 64 | import org.apache.sysds.runtime.lineage.LineageTraceable; |
57 | 65 | import org.apache.sysds.runtime.matrix.data.MatrixBlock; |
| 66 | +import org.apache.sysds.runtime.matrix.data.MatrixIndexes; |
58 | 67 | import org.apache.sysds.runtime.meta.DataCharacteristics; |
59 | 68 | import org.apache.sysds.runtime.meta.MatrixCharacteristics; |
60 | 69 | import org.apache.sysds.runtime.meta.MetaData; |
@@ -1061,31 +1070,25 @@ else if( getInput1().getDataType() == DataType.MATRIX ) { |
1061 | 1070 | LocalTaskQueue<IndexedMatrixValue> stream = mo.getStreamHandle(); |
1062 | 1071 |
|
1063 | 1072 | if (stream != null) { |
1064 | | - System.out.println("Write OOC instruction: " + getInput1().getName() + "to file name: " + fname); |
1065 | 1073 |
|
1066 | 1074 | try { |
1067 | 1075 | IndexedMatrixValue tmp = null; |
1068 | 1076 | MatrixWriter writer = MatrixWriterFactory.createMatrixWriter(fmt); |
1069 | | - System.out.println("mo details: "+ mo.getDataCharacteristics()); |
1070 | | - |
1071 | 1077 |
|
1072 | 1078 | while((tmp = stream.dequeueTask()) != LocalTaskQueue.NO_MORE_TASKS) { |
1073 | 1079 | MatrixBlock mb = (MatrixBlock)tmp.getValue(); |
| 1080 | + MatrixIndexes mi = tmp.getIndexes(); |
1074 | 1081 |
|
| 1082 | + // Construct a unique filename for each part-file inside the output directory |
| 1083 | + String partFilePath = fname + "/part-" + mi.getRowIndex() + "-" + mi.getColumnIndex(); |
1075 | 1084 |
|
1076 | | -// writer.writeMatrixToHDFS(tmp.getValue(), fname, FileFormat.HDF5, mo.getMetaData().getDataCharacteristics()); |
1077 | | - writer.writeMatrixToHDFS(mb, fname, mb.getNumRows(), mb.getNumColumns(), mo.getBlocksize(),mb.getNonZeros()); |
1078 | | -// writer.writeMatrixToHDFS((MatrixBlock)tmp.getValue(), fname, mc.getRows(), mc.getCols(), |
1079 | | -// mc.getBlocksize(), mc.getNonZeros()); |
1080 | | - System.out.println(tmp); |
1081 | | - |
| 1085 | + writer.writeMatrixToHDFS(mb, partFilePath, mb.getNumRows(), mb.getNumColumns(), (int) mb.getLength() , mb.getNonZeros()); |
1082 | 1086 | } |
1083 | | -// IOUtilFunctions.closeSilently(writer); |
1084 | | - HDFSTool.writeMetaDataFile(fname + ".mtd", mo.getValueType(), |
| 1087 | + HDFSTool.writeMetaDataFile(fname + "/.mtd", mo.getValueType(), |
1085 | 1088 | mo.getMetaData().getDataCharacteristics(), FileFormat.HDF5, _formatProperties); |
1086 | 1089 | } |
1087 | 1090 | catch(Exception ex) { |
1088 | | - throw new DMLRuntimeException(ex); |
| 1091 | + throw new DMLRuntimeException("Failed to write OOC stream to " + fname, ex); |
1089 | 1092 | } |
1090 | 1093 | } |
1091 | 1094 | else { |
|
0 commit comments