1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.hadoop.hbase.client;
21
22 import org.apache.hadoop.classification.InterfaceAudience;
23 import org.apache.hadoop.classification.InterfaceStability;
24 import org.apache.hadoop.hbase.util.Bytes;
25 import org.apache.hadoop.hbase.util.Pair;
26
27 import java.util.ArrayList;
28 import java.util.Collection;
29 import java.util.List;
30 import java.util.Map;
31 import java.util.TreeMap;
32
33
34
35
36 @InterfaceAudience.Public
37 @InterfaceStability.Evolving
38 public class MultiResponse {
39
40
41
42 private Map<byte[], List<Pair<Integer, Object>>> results =
43 new TreeMap<byte[], List<Pair<Integer, Object>>>(Bytes.BYTES_COMPARATOR);
44
45 public MultiResponse() {
46 super();
47 }
48
49
50
51
52 public int size() {
53 int size = 0;
54 for (Collection<?> c : results.values()) {
55 size += c.size();
56 }
57 return size;
58 }
59
60
61
62
63
64
65
66
67
68
69 public void add(byte[] regionName, Pair<Integer, Object> r) {
70 List<Pair<Integer, Object>> rs = results.get(regionName);
71 if (rs == null) {
72 rs = new ArrayList<Pair<Integer, Object>>();
73 results.put(regionName, rs);
74 }
75 rs.add(r);
76 }
77
78 public void add(byte []regionName, int originalIndex, Object resOrEx) {
79 add(regionName, new Pair<Integer,Object>(originalIndex, resOrEx));
80 }
81
82 public Map<byte[], List<Pair<Integer, Object>>> getResults() {
83 return results;
84 }
85 }