Extracts the rows from the given ScanResponse. @param resp The protobuf of the RPC response. @param buf The buffer the response was read from. The actual KeyValues of the response will be read from there if cell blocks are in use. @param cell_size The number of bytes of the cell block that
(final ScanResponse resp,
final ChannelBuffer buf,
final int cell_size)
| 1215 | * in the buffer. |
| 1216 | */ |
| 1217 | private ArrayList<ArrayList<KeyValue>> getRows(final ScanResponse resp, |
| 1218 | final ChannelBuffer buf, |
| 1219 | final int cell_size) { |
| 1220 | final int nrows = (cell_size == 0 |
| 1221 | ? resp.getResultsCount() |
| 1222 | : resp.getCellsPerResultCount()); |
| 1223 | if (nrows == 0) { |
| 1224 | return null; |
| 1225 | } |
| 1226 | HBaseRpc.checkArrayLength(buf, nrows); |
| 1227 | final ArrayList<ArrayList<KeyValue>> rows = |
| 1228 | new ArrayList<ArrayList<KeyValue>>(nrows); |
| 1229 | if (cell_size != 0) { |
| 1230 | KeyValue kv = null; |
| 1231 | for (int i = 0; i < nrows; i++) { |
| 1232 | final int nkvs = resp.getCellsPerResult(i); |
| 1233 | HBaseRpc.checkArrayLength(buf, nkvs); |
| 1234 | final ArrayList<KeyValue> row = new ArrayList<KeyValue>(nkvs); |
| 1235 | for (int j = 0; j < nkvs; j++) { |
| 1236 | final int kv_length = buf.readInt(); |
| 1237 | kv = KeyValue.fromBuffer(buf, kv); |
| 1238 | row.add(kv); |
| 1239 | } |
| 1240 | rows.add(row); |
| 1241 | } |
| 1242 | } else { |
| 1243 | for (int i = 0; i < nrows; i++) { |
| 1244 | rows.add(GetRequest.convertResult(resp.getResults(i), buf, cell_size)); |
| 1245 | } |
| 1246 | } |
| 1247 | return rows; |
| 1248 | } |
| 1249 | |
| 1250 | /** RPC method name to use with HBase 0.95+. */ |
| 1251 | private static final byte[] SCAN = new byte[] { 'S', 'c', 'a', 'n' }; |
no test coverage detected