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 java.util.HashMap;
23 import java.util.Map;
24 import java.util.TreeMap;
25
26 import org.apache.hadoop.hbase.classification.InterfaceAudience;
27 import org.apache.hadoop.hbase.util.Bytes;
28
29
30
31
32 @InterfaceAudience.Private
33 public class MultiResponse {
34
35
36 private Map<byte[], Map<Integer, Object>> results =
37 new TreeMap<byte[], Map<Integer, Object>>(Bytes.BYTES_COMPARATOR);
38
39
40
41
42
43 private Map<byte[], Throwable> exceptions =
44 new TreeMap<byte[], Throwable>(Bytes.BYTES_COMPARATOR);
45
46 public MultiResponse() {
47 super();
48 }
49
50
51
52
53 public int size() {
54 int size = 0;
55 for (Map<?,?> c : results.values()) {
56 size += c.size();
57 }
58 return size;
59 }
60
61
62
63
64
65
66
67
68 public void add(byte[] regionName, int originalIndex, Object resOrEx) {
69 Map<Integer, Object> rs = results.get(regionName);
70 if (rs == null) {
71 rs = new HashMap<Integer, Object>();
72 results.put(regionName, rs);
73 }
74 rs.put(originalIndex, resOrEx);
75 }
76
77 public Map<byte[], Map<Integer, Object>> getResults() {
78 return results;
79 }
80
81 public void addException(byte []regionName, Throwable ie){
82 exceptions.put(regionName, ie);
83 }
84
85
86
87
88 public Throwable getException(byte []regionName){
89 return exceptions.get(regionName);
90 }
91
92 public Map<byte[], Throwable> getExceptions() {
93 return exceptions;
94 }
95 }