Skip to content

Commit

Permalink
[MINOR] Fix bugs in lineage tracing
Browse files Browse the repository at this point in the history
This patch fixes bugs in lineage tracing code and adds support
for missing instructions.
  • Loading branch information
phaniarnab committed Sep 2, 2021
1 parent bebfd41 commit 4497199
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
Expand Up @@ -47,6 +47,7 @@
import org.apache.sysds.runtime.instructions.cp.ListObject;
import org.apache.sysds.runtime.instructions.cp.ScalarObject;
import org.apache.sysds.runtime.instructions.cp.ScalarObjectFactory;
import org.apache.sysds.runtime.lineage.LineageItem;
import org.apache.sysds.runtime.matrix.data.MatrixBlock;
import org.apache.sysds.utils.Statistics;

Expand Down Expand Up @@ -81,7 +82,7 @@ protected static void rReplaceLiterals( Hop hop, ExecutionContext ec, boolean sc
lit = (lit==null) ? replaceLiteralFullUnaryAggregateRightIndexing(c, vars) : lit;
lit = (lit==null) ? replaceTReadMatrixFromList(c, ec) : lit;
lit = (lit==null) ? replaceTReadMatrixFromListAppend(c, ec) : lit;
lit = (lit==null) ? replaceTReadMatrixLookupFromList(c, vars) : lit;
lit = (lit==null) ? replaceTReadMatrixLookupFromList(c, ec) : lit;
lit = (lit==null) ? replaceTReadScalarLookupFromList(c, vars) : lit;
}

Expand Down Expand Up @@ -385,8 +386,9 @@ private static NaryOp replaceTReadMatrixFromListAppend( Hop c, ExecutionContext
return ret;
}

private static DataOp replaceTReadMatrixLookupFromList( Hop c, LocalVariableMap vars ) {
private static DataOp replaceTReadMatrixLookupFromList( Hop c, ExecutionContext ec) {
//pattern: as.matrix(X[i:i]) or as.matrix(X['a','a']) with X being a list
LocalVariableMap vars = ec.getVariables();
DataOp ret = null;
if( HopRewriteUtils.isUnary(c, OpOp1.CAST_AS_MATRIX)
&& c.getInput().get(0) instanceof IndexingOp ) {
Expand All @@ -402,7 +404,11 @@ private static DataOp replaceTReadMatrixLookupFromList( Hop c, LocalVariableMap
LiteralOp lit = (LiteralOp) ix.getInput().get(1);
MatrixObject mo = (MatrixObject) (!lit.getValueType().isNumeric() ?
list.slice(lit.getName()) : list.slice((int)lit.getLongValue()-1));
LineageItem li = !lit.getValueType().isNumeric() ?
list.getLineageItem(lit.getName()) : list.getLineageItem((int)lit.getLongValue()-1);
vars.put(varname, mo);
if (DMLScript.LINEAGE)
ec.getLineage().set(varname, li);
ret = HopRewriteUtils.createTransientRead(varname, c);
}
}
Expand Down
Expand Up @@ -528,6 +528,16 @@ public Pair<String, LineageItem> getLineageItem(ExecutionContext ec) {
tmpInstStr = replaceNonLiteral(tmpInstStr, seq_incr, 7, ec);
break;
}
case FRAMEINIT: {
tmpInstStr = InstructionUtils.replaceOperandName(tmpInstStr);
CPOperand frameInp = new CPOperand(frame_data, ValueType.STRING, DataType.SCALAR, true);
tmpInstStr = InstructionUtils.replaceOperand(tmpInstStr, 2, frameInp.getLineageLiteral());
tmpInstStr = replaceNonLiteral(tmpInstStr, rows, 3, ec);
tmpInstStr = replaceNonLiteral(tmpInstStr, cols, 4, ec);
CPOperand schemaInp = new CPOperand(schema, ValueType.STRING, DataType.SCALAR, true);
tmpInstStr = !schema.equalsIgnoreCase("NULL")
? InstructionUtils.replaceOperand(tmpInstStr, 5, schemaInp.getLineageLiteral()) : tmpInstStr;
}
case TIME:
// only opcode (time) is sufficient to compute from lineage.
break;
Expand Down
Expand Up @@ -313,8 +313,9 @@ private boolean reuseFunctionOutputs(LineageItem[] liInputs, FunctionProgramBloc
return reuse;
}

private static String getCacheFunctionName(String fname, FunctionProgramBlock fpb) {
return !fpb.hasThreadID() ? fname :
private String getCacheFunctionName(String fname, FunctionProgramBlock fpb) {
String tmpFname = !fpb.hasThreadID() ? fname :
fname.substring(0, fname.lastIndexOf(Lop.CP_CHILD_THREAD+fpb.getThreadID()));
return DMLProgram.constructFunctionKey(_namespace, tmpFname);
}
}

0 comments on commit 4497199

Please sign in to comment.