blob: 5f729d37447990afe68a4223aa5e83e8d4c8da16 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.sysds.test.functions.lineage;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.junit.Test;
import org.apache.sysds.runtime.controlprogram.caching.MatrixObject;
import org.apache.sysds.runtime.instructions.cp.Data;
import org.apache.sysds.runtime.lineage.Lineage;
import org.apache.sysds.runtime.lineage.LineageRecomputeUtils;
import org.apache.sysds.runtime.matrix.data.MatrixBlock;
import org.apache.sysds.runtime.matrix.data.MatrixValue.CellIndex;
import org.apache.sysds.test.AutomatedTestBase;
import org.apache.sysds.test.TestConfiguration;
import org.apache.sysds.test.TestUtils;
public class LineageTraceDedupExecTest extends AutomatedTestBase {
protected static final String TEST_DIR = "functions/lineage/";
protected static final String TEST_NAME1 = "LineageTraceDedupExec1";
protected static final String TEST_NAME10 = "LineageTraceDedupExec10";
protected static final String TEST_NAME2 = "LineageTraceDedupExec2";
protected String TEST_CLASS_DIR = TEST_DIR + LineageTraceDedupExecTest.class.getSimpleName() + "/";
protected static final int numRecords = 10;
protected static final int numFeatures = 5;
@Override
public void setUp() {
TestUtils.clearAssertionInformation();
addTestConfiguration(TEST_NAME1, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME1));
addTestConfiguration(TEST_NAME10, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME10));
addTestConfiguration(TEST_NAME2, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME2));
}
@Test
public void testLineageTraceExec1() {
testLineageTraceExec(TEST_NAME1);
}
@Test
public void testLineageTraceExec10() {
testLineageTraceExec(TEST_NAME10);
}
@Test
public void testLineageTraceExec2() {
testLineageTraceExec(TEST_NAME2);
}
private void testLineageTraceExec(String testname) {
System.out.println("------------ BEGIN " + testname + "------------");
getAndLoadTestConfiguration(testname);
List<String> proArgs = new ArrayList<>();
proArgs.add("-lineage");
proArgs.add("dedup");
proArgs.add("-stats");
proArgs.add("-args");
proArgs.add(output("R"));
proArgs.add(String.valueOf(numRecords));
proArgs.add(String.valueOf(numFeatures));
programArgs = proArgs.toArray(new String[proArgs.size()]);
fullDMLScriptName = getScript();
Lineage.resetInternalState();
//run the test
runTest(true, EXCEPTION_NOT_EXPECTED, null, -1);
//get lineage and generate program
String Rtrace = readDMLLineageFromHDFS("R");
String RDedupPatches = readDMLLineageDedupFromHDFS("R");
Data ret = LineageRecomputeUtils.parseNComputeLineageTrace(Rtrace, RDedupPatches);
HashMap<CellIndex, Double> dmlfile = readDMLMatrixFromHDFS("R");
MatrixBlock tmp = ((MatrixObject)ret).acquireReadAndRelease();
TestUtils.compareMatrices(dmlfile, tmp, 1e-6);
}
}