static ArrayList<KeyValue> convertResult(final ClientPB.Result res, final ChannelBuffer buf, final int kvCount) { final int size = res.getCellCount(); final ArrayList<KeyValue> rows = new ArrayList<KeyValue>(size + kvCount); KeyValue kv = null; for (int i = 0; i < size; i++) { kv = KeyValue.fromCell(res.getCell(i), kv); rows.add(kv); } for (int i = 0; i < kvCount; i++) { final int kv_length = buf.readInt(); kv = KeyValue.fromBuffer(buf, kv); rows.add(kv); } return rows; }
/** * Converts a protobuf result into a list of {@link KeyValue}. * @param res The protobuf'ed results from which to extract the KVs. * @param buf The buffer from which the protobuf was read. * @param cell_size The number of bytes of the cell block that follows, * in the buffer. */ static ArrayList<KeyValue> convertResult(final ClientPB.Result res, final ChannelBuffer buf, final int cell_size) { final int cell_kvs = RegionClient.numberOfKeyValuesAhead(buf, cell_size); final int size = res.getCellCount(); final ArrayList<KeyValue> rows = new ArrayList<KeyValue>(size + cell_kvs); KeyValue kv = null; for (int i = 0; i < size; i++) { kv = KeyValue.fromCell(res.getCell(i), kv); rows.add(kv); } for (int i = 0; i < cell_kvs; i++) { final int kv_length = buf.readInt(); kv = KeyValue.fromBuffer(buf, kv); rows.add(kv); } return rows; }
kv = KeyValue.fromBuffer(buf, kv); cells.add(kv);
for (int j = 0; j < nkvs; j++) { final int kv_length = buf.readInt(); kv = KeyValue.fromBuffer(buf, kv); row.add(kv);
/** * De-serializes an {@code hbase.client.Result} object. * @param buf The buffer that contains a serialized {@code Result}. * @return The result parsed into a list of {@link KeyValue} objects. */ private static ArrayList<KeyValue> parseResult(final ChannelBuffer buf) { final int length = buf.readInt(); HBaseRpc.checkArrayLength(buf, length); //LOG.debug("total Result response length={}", length); final int num_kv = numberOfKeyValuesAhead(buf, length); final ArrayList<KeyValue> results = new ArrayList<KeyValue>(num_kv); KeyValue kv = null; for (int i = 0; i < num_kv; i++) { final int kv_length = buf.readInt(); // Previous loop checked it's >0. // Now read a KeyValue that spans over kv_length bytes. kv = KeyValue.fromBuffer(buf, kv); final int key_length = (2 + kv.key().length + 1 + kv.family().length + kv.qualifier().length + 8 + 1); // XXX DEBUG if (key_length + kv.value().length + 4 + 4 != kv_length) { badResponse("kv_length=" + kv_length + " doesn't match key_length + value_length (" + key_length + " + " + kv.value().length + ") in " + buf + '=' + Bytes.pretty(buf)); } results.add(kv); } return results; }
HBaseRpc.checkNonEmptyArrayLength(buf, kv_length); kv = KeyValue.fromBuffer(buf, kv); result.add(kv); bytes_read += 4 + kv_length;