[SYSTEMDS-151] Removing deprecation in test code
Resolving JIRA issue https://issues.apache.org/jira/browse/SYSTEMDS-151
diff --git a/src/test/java/org/apache/sysds/test/AutomatedTestBase.java b/src/test/java/org/apache/sysds/test/AutomatedTestBase.java
index d802997..3c3b85b 100644
--- a/src/test/java/org/apache/sysds/test/AutomatedTestBase.java
+++ b/src/test/java/org/apache/sysds/test/AutomatedTestBase.java
@@ -94,7 +94,6 @@
* </ul>
*
*/
-@SuppressWarnings("deprecation")
public abstract class AutomatedTestBase {
private static final Log LOG = LogFactory.getLog(AutomatedTestBase.class.getName());
@@ -997,25 +996,6 @@
}
/**
- * <p>
- * Loads a test configuration with its parameters. Adds the output directories to the output list as well as to the
- * list of possible comparison files.
- * </p>
- *
- * @param configurationName test configuration name
- *
- */
- @Deprecated
- protected void loadTestConfiguration(String configurationName) {
- if(!availableTestConfigurations.containsKey(configurationName))
- fail("test configuration not available: " + configurationName);
-
- TestConfiguration config = availableTestConfigurations.get(configurationName);
-
- loadTestConfiguration(config);
- }
-
- /**
* Runs an R script, default to the old way
*/
protected void runRScript() {
diff --git a/src/test/java/org/apache/sysds/test/TestUtils.java b/src/test/java/org/apache/sysds/test/TestUtils.java
index 6a7d8e6..1755e89 100644
--- a/src/test/java/org/apache/sysds/test/TestUtils.java
+++ b/src/test/java/org/apache/sysds/test/TestUtils.java
@@ -60,6 +60,7 @@
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.SequenceFile;
+import org.apache.hadoop.io.SequenceFile.Writer;
import org.apache.sysds.common.Types.FileFormat;
import org.apache.sysds.common.Types.ValueType;
import org.apache.sysds.runtime.data.TensorBlock;
@@ -461,11 +462,12 @@
/**
* Reads values from a matrix file in HDFS in DML format
- *
- * @deprecated You should not use this method, it is recommended to use the
- * corresponding method in AutomatedTestBase
- * @param filePath
- * @return
+ *
+ * NOTE: For reading the output of a matrix produced by a JUnit test, use the convenience
+ * function {@link AutomatedTestBase#readDMLMatrixFromHDFS(String)}
+ *
+ * @param filePath Path to the file to be read.
+ * @return Matrix values in a hashmap <index,value>
*/
public static HashMap<CellIndex, Double> readDMLMatrixFromHDFS(String filePath)
{
@@ -491,12 +493,12 @@
/**
* Reads values from a matrix file in OS's FS in R format
- *
- * @deprecated You should not use this method, it is recommended to use the
- * corresponding method in AutomatedTestBase
- *
- * @param filePath
- * @return
+ *
+ * NOTE: For reading the output of a matrix produced by a R validation code of a JUnit test, use the convenience
+ * function {@link AutomatedTestBase#readRMatrixFromFS(String)}
+ *
+ * @param filePath Path to the file to be read.
+ * @return Matrix values in a hashmap <index,value>
*/
public static HashMap<CellIndex, Double> readRMatrixFromFS(String filePath)
{
@@ -2083,10 +2085,11 @@
SequenceFile.Writer writer = null;
try {
Path path = new Path(file);
- FileSystem fs = IOUtilFunctions.getFileSystem(path, conf);
- writer = new SequenceFile.Writer(fs, conf, path,
- MatrixIndexes.class, MatrixCell.class);
-
+ Writer.Option filePath = Writer.file(path);
+ Writer.Option keyClass = Writer.keyClass(MatrixIndexes.class);
+ Writer.Option valueClass = Writer.valueClass(MatrixBlock.class);
+ Writer.Option compression = Writer.compression(SequenceFile.CompressionType.NONE);
+ writer = SequenceFile.createWriter(conf, filePath, keyClass, valueClass, compression);
MatrixIndexes index = new MatrixIndexes();
MatrixCell value = new MatrixCell();
for (int i = 0; i < matrix.length; i++) {
@@ -2131,10 +2134,11 @@
try {
Path path = new Path(file);
- FileSystem fs = IOUtilFunctions.getFileSystem(path, conf);
- writer = new SequenceFile.Writer(fs, conf, path,
- MatrixIndexes.class, MatrixBlock.class);
-
+ Writer.Option filePath = Writer.file(path);
+ Writer.Option keyClass = Writer.keyClass(MatrixIndexes.class);
+ Writer.Option valueClass = Writer.valueClass(MatrixBlock.class);
+ Writer.Option compression = Writer.compression(SequenceFile.CompressionType.NONE);
+ writer = SequenceFile.createWriter(conf, filePath, keyClass, valueClass, compression);
MatrixIndexes index = new MatrixIndexes();
MatrixBlock value = new MatrixBlock();
for (int i = 0; i < matrix.length; i += rowsInBlock) {
@@ -2142,7 +2146,7 @@
for (int j = 0; j < matrix[i].length; j += colsInBlock) {
int cols = Math.min(colsInBlock, (matrix[i].length - j));
index.setIndexes(((i / rowsInBlock) + 1), ((j / colsInBlock) + 1));
- value = new MatrixBlock(rows, cols, sparseFormat);
+ value.reset(rows, cols, sparseFormat);
for (int k = 0; k < rows; k++) {
for (int l = 0; l < cols; l++) {
value.setValue(k, l, matrix[i + k][j + l]);
diff --git a/src/test/java/org/apache/sysds/test/functions/parfor/misc/ParForAdversarialLiteralsTest.java b/src/test/java/org/apache/sysds/test/functions/parfor/misc/ParForAdversarialLiteralsTest.java
index cbd755b..afeab47 100644
--- a/src/test/java/org/apache/sysds/test/functions/parfor/misc/ParForAdversarialLiteralsTest.java
+++ b/src/test/java/org/apache/sysds/test/functions/parfor/misc/ParForAdversarialLiteralsTest.java
@@ -100,11 +100,9 @@
runLiteralTest(TEST_NAME4b);
}
- @SuppressWarnings("deprecation")
private void runLiteralTest( String testName )
{
- String TEST_NAME = testName;
- TestConfiguration config = getTestConfiguration(TEST_NAME);
+ TestConfiguration config = getTestConfiguration(testName);
config.addVariable("rows", rows);
config.addVariable("cols", cols);
loadTestConfiguration(config);
@@ -114,18 +112,17 @@
String IN = "A";
String OUT = (testName.equals(TEST_NAME1a)||testName.equals(TEST_NAME1b))?Lop.CP_ROOT_THREAD_ID:"B";
- fullDMLScriptName = HOME + TEST_NAME + ".dml";
+ fullDMLScriptName = HOME + testName + ".dml";
programArgs = new String[]{"-args", input(IN),
Integer.toString(rows), Integer.toString(cols), output(OUT) };
- fullRScriptName = HOME + TEST_NAME + ".R";
+ fullRScriptName = HOME + testName + ".R";
rCmd = "Rscript" + " " + fullRScriptName + " " + inputDir() + " " + expectedDir();
double[][] A = getRandomMatrix(rows, cols, 0, 1, sparsity, 7);
writeInputMatrix("A", A, false);
- boolean exceptionExpected = false;
- runTest(true, exceptionExpected, null, -1);
+ runTest(true, false, null, -1);
//compare matrices
HashMap<CellIndex, Double> dmlin = TestUtils.readDMLMatrixFromHDFS(input(IN));