1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase.mapred;
20
21 import java.io.DataInput;
22 import java.io.DataOutput;
23 import java.io.IOException;
24
25 import org.apache.hadoop.hbase.HConstants;
26 import org.apache.hadoop.hbase.util.Bytes;
27 import org.apache.hadoop.mapred.InputSplit;
28
29
30
31
32 @Deprecated
33 public class TableSplit implements InputSplit, Comparable<TableSplit> {
34 private byte [] m_tableName;
35 private byte [] m_startRow;
36 private byte [] m_endRow;
37 private String m_regionLocation;
38
39
40 public TableSplit() {
41 this(HConstants.EMPTY_BYTE_ARRAY, HConstants.EMPTY_BYTE_ARRAY,
42 HConstants.EMPTY_BYTE_ARRAY, "");
43 }
44
45
46
47
48
49
50
51
52 public TableSplit(byte [] tableName, byte [] startRow, byte [] endRow,
53 final String location) {
54 this.m_tableName = tableName;
55 this.m_startRow = startRow;
56 this.m_endRow = endRow;
57 this.m_regionLocation = location;
58 }
59
60
61 public byte [] getTableName() {
62 return this.m_tableName;
63 }
64
65
66 public byte [] getStartRow() {
67 return this.m_startRow;
68 }
69
70
71 public byte [] getEndRow() {
72 return this.m_endRow;
73 }
74
75
76 public String getRegionLocation() {
77 return this.m_regionLocation;
78 }
79
80 public String[] getLocations() {
81 return new String[] {this.m_regionLocation};
82 }
83
84 public long getLength() {
85
86 return 0;
87 }
88
89 public void readFields(DataInput in) throws IOException {
90 this.m_tableName = Bytes.readByteArray(in);
91 this.m_startRow = Bytes.readByteArray(in);
92 this.m_endRow = Bytes.readByteArray(in);
93 this.m_regionLocation = Bytes.toString(Bytes.readByteArray(in));
94 }
95
96 public void write(DataOutput out) throws IOException {
97 Bytes.writeByteArray(out, this.m_tableName);
98 Bytes.writeByteArray(out, this.m_startRow);
99 Bytes.writeByteArray(out, this.m_endRow);
100 Bytes.writeByteArray(out, Bytes.toBytes(this.m_regionLocation));
101 }
102
103 @Override
104 public String toString() {
105 return m_regionLocation + ":" +
106 Bytes.toStringBinary(m_startRow) + "," + Bytes.toStringBinary(m_endRow);
107 }
108
109 @Override
110 public int compareTo(TableSplit o) {
111 return Bytes.compareTo(getStartRow(), o.getStartRow());
112 }
113
114 @Override
115 public boolean equals(Object o) {
116 if (o == null || !(o instanceof TableSplit)) {
117 return false;
118 }
119 TableSplit other = (TableSplit)o;
120 return Bytes.equals(m_tableName, other.m_tableName) &&
121 Bytes.equals(m_startRow, other.m_startRow) &&
122 Bytes.equals(m_endRow, other.m_endRow) &&
123 m_regionLocation.equals(other.m_regionLocation);
124 }
125 }