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.classification.InterfaceAudience;
26 import org.apache.hadoop.classification.InterfaceStability;
27 import org.apache.hadoop.hbase.TableName;
28 import org.apache.hadoop.hbase.HConstants;
29 import org.apache.hadoop.hbase.util.Bytes;
30 import org.apache.hadoop.mapred.InputSplit;
31
32
33
34
35 @Deprecated
36 @InterfaceAudience.Public
37 @InterfaceStability.Stable
38 public class TableSplit implements InputSplit, Comparable<TableSplit> {
39 private TableName m_tableName;
40 private byte [] m_startRow;
41 private byte [] m_endRow;
42 private String m_regionLocation;
43
44
45 public TableSplit() {
46 this((TableName)null, HConstants.EMPTY_BYTE_ARRAY,
47 HConstants.EMPTY_BYTE_ARRAY, "");
48 }
49
50
51
52
53
54
55
56
57 public TableSplit(TableName tableName, byte [] startRow, byte [] endRow,
58 final String location) {
59 this.m_tableName = tableName;
60 this.m_startRow = startRow;
61 this.m_endRow = endRow;
62 this.m_regionLocation = location;
63 }
64
65 public TableSplit(byte [] tableName, byte [] startRow, byte [] endRow,
66 final String location) {
67 this(TableName.valueOf(tableName), startRow, endRow,
68 location);
69 }
70
71
72 public TableName getTable() {
73 return this.m_tableName;
74 }
75
76
77 public byte [] getTableName() {
78 return this.m_tableName.getName();
79 }
80
81
82 public byte [] getStartRow() {
83 return this.m_startRow;
84 }
85
86
87 public byte [] getEndRow() {
88 return this.m_endRow;
89 }
90
91
92 public String getRegionLocation() {
93 return this.m_regionLocation;
94 }
95
96 public String[] getLocations() {
97 return new String[] {this.m_regionLocation};
98 }
99
100 public long getLength() {
101
102 return 0;
103 }
104
105 public void readFields(DataInput in) throws IOException {
106 this.m_tableName = TableName.valueOf(Bytes.readByteArray(in));
107 this.m_startRow = Bytes.readByteArray(in);
108 this.m_endRow = Bytes.readByteArray(in);
109 this.m_regionLocation = Bytes.toString(Bytes.readByteArray(in));
110 }
111
112 public void write(DataOutput out) throws IOException {
113 Bytes.writeByteArray(out, this.m_tableName.getName());
114 Bytes.writeByteArray(out, this.m_startRow);
115 Bytes.writeByteArray(out, this.m_endRow);
116 Bytes.writeByteArray(out, Bytes.toBytes(this.m_regionLocation));
117 }
118
119 @Override
120 public String toString() {
121 return m_regionLocation + ":" +
122 Bytes.toStringBinary(m_startRow) + "," + Bytes.toStringBinary(m_endRow);
123 }
124
125 @Override
126 public int compareTo(TableSplit o) {
127 return Bytes.compareTo(getStartRow(), o.getStartRow());
128 }
129
130 @Override
131 public boolean equals(Object o) {
132 if (o == null || !(o instanceof TableSplit)) {
133 return false;
134 }
135 TableSplit other = (TableSplit)o;
136 return m_tableName.equals(other.m_tableName) &&
137 Bytes.equals(m_startRow, other.m_startRow) &&
138 Bytes.equals(m_endRow, other.m_endRow) &&
139 m_regionLocation.equals(other.m_regionLocation);
140 }
141 }