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.io.DataInput;
23 import java.io.DataOutput;
24 import java.io.IOException;
25
26 import org.apache.hadoop.hbase.io.HbaseObjectWritable;
27 import org.apache.hadoop.hbase.util.Bytes;
28 import org.apache.hadoop.io.Writable;
29
30
31
32
33
34
35 public class Action implements Writable, Comparable {
36
37 private byte[] regionName;
38 private Row action;
39 private int originalIndex;
40 private Result result;
41
42 public Action() {
43 super();
44 }
45
46 public Action(byte[] regionName, Row action, int originalIndex) {
47 super();
48 this.regionName = regionName;
49 this.action = action;
50 this.originalIndex = originalIndex;
51 }
52
53 public byte[] getRegionName() {
54 return regionName;
55 }
56
57 public void setRegionName(byte[] regionName) {
58 this.regionName = regionName;
59 }
60
61 public Result getResult() {
62 return result;
63 }
64
65 public void setResult(Result result) {
66 this.result = result;
67 }
68
69 public Row getAction() {
70 return action;
71 }
72
73 public int getOriginalIndex() {
74 return originalIndex;
75 }
76
77 @Override
78 public int compareTo(Object o) {
79 return action.compareTo(((Action) o).getAction());
80 }
81
82
83
84
85
86 public void write(final DataOutput out) throws IOException {
87 Bytes.writeByteArray(out, regionName);
88 HbaseObjectWritable.writeObject(out, action, Row.class, null);
89 out.writeInt(originalIndex);
90 HbaseObjectWritable.writeObject(out, result, Result.class, null);
91 }
92
93 public void readFields(final DataInput in) throws IOException {
94 this.regionName = Bytes.readByteArray(in);
95 this.action = (Row) HbaseObjectWritable.readObject(in, null);
96 this.originalIndex = in.readInt();
97 this.result = (Result) HbaseObjectWritable.readObject(in, null);
98 }
99
100 }