@Test public void testToBytes() throws Exception { List<Row> rows = Collections.singletonList( new Row("str_col", "10000").add("int_col", 10000).add("double_col", 10000.00d) .add("short_col", new Short("10000")).add("long_col", 10000L).add("float_col", 10000.0f) .add("bytes_col", new byte[] {64, -61, -120, 0, 0, 0, 0, 0}) ); byte[][] bytesResults = new byte[][] { new byte[] {49, 48, 48, 48, 48}, new byte[] {0, 0, 39, 16}, new byte[] {64, -61, -120, 0, 0, 0, 0, 0}, new byte[] {39, 16}, new byte[] {0, 0, 0, 0, 0, 0, 39, 16}, new byte[] {70, 28, 64, 0}, new byte[] {64, -61, -120, 0, 0, 0, 0, 0} }; String[] directives = new String[] { "set-type str_col bytes", "set-type int_col Bytes", "set-type double_col BYTES", "set-type short_col bytes", "set-type long_col Bytes", "set-type float_col BYTES", "set-type bytes_col bytes" }; List<Row> results = TestingRig.execute(directives, rows); Row row = results.get(0); for (int i = 0; i < row.width(); i++) { Object object = row.getValue(i); Assert.assertTrue(object instanceof byte[]); byte [] value = (byte[]) object; Assert.assertEquals(0, Bytes.compareTo(value, bytesResults[i])); } }
@Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { ColumnConverter.convertType(NAME, row, col, type); } return rows; }
SetType implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { ColumnConverter.convertType(NAME, row, col, type); } return rows; } }
SetType implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { ColumnConverter.convertType(NAME, row, col, type); } return rows; }  }
SetType implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { ColumnConverter.convertType(NAME, row, col, type); } 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(); }
SetType implements Directive, Lineage { @Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException { for (Row row : rows) { ColumnConverter.convertType(NAME, row, col, type); } 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; }