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