Package org.apache.sysds.runtime.instructions.cp

## Class VariableCPInstruction

- java.lang.Object
- - org.apache.sysds.runtime.instructions.Instruction
  - - org.apache.sysds.runtime.instructions.cp.CPInstruction
    - - org.apache.sysds.runtime.instructions.cp.VariableCPInstruction

All Implemented Interfaces:
  `LineageTraceable`

    public class VariableCPInstruction
    extends CPInstruction
    implements LineageTraceable

### Nested Class Summary

Nested Classes
`static class` `VariableCPInstruction.VariableOperationCode`

### Nested classes/interfaces inherited from class org.apache.sysds.runtime.instructions.cp.CPInstruction

`CPInstruction.CPType`

### Nested classes/interfaces inherited from class org.apache.sysds.runtime.instructions.Instruction

`Instruction.IType`

### Field Summary

### Fields inherited from class org.apache.sysds.runtime.instructions.Instruction

`DATATYPE_PREFIX, FEDERATED_INST_PREFIX, GPU_INST_PREFIX, INSTRUCTION_DELIM, LITERAL_PREFIX, OPERAND_DELIM, SP_INST_PREFIX, VALUETYPE_PREFIX`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `addInput​(CPOperand input)`
`FileFormatProperties` `getFormatProperties()`
`CPOperand` `getInput​(int index)`
`CPOperand` `getInput1()`
`CPOperand` `getInput2()`
`CPOperand` `getInput3()`
`CPOperand` `getInput4()`
`List<CPOperand>` `getInputs()`
`org.apache.commons.lang3.tuple.Pair<String,​LineageItem>` `getLineageItem​(ExecutionContext ec)` Obtain lineage trace of an instruction with a single output.
`MetaData` `getMetaData()`
`CPOperand` `getOutput()`
`String` `getOutputVariableName()`
`static String` `getUniqueFileName​(String fname)`
`VariableCPInstruction.VariableOperationCode` `getVariableOpcode()`
`boolean` `isAssignOrCopyVariable()`
`boolean` `isAssignVariable()`
`boolean` `isCreateVariable()`
`boolean` `isMoveVariable()`
`boolean` `isRemoveVariable()`
`boolean` `isRemoveVariable​(String varName)` Checks if this instruction is a remove instruction for varName
`boolean` `isRemoveVariableNoFile()`
`boolean` `isVariableCastInstruction()`
`static VariableCPInstruction` `parseInstruction​(String str)`
`static Instruction` `prepareCopyInstruction​(String srcVar, String destVar)`
`static Instruction` `prepareRemoveInstruction​(long... varName)`
`static Instruction` `prepareRemoveInstruction​(String... varNames)`
`static Instruction` `prepCreatevarInstruction​(String varName, String fileName, boolean fNameOverride, String format)`
`static Instruction` `prepCreatevarInstruction​(String varName, String fileName, boolean fNameOverride, Types.DataType dt, String format, DataCharacteristics mc, MatrixObject.UpdateType update)`
`static Instruction` `prepCreatevarInstruction​(String varName, String fileName, boolean fNameOverride, Types.DataType dt, String format, DataCharacteristics mc, MatrixObject.UpdateType update, boolean hasHeader, String delim, boolean sparse)`
`static Instruction` `prepMoveInstruction​(String srcVar, String destVar)`
`static Instruction` `prepMoveInstruction​(String srcVar, String destFileName, String format)`
`void` `processInstruction​(ExecutionContext ec)` This method should be used to execute the instruction.
`static void` `processRmvarInstruction​(ExecutionContext ec, String varname)` Remove variable instruction externalized as a static function in order to allow various cleanup procedures to use the same codepath as the actual rmVar instruction
`void` `updateInstructionThreadID​(String pattern, String replace)` All instructions that have thread-specific filenames or names encoded in it should overwrite this method in order to update (1) the in-memory instruction and (2) the instruction string

### Methods inherited from class org.apache.sysds.runtime.instructions.cp.CPInstruction

`getCPInstructionType, getGraphString, getType, postprocessInstruction, preprocessInstruction, requiresLabelUpdate, updateLabels`

### Methods inherited from class org.apache.sysds.runtime.instructions.Instruction

`getBeginColumn, getBeginLine, getEndColumn, getEndLine, getExtendedOpcode, getFilename, getInstID, getInstructionString, getLineNum, getOpcode, getOperator, printMe, setInstID, setLocation, setLocation, setLocation, setLocation, toString`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.apache.sysds.runtime.lineage.LineageTraceable

`getLineageItems, hasSingleLineage`

### Method Detail

#### isRemoveVariable

    public boolean isRemoveVariable​(String varName)

Checks if this instruction is a remove instruction for varName

Parameters:
  `varName` - variable name
Returns:
  true if rmvar instruction including varName

#### isRemoveVariableNoFile

    public boolean isRemoveVariableNoFile()

#### isRemoveVariable

    public boolean isRemoveVariable()

#### isMoveVariable

    public boolean isMoveVariable()

#### isAssignVariable

    public boolean isAssignVariable()

#### isAssignOrCopyVariable

    public boolean isAssignOrCopyVariable()

#### isCreateVariable

    public boolean isCreateVariable()

#### getVariableOpcode

    public VariableCPInstruction.VariableOperationCode getVariableOpcode()

#### getFormatProperties

    public FileFormatProperties getFormatProperties()

#### getInputs

    public List<CPOperand> getInputs()

#### getInput1

    public CPOperand getInput1()

#### getInput2

    public CPOperand getInput2()

#### getInput3

    public CPOperand getInput3()

#### getInput4

    public CPOperand getInput4()

#### getInput

    public CPOperand getInput​(int index)

#### addInput

    public void addInput​(CPOperand input)

#### getOutputVariableName

    public String getOutputVariableName()

#### getOutput

    public CPOperand getOutput()

#### parseInstruction

    public static VariableCPInstruction parseInstruction​(String str)

#### processInstruction

    public void processInstruction​(ExecutionContext ec)

Description copied from class: `Instruction`
This method should be used to execute the instruction.

Specified by:
  `processInstruction` in class `CPInstruction`
Parameters:
  `ec` - execution context

#### processRmvarInstruction

    public static void processRmvarInstruction​(ExecutionContext ec,
                                               String varname)

Remove variable instruction externalized as a static function in order to allow various cleanup procedures to use the same codepath as the actual rmVar instruction

Parameters:
  `ec` - execution context
  `varname` - variable name

#### prepareRemoveInstruction

    public static Instruction prepareRemoveInstruction​(long... varName)

#### prepareRemoveInstruction

    public static Instruction prepareRemoveInstruction​(String... varNames)

#### prepareCopyInstruction

    public static Instruction prepareCopyInstruction​(String srcVar,
                                                     String destVar)

#### prepMoveInstruction

    public static Instruction prepMoveInstruction​(String srcVar,
                                                  String destFileName,
                                                  String format)

#### prepMoveInstruction

    public static Instruction prepMoveInstruction​(String srcVar,
                                                  String destVar)

#### prepCreatevarInstruction

    public static Instruction prepCreatevarInstruction​(String varName,
                                                       String fileName,
                                                       boolean fNameOverride,
                                                       String format)

#### prepCreatevarInstruction

    public static Instruction prepCreatevarInstruction​(String varName,
                                                       String fileName,
                                                       boolean fNameOverride,
                                                       Types.DataType dt,
                                                       String format,
                                                       DataCharacteristics mc,
                                                       MatrixObject.UpdateType update)

#### prepCreatevarInstruction

    public static Instruction prepCreatevarInstruction​(String varName,
                                                       String fileName,
                                                       boolean fNameOverride,
                                                       Types.DataType dt,
                                                       String format,
                                                       DataCharacteristics mc,
                                                       MatrixObject.UpdateType update,
                                                       boolean hasHeader,
                                                       String delim,
                                                       boolean sparse)

#### updateInstructionThreadID

    public void updateInstructionThreadID​(String pattern,
                                          String replace)

Description copied from class: `Instruction`
All instructions that have thread-specific filenames or names encoded in it should overwrite this method in order to update (1) the in-memory instruction and (2) the instruction string

Overrides:
  `updateInstructionThreadID` in class `Instruction`
Parameters:
  `pattern` - ?
  `replace` - ?

#### getLineageItem

    public org.apache.commons.lang3.tuple.Pair<String,​LineageItem> getLineageItem​(ExecutionContext ec)

Description copied from interface: `LineageTraceable`
Obtain lineage trace of an instruction with a single output.

Specified by:
  `getLineageItem` in interface `LineageTraceable`
Parameters:
  `ec` - execution context w/ live variables
Returns:
  pair of (output variable name, output lineage item)

#### isVariableCastInstruction

    public boolean isVariableCastInstruction()

#### getUniqueFileName

    public static String getUniqueFileName​(String fname)

#### getMetaData

    public MetaData getMetaData()