@Test public void testKeep() throws Exception { String[] directives = new String[] { "parse-as-csv body ,", "keep body_1,body_2" }; List<Row> rows = Arrays.asList( new Row("body", "1,2,3,4,5,6,7,8,9,10") ); rows = TestingRig.execute(directives, rows); Assert.assertTrue(rows.size() == 1); Assert.assertEquals(2, rows.get(0).width()); }
@Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { int idx = 0; for (Pair<String, Object> v : row.getFields()) { if (!keep.contains(v.getFirst())) { row.remove(idx); } else { ++idx; } } } return rows; }
Keep implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { int idx = 0; for (Pair<String, Object> v : row.getFields()) { if (!keep.contains(v.getFirst())) { row.remove(idx); } else { ++idx; } } } return rows; } }
Keep implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { int idx = 0; for (Pair<String, Object> v : row.getFields()) { if (!keep.contains(v.getFirst())) { row.remove(idx); } else { ++idx; } } } return rows; }  }
Keep implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { int idx = 0; for (Pair<String, Object> v : row.getFields()) { if (!keep.contains(v.getFirst())) { row.remove(idx); } else { ++idx; } } } return rows; }  @Override UsageDefinition define(); @Override void initialize(Arguments args); @Override void destroy(); @Override List<Row> execute(List<Row> rows, ExecutorContext context); @Override Mutation lineage(); }
Keep implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { int idx = 0; for (Pair<String, Object> v : row.getFields()) { if (!keep.contains(v.getFirst())) { row.remove(idx); } else { ++idx; } } } return rows; }  @Override UsageDefinition define(); @Override void initialize(Arguments args); @Override void destroy(); @Override List<Row> execute(List<Row> rows, ExecutorContext context); @Override Mutation lineage(); static final String NAME; }