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