Skip to content

Commit 327a91d

Browse files
committed
[SYSTEMDS-3816] Fix missing removal of list crc files in local FS
The list writer was corrupted a while ago, and did no longer properly remove the crc files of the list directory and individual files in local file system.
1 parent 751b55f commit 327a91d

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/main/java/org/apache/sysds/runtime/io/ListWriter.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919

2020
package org.apache.sysds.runtime.io;
2121

22+
import org.apache.hadoop.fs.Path;
23+
import org.apache.hadoop.mapred.JobConf;
2224
import org.apache.sysds.common.Types.FileFormat;
25+
import org.apache.sysds.conf.ConfigurationManager;
2326
import org.apache.sysds.conf.DMLConfig;
2427
import org.apache.sysds.runtime.DMLRuntimeException;
2528
import org.apache.sysds.runtime.controlprogram.caching.CacheableData;
@@ -52,6 +55,7 @@ public static void writeListToHDFS(ListObject lo, String fname, String fmtStr, F
5255

5356
try {
5457
//write basic list meta data
58+
JobConf job = new JobConf(ConfigurationManager.getCachedJobConf());
5559
HDFSTool.writeMetaDataFile(fname + ".mtd", lo.getValueType(), null,
5660
lo.getDataType(), dc, FileFormat.safeValueOf(fmtStr), props);
5761

@@ -64,13 +68,18 @@ public static void writeListToHDFS(ListObject lo, String fname, String fmtStr, F
6468
for(int i=0; i<lo.getLength(); i++) {
6569
Data dat = lo.getData(i);
6670
String lfname = fname +"/"+i+"_"+(lo.isNamedList()?lo.getName(i):"null");
67-
if( dat instanceof CacheableData<?> )
71+
if( dat instanceof CacheableData<?> ) {
6872
((CacheableData<?>)dat).exportData(lfname, fmtStr, props);
73+
IOUtilFunctions.deleteCrcFilesFromLocalFileSystem(job, new Path(lfname));
74+
}
6975
else if( dat instanceof ListObject )
7076
writeListToHDFS((ListObject)dat, lfname, fmtStr, props);
7177
else //scalar
7278
HDFSTool.writeScalarToHDFS((ScalarObject)dat, lfname);
7379
}
80+
81+
//remove crc file of list directory
82+
IOUtilFunctions.deleteCrcFilesFromLocalFileSystem(job, new Path(fname));
7483
}
7584
catch(Exception ex) {
7685
throw new DMLRuntimeException(

src/test/java/org/apache/sysds/test/functions/io/ReadWriteListTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ private void runListReadWriteTest(boolean named, FileFormat format, ExecMode mod
111111
double val1 = HDFSTool.readDoubleFromHDFSFile(output("R1"));
112112

113113
//check no crc files
114-
// I have removed this check since i modified the removal of .crc files to a remove on close
115-
// File[] files = new File(output("L")).listFiles();
116-
// LOG.error(Arrays.toString(files));
117-
// Assert.assertFalse(Arrays.stream(files).anyMatch(f -> f.getName().endsWith(".crc")));
114+
//disabled due to delete on exist, but for temporary validation via delete
115+
//File[] files = new File(output("L")).listFiles();
116+
//LOG.error(Arrays.toString(files));
117+
//Assert.assertFalse(Arrays.stream(files).anyMatch(f -> f.getName().endsWith(".crc")));
118118

119119
//run read
120120
fullDMLScriptName = HOME + TEST_NAME2 + ".dml";

0 commit comments

Comments
 (0)