Package org.apache.sysds.runtime.util
Class ProgramConverter
java.lang.Object
org.apache.sysds.runtime.util.ProgramConverter
Program converter functionalities for
(1) creating deep copies of program blocks, instructions, function program blocks, and
(2) serializing and parsing of programs, program blocks, functions program blocks.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic InstructioncloneInstruction(Instruction oInst, long pid, boolean plain, boolean cpFunctions) static ExecutionContextCreates a deep copy of the given execution context.static ForProgramBlockcreateDeepCopyForProgramBlock(ForProgramBlock fpb, long pid, int IDPrefix, Program prog, Set<String> fnStack, Set<String> fnCreated, boolean plain, boolean forceDeepCopy) static voidcreateDeepCopyFunctionProgramBlock(String namespace, String oldName, long pid, int IDPrefix, Program prog, Set<String> fnStack, Set<String> fnCreated, boolean plain) This creates a deep copy of a function program block.static FunctionProgramBlockcreateDeepCopyFunctionProgramBlock(FunctionProgramBlock fpb, Set<String> fnStack, Set<String> fnCreated) static FunctionProgramBlockcreateDeepCopyFunctionProgramBlock(FunctionProgramBlock fpb, Set<String> fnStack, Set<String> fnCreated, long pid) static FunctionProgramBlockcreateDeepCopyFunctionProgramBlock(FunctionProgramBlock fpb, Set<String> fnStack, Set<String> fnCreated, long pid, int IDPrefix, boolean plain) static FunctionStatementBlockcreateDeepCopyFunctionStatementBlock(FunctionStatementBlock fsb, Set<String> fnStack, Set<String> fnCreated) static IfProgramBlockcreateDeepCopyIfProgramBlock(IfProgramBlock ipb, long pid, int IDPrefix, Program prog, Set<String> fnStack, Set<String> fnCreated, boolean plain, boolean forceDeepCopy) static ArrayList<Instruction>createDeepCopyInstructionSet(ArrayList<Instruction> instSet, long pid, int IDPrefix, Program prog, Set<String> fnStack, Set<String> fnCreated, boolean plain, boolean cpFunctions) Creates a deep copy of an array of instructions and replaces the placeholders of parworker IDs with the concrete IDs of this parfor instance.static ParForProgramBlockcreateDeepCopyParForProgramBlock(ParForProgramBlock pfpb, long pid, int IDPrefix, Program prog, Set<String> fnStack, Set<String> fnCreated, boolean plain, boolean forceDeepCopy) static WhileProgramBlockcreateDeepCopyWhileProgramBlock(WhileProgramBlock wpb, long pid, int IDPrefix, Program prog, Set<String> fnStack, Set<String> fnCreated, boolean plain, boolean forceDeepCopy) static ForStatementBlockcreateForStatementBlockCopy(ForStatementBlock sb, boolean forceDeepCopy) static IfStatementBlockcreateIfStatementBlockCopy(IfStatementBlock sb, boolean forceDeepCopy) static ForProgramBlockstatic ArrayList<Instruction>createShallowCopyInstructionSet(ArrayList<Instruction> insts, long pid) static StatementBlockcreateStatementBlockCopy(StatementBlock sb, long pid, boolean plain, boolean forceDeepCopy) static WhileStatementBlockcreateWhileStatementBlockCopy(WhileStatementBlock sb, boolean forceDeepCopy) static Object[]NOTE: MRJobConfiguration cannot be used for the general case because program blocks and related symbol tables can be hierarchically structured.static ParForBodyparseParForBody(String in, int id) static ParForBodyparseParForBody(String in, int id, boolean inSpark) static ProgramparseProgram(String in, int id) static SparkPSBodyparseSparkPSBody(String in, int id) static ArrayList<ProgramBlock>rcreateDeepCopyProgramBlocks(ArrayList<ProgramBlock> childBlocks, long pid, int IDPrefix, Set<String> fnStack, Set<String> fnCreated, boolean plain, boolean forceDeepCopy) This recursively creates a deep copy of program blocks and transparently replaces filenames according to the specified parallel worker in order to avoid conflicts between parworkers.static StatementBlockstatic StringsaveReplaceFilenameThreadID(String fname, String pattern, String replace) static StringserializeDataObject(String key, Data dat) static StringserializeList(List<String> elements) static StringserializeList(List<String> elements, String delim) static Stringstatic StringserializeParForBody(ParForBody body, HashMap<String, byte[]> clsMap) static StringserializeProgram(Program prog, ArrayList<ProgramBlock> pbs, HashMap<String, byte[]> clsMap) static Stringstatic StringserializeSparkPSBody(SparkPSBody body, HashMap<String, byte[]> clsMap)
-
Field Details
-
NEWLINE
- See Also:
-
COMPONENTS_DELIM
- See Also:
-
ELEMENT_DELIM
- See Also:
-
ELEMENT_DELIM2
- See Also:
-
DATA_FIELD_DELIM
- See Also:
-
KEY_VALUE_DELIM
- See Also:
-
LEVELIN
- See Also:
-
LEVELOUT
- See Also:
-
EMPTY
- See Also:
-
DASH
- See Also:
-
REF
- See Also:
-
LIST_ELEMENT_DELIM
- See Also:
-
CDATA_BEGIN
- See Also:
-
CDATA_END
- See Also:
-
PROG_BEGIN
- See Also:
-
PROG_END
- See Also:
-
VARS_BEGIN
- See Also:
-
VARS_END
- See Also:
-
PBS_BEGIN
- See Also:
-
PBS_END
- See Also:
-
INST_BEGIN
- See Also:
-
INST_END
- See Also:
-
EC_BEGIN
- See Also:
-
EC_END
- See Also:
-
PB_BEGIN
- See Also:
-
PB_END
- See Also:
-
PB_WHILE
- See Also:
-
PB_FOR
- See Also:
-
PB_PARFOR
- See Also:
-
PB_IF
- See Also:
-
PB_FC
- See Also:
-
PB_EFC
- See Also:
-
CONF_STATS
- See Also:
-
PARFORBODY_BEGIN
- See Also:
-
PARFORBODY_END
- See Also:
-
PSBODY_BEGIN
- See Also:
-
PSBODY_END
- See Also:
-
NOT_SUPPORTED_SPARK_INSTRUCTION
- See Also:
-
NOT_SUPPORTED_SPARK_PARFOR
- See Also:
-
NOT_SUPPORTED_PB
- See Also:
-
-
Constructor Details
-
ProgramConverter
public ProgramConverter()
-
-
Method Details
-
createDeepCopyExecutionContext
public static ExecutionContext createDeepCopyExecutionContext(ExecutionContext ec) throws CloneNotSupportedException Creates a deep copy of the given execution context. For rt_platform=Hadoop, execution context has a symbol table.- Parameters:
ec- execution context- Returns:
- execution context
- Throws:
CloneNotSupportedException- if CloneNotSupportedException occurs
-
rcreateDeepCopyProgramBlocks
public static ArrayList<ProgramBlock> rcreateDeepCopyProgramBlocks(ArrayList<ProgramBlock> childBlocks, long pid, int IDPrefix, Set<String> fnStack, Set<String> fnCreated, boolean plain, boolean forceDeepCopy) This recursively creates a deep copy of program blocks and transparently replaces filenames according to the specified parallel worker in order to avoid conflicts between parworkers. This happens recursively in order to support arbitrary control-flow constructs within a parfor.- Parameters:
childBlocks- child program blockspid- ?IDPrefix- ?fnStack- ?fnCreated- ?plain- if true, full deep copy without id replacementforceDeepCopy- if true, force deep copy- Returns:
- list of program blocks
-
createDeepCopyWhileProgramBlock
public static WhileProgramBlock createDeepCopyWhileProgramBlock(WhileProgramBlock wpb, long pid, int IDPrefix, Program prog, Set<String> fnStack, Set<String> fnCreated, boolean plain, boolean forceDeepCopy) -
createDeepCopyIfProgramBlock
public static IfProgramBlock createDeepCopyIfProgramBlock(IfProgramBlock ipb, long pid, int IDPrefix, Program prog, Set<String> fnStack, Set<String> fnCreated, boolean plain, boolean forceDeepCopy) -
createDeepCopyForProgramBlock
public static ForProgramBlock createDeepCopyForProgramBlock(ForProgramBlock fpb, long pid, int IDPrefix, Program prog, Set<String> fnStack, Set<String> fnCreated, boolean plain, boolean forceDeepCopy) -
createShallowCopyForProgramBlock
-
createDeepCopyParForProgramBlock
public static ParForProgramBlock createDeepCopyParForProgramBlock(ParForProgramBlock pfpb, long pid, int IDPrefix, Program prog, Set<String> fnStack, Set<String> fnCreated, boolean plain, boolean forceDeepCopy) -
createDeepCopyFunctionProgramBlock
public static void createDeepCopyFunctionProgramBlock(String namespace, String oldName, long pid, int IDPrefix, Program prog, Set<String> fnStack, Set<String> fnCreated, boolean plain) This creates a deep copy of a function program block. The central reference to singletons of function program blocks poses the need for explicit copies in order to prevent conflicting writes of temporary variables (see ExternalFunctionProgramBlock.- Parameters:
namespace- function namespaceoldName- ?pid- ?IDPrefix- ?prog- runtime programfnStack- ?fnCreated- ?plain- ?
-
createDeepCopyFunctionProgramBlock
public static FunctionProgramBlock createDeepCopyFunctionProgramBlock(FunctionProgramBlock fpb, Set<String> fnStack, Set<String> fnCreated) -
createDeepCopyFunctionProgramBlock
public static FunctionProgramBlock createDeepCopyFunctionProgramBlock(FunctionProgramBlock fpb, Set<String> fnStack, Set<String> fnCreated, long pid) -
createDeepCopyFunctionProgramBlock
public static FunctionProgramBlock createDeepCopyFunctionProgramBlock(FunctionProgramBlock fpb, Set<String> fnStack, Set<String> fnCreated, long pid, int IDPrefix, boolean plain) -
createDeepCopyInstructionSet
public static ArrayList<Instruction> createDeepCopyInstructionSet(ArrayList<Instruction> instSet, long pid, int IDPrefix, Program prog, Set<String> fnStack, Set<String> fnCreated, boolean plain, boolean cpFunctions) Creates a deep copy of an array of instructions and replaces the placeholders of parworker IDs with the concrete IDs of this parfor instance. This is a helper method uses for generating deep copies of program blocks.- Parameters:
instSet- list of instructionspid- ?IDPrefix- ?prog- runtime programfnStack- ?fnCreated- ?plain- ?cpFunctions- ?- Returns:
- list of instructions
-
createShallowCopyInstructionSet
public static ArrayList<Instruction> createShallowCopyInstructionSet(ArrayList<Instruction> insts, long pid) -
cloneInstruction
public static Instruction cloneInstruction(Instruction oInst, long pid, boolean plain, boolean cpFunctions) -
createDeepCopyFunctionStatementBlock
public static FunctionStatementBlock createDeepCopyFunctionStatementBlock(FunctionStatementBlock fsb, Set<String> fnStack, Set<String> fnCreated) -
rCreateDeepCopyStatementBlock
-
createStatementBlockCopy
public static StatementBlock createStatementBlockCopy(StatementBlock sb, long pid, boolean plain, boolean forceDeepCopy) -
createIfStatementBlockCopy
public static IfStatementBlock createIfStatementBlockCopy(IfStatementBlock sb, boolean forceDeepCopy) -
createWhileStatementBlockCopy
public static WhileStatementBlock createWhileStatementBlockCopy(WhileStatementBlock sb, boolean forceDeepCopy) -
createForStatementBlockCopy
public static ForStatementBlock createForStatementBlockCopy(ForStatementBlock sb, boolean forceDeepCopy) -
serializeSparkPSBody
-
serializeParForBody
-
serializeParForBody
-
serializeProgram
-
serializeDataObject
-
serializeResultVariables
-
serializeList
-
serializeList
-
parseSparkPSBody
-
parseParForBody
-
parseParForBody
-
parseProgram
-
parseDataObject
NOTE: MRJobConfiguration cannot be used for the general case because program blocks and related symbol tables can be hierarchically structured.- Parameters:
in- data object as string- Returns:
- array of objects
-
saveReplaceFilenameThreadID
-