1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.hbase.regionserver;
19
20 import org.apache.hadoop.classification.InterfaceAudience;
21 import org.apache.hadoop.classification.InterfaceStability;
22 import org.apache.hadoop.hbase.coprocessor.RegionObserver;
23 import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
24
25
26
27
28
29
30
31
32 @InterfaceAudience.Public
33 @InterfaceStability.Evolving
34 public class MiniBatchOperationInProgress<T> {
35 private final T[] operations;
36 private final OperationStatus[] retCodeDetails;
37 private final WALEdit[] walEditsFromCoprocessors;
38 private final int firstIndex;
39 private final int lastIndexExclusive;
40
41 public MiniBatchOperationInProgress(T[] operations, OperationStatus[] retCodeDetails,
42 WALEdit[] walEditsFromCoprocessors, int firstIndex, int lastIndexExclusive) {
43 this.operations = operations;
44 this.retCodeDetails = retCodeDetails;
45 this.walEditsFromCoprocessors = walEditsFromCoprocessors;
46 this.firstIndex = firstIndex;
47 this.lastIndexExclusive = lastIndexExclusive;
48 }
49
50
51
52
53 public int size() {
54 return this.lastIndexExclusive - this.firstIndex;
55 }
56
57
58
59
60
61 public T getOperation(int index) {
62 return operations[getAbsoluteIndex(index)];
63 }
64
65
66
67
68
69
70
71 public void setOperationStatus(int index, OperationStatus opStatus) {
72 this.retCodeDetails[getAbsoluteIndex(index)] = opStatus;
73 }
74
75
76
77
78
79 public OperationStatus getOperationStatus(int index) {
80 return this.retCodeDetails[getAbsoluteIndex(index)];
81 }
82
83
84
85
86
87
88 public void setWalEdit(int index, WALEdit walEdit) {
89 this.walEditsFromCoprocessors[getAbsoluteIndex(index)] = walEdit;
90 }
91
92
93
94
95
96 public WALEdit getWalEdit(int index) {
97 return this.walEditsFromCoprocessors[getAbsoluteIndex(index)];
98 }
99
100 private int getAbsoluteIndex(int index) {
101 if (index < 0 || this.firstIndex + index >= this.lastIndexExclusive) {
102 throw new ArrayIndexOutOfBoundsException(index);
103 }
104 return this.firstIndex + index;
105 }
106 }