De-serializes an hbase.client.Result object. @param buf The buffer that contains a serialized Result. @return The result parsed into a list of KeyValue objects.
(final ChannelBuffer buf)
| 1898 | * @return The result parsed into a list of {@link KeyValue} objects. |
| 1899 | */ |
| 1900 | private static ArrayList<KeyValue> parseResult(final ChannelBuffer buf) { |
| 1901 | final int length = buf.readInt(); |
| 1902 | HBaseRpc.checkArrayLength(buf, length); |
| 1903 | //LOG.debug("total Result response length={}", length); |
| 1904 | |
| 1905 | final int num_kv = numberOfKeyValuesAhead(buf, length); |
| 1906 | |
| 1907 | final ArrayList<KeyValue> results = new ArrayList<KeyValue>(num_kv); |
| 1908 | KeyValue kv = null; |
| 1909 | for (int i = 0; i < num_kv; i++) { |
| 1910 | final int kv_length = buf.readInt(); // Previous loop checked it's >0. |
| 1911 | // Now read a KeyValue that spans over kv_length bytes. |
| 1912 | kv = KeyValue.fromBuffer(buf, kv); |
| 1913 | final int key_length = (2 + kv.key().length + 1 + kv.family().length |
| 1914 | + kv.qualifier().length + 8 + 1); // XXX DEBUG |
| 1915 | if (key_length + kv.value().length + 4 + 4 != kv_length) { |
| 1916 | badResponse("kv_length=" + kv_length |
| 1917 | + " doesn't match key_length + value_length (" |
| 1918 | + key_length + " + " + kv.value().length + ") in " + buf |
| 1919 | + '=' + Bytes.pretty(buf)); |
| 1920 | } |
| 1921 | results.add(kv); |
| 1922 | } |
| 1923 | return results; |
| 1924 | } |
| 1925 | |
| 1926 | /** |
| 1927 | * De-serializes an {@code hbase.client.Result} array. |
no test coverage detected