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.hbase.classification.InterfaceAudience;
21 import org.apache.hadoop.hbase.coprocessor.ObserverContext;
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.Private
33 public class MiniBatchOperationInProgress<T> {
34 private final T[] operations;
35 private final OperationStatus[] retCodeDetails;
36 private final WALEdit[] walEditsFromCoprocessors;
37 private final int firstIndex;
38 private final int lastIndexExclusive;
39
40 public MiniBatchOperationInProgress(T[] operations, OperationStatus[] retCodeDetails,
41 WALEdit[] walEditsFromCoprocessors, int firstIndex, int lastIndexExclusive) {
42 this.operations = operations;
43 this.retCodeDetails = retCodeDetails;
44 this.walEditsFromCoprocessors = walEditsFromCoprocessors;
45 this.firstIndex = firstIndex;
46 this.lastIndexExclusive = lastIndexExclusive;
47 }
48
49
50
51
52 public int size() {
53 return this.lastIndexExclusive - this.firstIndex;
54 }
55
56
57
58
59
60 public T getOperation(int index) {
61 return operations[getAbsoluteIndex(index)];
62 }
63
64
65
66
67
68
69
70 public void setOperationStatus(int index, OperationStatus opStatus) {
71 this.retCodeDetails[getAbsoluteIndex(index)] = opStatus;
72 }
73
74
75
76
77
78 public OperationStatus getOperationStatus(int index) {
79 return this.retCodeDetails[getAbsoluteIndex(index)];
80 }
81
82
83
84
85
86
87 public void setWalEdit(int index, WALEdit walEdit) {
88 this.walEditsFromCoprocessors[getAbsoluteIndex(index)] = walEdit;
89 }
90
91
92
93
94
95 public WALEdit getWalEdit(int index) {
96 return this.walEditsFromCoprocessors[getAbsoluteIndex(index)];
97 }
98
99 private int getAbsoluteIndex(int index) {
100 if (index < 0 || this.firstIndex + index >= this.lastIndexExclusive) {
101 throw new ArrayIndexOutOfBoundsException(index);
102 }
103 return this.firstIndex + index;
104 }
105 }