private Map<Command, List<Command> > generateGraph() { Map<Command, List<Command> > dag = new HashMap<>(); Map<String, List<Command> > outputMapping = new HashMap<>(); for (Command command : commands) { Set<String> inputs = command.getInputColumns(); for (String input : inputs) { List<Command> outputCommands = outputMapping.get(input); if (outputCommands != null) { List<Command> edges = dag.get(command); if (edges == null) edges = new ArrayList<>(); for (Command tmp : outputCommands) { if (tmp != command) edges.add(tmp); } dag.put(command, edges); } } Set<String> outputs = command.getOutputColumns(); for (String output : outputs) { List<Command> tmp = outputMapping.get(output); if (tmp == null) tmp = new ArrayList<>(); tmp.add(command); outputMapping.put(output, tmp); } } return dag; }
private Set<String> getParents(Command c, Map<Command, List<Command> >dag) { List<Command> parents = dag.get(c); Set<String> terminalColumns = new HashSet<>(); if (parents == null || parents.size() == 0) terminalColumns.addAll(c.getInputColumns()); else { for (Command t : parents) { terminalColumns.addAll(getParents(t, dag)); for (String hNodeId : c.getInputColumns()) { HNode hn = workspace.getFactory().getHNode(hNodeId); if (hn != null && hn.getHNodeType() == HNodeType.Regular) terminalColumns.add(hNodeId); } } } return terminalColumns; }
private void placeTransformCommandByInput(Command command) { ICommand placeAfterCmd = null; Set<String> cmdInputs = command.getInputColumns(); Set<String> cmdOutputs = command.getOutputColumns(); List<Command> commandsToMove = new ArrayList<>(); for (ICommand afterCmd : worksheetCommandHistory.getCommandsAfterCommand(command, CommandTag.Transformation)) { Set<String> afterCmdOutputs = ((Command)afterCmd).getOutputColumns(); Set<String> afterCmdInputs = ((Command)afterCmd).getInputColumns(); for(String input : cmdInputs) { if(afterCmdOutputs.contains(input)) {
for (ICommand cmd : worksheetCommandHistory.getCommandsFromWorksheetIdAndCommandTag(worksheetId, CommandTag.Transformation)) { Set<String> outputs = ((Command)cmd).getOutputColumns(); Set<String> inputs = ((Command)cmd).getInputColumns(); String commandId = "Command-" + cmd.getId(); historyInputOutputGraph.addVertex(commandId);
Command tmp = (Command)comm; JSONArray inputArray = new JSONArray(); for (String hNodeId : tmp.getInputColumns()) { HNode node = workspace.getFactory().getHNode(hNodeId); JSONArray hNodeRepresentation = node.getJSONArrayRepresentation(workspace.getFactory());
effects.append(runCommand.doIt(workspace)); if(runCommand.getInputColumns().size() > 0 && !runCommand.getInputColumns().equals(command.getInputColumns())) { Pair<Boolean, Set<String>> cycleDetect = detectTransformCycle(worksheetId); if(cycleDetect.getLeft() == false) {