@Test public void testBasicColumnReplace() throws Exception { String[] directives = new String[] { "columns-replace s/^data_ }; List<Row> rows = Arrays.asList( new Row("data_a", 1).add("data_b", 2).add("data_timestamp", 3).add("data_data_confuse", 4) .add("no_data", 5).add("whatever", 6) ); rows = TestingRig.execute(directives, rows); Assert.assertTrue(rows.size() == 1); Assert.assertEquals("a", rows.get(0).getColumn(0)); Assert.assertEquals("b", rows.get(0).getColumn(1)); Assert.assertEquals("timestamp", rows.get(0).getColumn(2)); Assert.assertEquals("data_confuse", rows.get(0).getColumn(3)); Assert.assertEquals("no_data", rows.get(0).getColumn(4)); Assert.assertEquals("whatever", rows.get(0).getColumn(5)); }
@Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { for (int i = 0; i < row.width(); ++i) { String name = row.getColumn(i); try { Unix4jCommandBuilder builder = Unix4j.echo(name).sed(sed); row.setColumn(i, builder.toStringResult()); } catch (IllegalArgumentException e) { throw new DirectiveExecutionException(NAME, e.getMessage(), e); } } } return rows; }
ColumnsReplace implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { for (int i = 0; i < row.width(); ++i) { String name = row.getColumn(i); try { Unix4jCommandBuilder builder = Unix4j.echo(name).sed(sed); row.setColumn(i, builder.toStringResult()); } catch (IllegalArgumentException e) { throw new DirectiveExecutionException(NAME, e.getMessage(), e); } } } return rows; } }
ColumnsReplace implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { for (int i = 0; i < row.width(); ++i) { String name = row.getColumn(i); try { Unix4jCommandBuilder builder = Unix4j.echo(name).sed(sed); row.setColumn(i, builder.toStringResult()); } catch (IllegalArgumentException e) { throw new DirectiveExecutionException(NAME, e.getMessage(), e); } } } return rows; }  }
ColumnsReplace implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { for (int i = 0; i < row.width(); ++i) { String name = row.getColumn(i); try { Unix4jCommandBuilder builder = Unix4j.echo(name).sed(sed); row.setColumn(i, builder.toStringResult()); } catch (IllegalArgumentException e) { throw new DirectiveExecutionException(NAME, e.getMessage(), e); } } } 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(); }
ColumnsReplace implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { for (int i = 0; i < row.width(); ++i) { String name = row.getColumn(i); try { Unix4jCommandBuilder builder = Unix4j.echo(name).sed(sed); row.setColumn(i, builder.toStringResult()); } catch (IllegalArgumentException e) { throw new DirectiveExecutionException(NAME, e.getMessage(), e); } } } 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; }