@Test public void testExecution(){ Schema schema = new Schema.Builder() .addColumnsString("col") .addColumnsDouble("col2") .build(); Map<Character,Integer> m = defaultCharIndex(); TransformProcess transformProcess = new TransformProcess.Builder(schema) .doubleMathOp("col2", MathOp.Add, 1.0) .build(); List<Writable> in = Arrays.<Writable>asList(new Text("Text"), new DoubleWritable(2.0)); List<Writable> exp = Arrays.<Writable>asList(new Text("Text"), new DoubleWritable(3.0)); List<Writable> out = transformProcess.execute(in); assertEquals(exp, out); }
public List<Writable> execute(List<Writable> input) { List<Writable> currValues = input; for (DataAction d : actionList) { if (d.getTransform() != null) { Transform t = d.getTransform(); currValues = t.map(currValues); } else if (d.getFilter() != null) { Filter f = d.getFilter(); if (f.removeExample(currValues)) return null; } else if (d.getConvertToSequence() != null) { throw new RuntimeException( "Cannot execute examples individually: TransformProcess contains a ConvertToSequence operation"); } else if (d.getConvertFromSequence() != null) { throw new RuntimeException( "Unexpected operation: TransformProcess contains a ConvertFromSequence operation"); } else if (d.getSequenceSplit() != null) { throw new RuntimeException( "Cannot execute examples individually: TransformProcess contains a SequenceSplit operation"); } else { throw new RuntimeException("Unknown action: " + d); } } return currValues; }
TransformProcess implements Serializable { public List<Writable> execute(List<Writable> input) { List<Writable> currValues = input; for (DataAction d : actionList) { if (d.getTransform() != null) { Transform t = d.getTransform(); currValues = t.map(currValues); } else if (d.getFilter() != null) { Filter f = d.getFilter(); if (f.removeExample(currValues)) return null; } else if (d.getConvertToSequence() != null) { throw new RuntimeException( "Cannot execute examples individually: TransformProcess contains a ConvertToSequence operation"); } else if (d.getConvertFromSequence() != null) { throw new RuntimeException( "Unexpected operation: TransformProcess contains a ConvertFromSequence operation"); } else if (d.getSequenceSplit() != null) { throw new RuntimeException( "Cannot execute examples individually: TransformProcess contains a SequenceSplit operation"); } else { throw new RuntimeException("Unknown action: " + d); } } return currValues; } }
TransformProcess implements Serializable { public List<Writable> execute(List<Writable> input) { List<Writable> currValues = input; for (DataAction d : actionList) { if (d.getTransform() != null) { Transform t = d.getTransform(); currValues = t.map(currValues); } else if (d.getFilter() != null) { Filter f = d.getFilter(); if (f.removeExample(currValues)) return null; } else if (d.getConvertToSequence() != null) { throw new RuntimeException( "Cannot execute examples individually: TransformProcess contains a ConvertToSequence operation"); } else if (d.getConvertFromSequence() != null) { throw new RuntimeException( "Unexpected operation: TransformProcess contains a ConvertFromSequence operation"); } else if (d.getSequenceSplit() != null) { throw new RuntimeException( "Cannot execute examples individually: TransformProcess contains a SequenceSplit operation"); } else { throw new RuntimeException("Unknown action: " + d); } } return currValues; } TransformProcess(@JsonProperty("initialSchema") Schema initialSchema,
                            @JsonProperty("actionList") List<DataAction> actionList); private  TransformProcess(Builder builder); }
TransformProcess implements Serializable { public List<Writable> execute(List<Writable> input) { List<Writable> currValues = input; for (DataAction d : actionList) { if (d.getTransform() != null) { Transform t = d.getTransform(); currValues = t.map(currValues); } else if (d.getFilter() != null) { Filter f = d.getFilter(); if (f.removeExample(currValues)) return null; } else if (d.getConvertToSequence() != null) { throw new RuntimeException( "Cannot execute examples individually: TransformProcess contains a ConvertToSequence operation"); } else if (d.getConvertFromSequence() != null) { throw new RuntimeException( "Unexpected operation: TransformProcess contains a ConvertFromSequence operation"); } else if (d.getSequenceSplit() != null) { throw new RuntimeException( "Cannot execute examples individually: TransformProcess contains a SequenceSplit operation"); } else { throw new RuntimeException("Unknown action: " + d); } } return currValues; } TransformProcess(@JsonProperty("initialSchema") Schema initialSchema,
                            @JsonProperty("actionList") List<DataAction> actionList); private  TransformProcess(Builder builder); List<DataAction> getActionList(); Schema getFinalSchema(); Schema getSchemaAfterStep(int step); List<Writable> execute(List<Writable> input); List<List<Writable>> executeSequenceToSequence(List<List<Writable>> input); List<List<Writable>> executeSequence(List<List<Writable>> inputSequence); List<List<List<Writable>>> executeToSequenceBatch(List<List<Writable>> inputExample); List<List<Writable>> executeToSequence(List<Writable> inputExample); List<Writable> executeSequenceToSingle(List<List<Writable>> inputSequence); String toJson(); String toYaml(); static TransformProcess fromJson(String json); static TransformProcess fromYaml(String yaml); static List<String> inferCategories(RecordReader recordReader,int columnIndex); static Map<Integer,List<String>> inferCategories(RecordReader recordReader,int[] columnIndices); List<List<Writable>> transformRawStringsToInputSequence(List<List<String>> sequence); List<Writable> transformRawStringsToInputList(List<String> values); List<Writable> transformRawStringsToInput(String... values); }
TransformProcess implements Serializable { public List<Writable> execute(List<Writable> input) { List<Writable> currValues = input; for (DataAction d : actionList) { if (d.getTransform() != null) { Transform t = d.getTransform(); currValues = t.map(currValues); } else if (d.getFilter() != null) { Filter f = d.getFilter(); if (f.removeExample(currValues)) return null; } else if (d.getConvertToSequence() != null) { throw new RuntimeException( "Cannot execute examples individually: TransformProcess contains a ConvertToSequence operation"); } else if (d.getConvertFromSequence() != null) { throw new RuntimeException( "Unexpected operation: TransformProcess contains a ConvertFromSequence operation"); } else if (d.getSequenceSplit() != null) { throw new RuntimeException( "Cannot execute examples individually: TransformProcess contains a SequenceSplit operation"); } else { throw new RuntimeException("Unknown action: " + d); } } return currValues; } TransformProcess(@JsonProperty("initialSchema") Schema initialSchema,
                            @JsonProperty("actionList") List<DataAction> actionList); private  TransformProcess(Builder builder); List<DataAction> getActionList(); Schema getFinalSchema(); Schema getSchemaAfterStep(int step); List<Writable> execute(List<Writable> input); List<List<Writable>> executeSequenceToSequence(List<List<Writable>> input); List<List<Writable>> executeSequence(List<List<Writable>> inputSequence); List<List<List<Writable>>> executeToSequenceBatch(List<List<Writable>> inputExample); List<List<Writable>> executeToSequence(List<Writable> inputExample); List<Writable> executeSequenceToSingle(List<List<Writable>> inputSequence); String toJson(); String toYaml(); static TransformProcess fromJson(String json); static TransformProcess fromYaml(String yaml); static List<String> inferCategories(RecordReader recordReader,int columnIndex); static Map<Integer,List<String>> inferCategories(RecordReader recordReader,int[] columnIndices); List<List<Writable>> transformRawStringsToInputSequence(List<List<String>> sequence); List<Writable> transformRawStringsToInputList(List<String> values); List<Writable> transformRawStringsToInput(String... values);  }