IterationStrategyStack stack = (IterationStrategyStack) parent; if (!stack.contains(this)) stack.add(this); } else if (parent instanceof DotProduct || parent instanceof CrossProduct) {
IterationStrategyStack stack = (IterationStrategyStack) parent; if (!stack.contains(this)) stack.add(this); } else if (parent instanceof DotProduct || parent instanceof CrossProduct) {
@Test public void testStagedCombinationOfDot1() { Processor p = new Processor(); IterationStrategyStack iss = new IterationStrategyStack(p); iss.add(getDot(1, 1)); iss.add(getDot(0, 0)); StructuralValidator sv = new StructuralValidator(); sv.getValidatorState().setProcessor(p); Map<InputProcessorPort, Integer> tempDepths = new HashMap<InputProcessorPort, Integer>(); tempDepths.put(a,2); tempDepths.put(b,2); assertEquals(Integer.valueOf(2), sv.calculateResultWrappingDepth(tempDepths)); }
protected IterationStrategyStack parseIterationStrategyStack( org.apache.taverna.scufl2.xml.t2flow.jaxb.IterationStrategyStack originalStack) throws ReaderException { IterationStrategyStack newStack = new IterationStrategyStack(); for (TopIterationNode strategy : originalStack.getIteration() .getStrategy()) { IterationNode topNode = strategy.getCross(); if (topNode == null) topNode = strategy.getDot(); if (topNode == null) continue; IterationNodeParent parent = (IterationNodeParent) topNode; if (parent.getCrossOrDotOrPort().isEmpty()) continue; try { newStack.add((IterationStrategyTopNode) parseIterationStrategyNode(topNode)); } catch (ReaderException e) { if (isStrict()) throw e; logger.warning(e.getMessage()); } } return newStack; }
@Test public void testStagedCombinationOfCross() { Processor p = new Processor(); IterationStrategyStack iss = new IterationStrategyStack(p); iss.add(getCross(1, 1)); iss.add(getCross(0, 0)); StructuralValidator sv = new StructuralValidator(); sv.getValidatorState().setProcessor(p); Map<InputProcessorPort, Integer> tempDepths = new HashMap<InputProcessorPort, Integer>(); tempDepths.put(a,2); tempDepths.put(b,2); assertEquals(Integer.valueOf(4), sv.calculateResultWrappingDepth(tempDepths)); }
@Test public void testStagedCombinationOfDot3() { Processor p = new Processor(); IterationStrategyStack iss = new IterationStrategyStack(p); iss.add(getDot(1, 1)); iss.add(getDot(0, 0)); StructuralValidator sv = new StructuralValidator(); sv.getValidatorState().setProcessor(p); Map<InputProcessorPort, Integer> tempDepths = new HashMap<InputProcessorPort, Integer>(); tempDepths.put(a,1); tempDepths.put(b,0); // Slightly strange superficially that this should work, but in fact // what happens is that the first single item is lifted to a list before // being passed to the iteration strategy. The result is that it's fine // to match with the dot product against the other list as neither at // this point have index arrays, then in the second stage both are lists // to be iterated over and both have single length index arrays. assertEquals(Integer.valueOf(1), sv.calculateResultWrappingDepth(tempDepths)); } }
@Test public void testStagedCombinationOfDot2() { Processor p = new Processor(); IterationStrategyStack iss = new IterationStrategyStack(p); iss.add(getDot(1, 1)); iss.add(getDot(0, 0)); StructuralValidator sv = new StructuralValidator(); sv.getValidatorState().setProcessor(p); Map<InputProcessorPort, Integer> tempDepths = new HashMap<InputProcessorPort, Integer>(); tempDepths.put(a,0); tempDepths.put(b,0); // Should pass because the single items (depth 0) are promoted to single // item lists before being passed into the iteration system so are // effectively both depth 1 going into the second stage which then // iterates to produce an index array length of 1 assertEquals(Integer.valueOf(1), sv.calculateResultWrappingDepth(tempDepths)); }
/** * Test whether Paul's example of iterating with dot product then cross * product can typecheck in a single staged iteration. This was an example * where the user had two lists of folders (a1, a2, b1, b2, c1, c2) and * wanted to compare all the contents of each 'a' folder with the other 'a' * folder and so on, doing a dot match to only compare a1 and a2 then a * cross product join within each pair to compare all contents of a1 with * all contents of a2. This appears to work! */ @Test public void testStagedCombinationOfDotAndCross() { Processor p = new Processor(); IterationStrategyStack iss = new IterationStrategyStack(p); iss.add(getDot(1, 1)); iss.add(getCross(0, 0)); StructuralValidator sv = new StructuralValidator(); sv.getValidatorState().setProcessor(p); Map<InputProcessorPort, Integer> tempDepths = new HashMap<InputProcessorPort, Integer>(); tempDepths.put(a,2); tempDepths.put(b,2); assertEquals(Integer.valueOf(3), sv.calculateResultWrappingDepth(tempDepths)); }
p.setIterationStrategyStack(iss); CrossProduct cp = new CrossProduct(); iss.add(cp); cp.setParent(iss); PortNode pn = new PortNode();
@Test public void testSimpleIteration() { WorkflowBundle wb = new WorkflowBundle(); Workflow w = new Workflow(); wb.setMainWorkflow(w); InputWorkflowPort a = new InputWorkflowPort(w, "a"); a.setDepth(1); Processor p = new Processor(w, "p"); InputProcessorPort ipp = new InputProcessorPort(p, "in"); ipp.setDepth(0); OutputProcessorPort opp = new OutputProcessorPort(p, "out"); opp.setDepth(3); DataLink inLink = new DataLink(w, a, ipp); IterationStrategyStack iss = new IterationStrategyStack(p); CrossProduct cp = new CrossProduct(); iss.add(cp); PortNode portNode = new PortNode(cp, ipp); portNode.setDesiredDepth(0); StructuralValidator sv = new StructuralValidator(); ReportStructuralValidationListener l = new ReportStructuralValidationListener(); sv.checkStructure(wb, l); ValidatorState vs = sv.getValidatorState(); assertEquals(0, l.getIncompleteWorkflows().size()); assertEquals(Integer.valueOf(1), vs.getPortResolvedDepth(a)); assertEquals(Integer.valueOf(1), vs.getDataLinkResolvedDepth(inLink)); assertEquals(Integer.valueOf(1), vs.getPortResolvedDepth(ipp)); assertEquals(Integer.valueOf(4), vs.getPortResolvedDepth(opp)); }
@Test public void testInScopeInputProcessorPort() { Processor p = new Processor(); InputProcessorPort ipp = new InputProcessorPort(); ipp.setParent(p); IterationStrategyStack iss = new IterationStrategyStack(); p.setIterationStrategyStack(iss); CrossProduct cp = new CrossProduct(); iss.add(cp); cp.setParent(iss); PortNode pn = new PortNode(); pn.setInputProcessorPort(ipp); cp.add(pn); pn.setParent(cp); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pn, false, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); assertEquals(Collections.EMPTY_SET, outOfScopeValueProblems); }
duplicateNode.setInputProcessorPort(p1); cp.add(duplicateNode); iss.add(cp);
pNode1.setInputProcessorPort(p1); cp.add(pNode1); iss.add(cp);
pNode1.setInputProcessorPort(p1); cp.add(pNode1); iss.add(cp);