@Test
public void testOrderVarbinary() throws Exception {
RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();
DrillConfig config = DrillConfig.create();
try(Drillbit bit1 = new Drillbit(config, serviceSet); DrillClient client = new DrillClient(config, serviceSet.getCoordinator());){
bit1.run();
client.connect();
List<QueryResultBatch> results = client.runQuery(UserProtos.QueryType.PHYSICAL, Resources.toString(Resources.getResource("physical_order_varbinary.json"),Charsets.UTF_8));
RecordBatchLoader loader = new RecordBatchLoader(bit1.getContext().getAllocator());
for (QueryResultBatch b : results) {
System.out.println(String.format("Got %d results", b.getHeader().getRowCount()));
loader.load(b.getHeader().getDef(), b.getData());
for (VectorWrapper vw : loader) {
System.out.println(vw.getValueVector().getField().getName());
ValueVector vv = vw.getValueVector();
for (int i = 0; i < vv.getAccessor().getValueCount(); i++) {
Object o = vv.getAccessor().getObject(i);
if(vv instanceof VarBinaryVector){
VarBinaryVector.Accessor x = ((VarBinaryVector) vv).getAccessor();
VarBinaryHolder vbh = new VarBinaryHolder();
x.get(i, vbh);
System.out.printf("%d..%d", vbh.start, vbh.end);
System.out.println("[" + new String( (byte[]) vv.getAccessor().getObject(i)) + "]");
}else{
System.out.println(vv.getAccessor().getObject(i));
}
}
}
}
client.close();
}
}