ResultGenerator.fromRowSpec(tableResource.getName(), rowspec, null);
if (!generator.hasNext()) {
throw new WebApplicationException(Response.Status.NOT_FOUND);
}
int count = 0;
CellSetModel model = new CellSetModel();
KeyValue value = generator.next();
byte[] rowKey = value.getRow();
RowModel rowModel = new RowModel(rowKey);
do {
if (!Bytes.equals(value.getRow(), rowKey)) {
model.addRow(rowModel);
rowKey = value.getRow();
rowModel = new RowModel(rowKey);
}
byte[] family = value.getFamily();
byte[] qualifier = value.getQualifier();
byte[] data = tableResource.transform(family, qualifier,
value.getValue(), Transform.Direction.OUT);
rowModel.addCell(new CellModel(family, qualifier,
value.getTimestamp(), data));
if (++count > rowspec.getMaxValues()) {
break;
}
value = generator.next();
} while (value != null);
model.addRow(rowModel);
return Response.ok(model).build();
} catch (IOException e) {
throw new WebApplicationException(e,
Response.Status.SERVICE_UNAVAILABLE);
}