String regionLocation = regionLocator.getRegionLocation(startKeys[startPos]). getHostname(); splits[i] = new TableSplit(this.table.getName(), startKeys[startPos], ((i + 1) < realNumSplits) ? startKeys[lastPos]: HConstants.EMPTY_START_ROW, regionLocation);
trr.setStartRow(tSplit.getStartRow()); trr.setEndRow(tSplit.getEndRow()); trr.setHTable(this.table); trr.setInputColumns(this.inputColumns);
@Test @SuppressWarnings({"deprecation", "SelfComparison"}) public void testSplitTableCompareTo() { TableSplit aTableSplit = new TableSplit(Bytes.toBytes("tableA"), Bytes.toBytes("aaa"), Bytes.toBytes("ddd"), "locationA"); TableSplit bTableSplit = new TableSplit(Bytes.toBytes("tableA"), Bytes.toBytes("iii"), Bytes.toBytes("kkk"), "locationA"); TableSplit cTableSplit = new TableSplit(Bytes.toBytes("tableA"), Bytes.toBytes("lll"), Bytes.toBytes("zzz"), "locationA"); assertEquals(0, aTableSplit.compareTo(aTableSplit)); assertEquals(0, bTableSplit.compareTo(bTableSplit)); assertEquals(0, cTableSplit.compareTo(cTableSplit)); assertTrue(aTableSplit.compareTo(bTableSplit) < 0); assertTrue(bTableSplit.compareTo(aTableSplit) > 0); assertTrue(aTableSplit.compareTo(cTableSplit) < 0); assertTrue(cTableSplit.compareTo(aTableSplit) > 0); assertTrue(bTableSplit.compareTo(cTableSplit) < 0); assertTrue(cTableSplit.compareTo(bTableSplit) > 0); assertTrue(cTableSplit.compareTo(aTableSplit) > 0); }
@Test @SuppressWarnings("deprecation") public void testSplitTableEquals() { byte[] tableA = Bytes.toBytes("tableA"); byte[] aaa = Bytes.toBytes("aaa"); byte[] ddd = Bytes.toBytes("ddd"); String locationA = "locationA"; TableSplit tablesplit = new TableSplit(tableA, aaa, ddd, locationA); TableSplit tableB = new TableSplit(Bytes.toBytes("tableB"), aaa, ddd, locationA); assertNotEquals(tablesplit.hashCode(), tableB.hashCode()); assertNotEquals(tablesplit, tableB); TableSplit startBbb = new TableSplit(tableA, Bytes.toBytes("bbb"), ddd, locationA); assertNotEquals(tablesplit.hashCode(), startBbb.hashCode()); assertNotEquals(tablesplit, startBbb); TableSplit endEee = new TableSplit(tableA, aaa, Bytes.toBytes("eee"), locationA); assertNotEquals(tablesplit.hashCode(), endEee.hashCode()); assertNotEquals(tablesplit, endEee); TableSplit locationB = new TableSplit(tableA, aaa, ddd, "locationB"); assertNotEquals(tablesplit.hashCode(), locationB.hashCode()); assertNotEquals(tablesplit, locationB); TableSplit same = new TableSplit(tableA, aaa, ddd, locationA); assertEquals(tablesplit.hashCode(), same.hashCode()); assertEquals(tablesplit, same); }
@Test @SuppressWarnings("deprecation") public void testToString() { TableSplit split = new TableSplit(TableName.valueOf(name.getMethodName()), "row-start".getBytes(), "row-end".getBytes(), "location"); String str = "HBase table split(table name: " + name.getMethodName() + ", start row: row-start, " + "end row: row-end, region location: location)"; Assert.assertEquals(str, split.toString()); split = new TableSplit((TableName) null, null, null, null); str = "HBase table split(table name: null, start row: null, " + "end row: null, region location: null)"; Assert.assertEquals(str, split.toString()); } }
@Override public int compareTo(TableSplit o) { return Bytes.compareTo(getStartRow(), o.getStartRow()); }
@Test @SuppressWarnings("deprecation") public void testToString() { TableSplit split = new TableSplit(TableName.valueOf(name.getMethodName()), "row-start".getBytes(), "row-end".getBytes(), "location"); String str = "HBase table split(table name: " + name.getMethodName() + ", start row: row-start, " + "end row: row-end, region location: location)"; Assert.assertEquals(str, split.toString()); split = new TableSplit((TableName) null, null, null, null); str = "HBase table split(table name: null, start row: null, " + "end row: null, region location: null)"; Assert.assertEquals(str, split.toString()); } }
@Test @SuppressWarnings("deprecation") public void testSplitTableEquals() { byte[] tableA = Bytes.toBytes("tableA"); byte[] aaa = Bytes.toBytes("aaa"); byte[] ddd = Bytes.toBytes("ddd"); String locationA = "locationA"; TableSplit tablesplit = new TableSplit(tableA, aaa, ddd, locationA); TableSplit tableB = new TableSplit(Bytes.toBytes("tableB"), aaa, ddd, locationA); assertNotEquals(tablesplit.hashCode(), tableB.hashCode()); assertNotEquals(tablesplit, tableB); TableSplit startBbb = new TableSplit(tableA, Bytes.toBytes("bbb"), ddd, locationA); assertNotEquals(tablesplit.hashCode(), startBbb.hashCode()); assertNotEquals(tablesplit, startBbb); TableSplit endEee = new TableSplit(tableA, aaa, Bytes.toBytes("eee"), locationA); assertNotEquals(tablesplit.hashCode(), endEee.hashCode()); assertNotEquals(tablesplit, endEee); TableSplit locationB = new TableSplit(tableA, aaa, ddd, "locationB"); assertNotEquals(tablesplit.hashCode(), locationB.hashCode()); assertNotEquals(tablesplit, locationB); TableSplit same = new TableSplit(tableA, aaa, ddd, locationA); assertEquals(tablesplit.hashCode(), same.hashCode()); assertEquals(tablesplit, same); }
public int compareTo(TableSplit o) { return Bytes.compareTo(getStartRow(), o.getStartRow()); } }
/** * Builds a TableRecordReader. If no TableRecordReader was provided, uses * the default. * * @see org.apache.hadoop.mapred.InputFormat#getRecordReader(InputSplit, * JobConf, Reporter) */ public RecordReader<ImmutableBytesWritable, Result> getRecordReader( InputSplit split, JobConf job, Reporter reporter) throws IOException { TableSplit tSplit = (TableSplit) split; TableRecordReader trr = this.tableRecordReader; // if no table record reader was provided use default if (trr == null) { trr = new TableRecordReader(); } trr.setStartRow(tSplit.getStartRow()); trr.setEndRow(tSplit.getEndRow()); trr.setHTable(this.table); trr.setInputColumns(this.inputColumns); trr.setRowFilter(this.rowFilter); trr.init(); return trr; }
private InputSplit[] convertSplits(List<org.apache.hadoop.mapreduce.InputSplit> splits) { InputSplit[] converted = new InputSplit[splits.size()]; for (int i = 0; i < splits.size(); i++) { org.apache.hadoop.hbase.mapreduce.TableSplit tableSplit = (org.apache.hadoop.hbase.mapreduce.TableSplit) splits.get(i); TableSplit newTableSplit = new TableSplit(tableSplit.getTableName(), tableSplit.getStartRow(), tableSplit.getEndRow(), tableSplit.getRegionLocation()); converted[i] = newTableSplit; } return converted; }
@Test @SuppressWarnings("deprecation") public void testToString() { TableSplit split = new TableSplit(TableName.valueOf(name.getMethodName()), "row-start".getBytes(), "row-end".getBytes(), "location"); String str = "HBase table split(table name: " + name.getMethodName() + ", start row: row-start, " + "end row: row-end, region location: location)"; Assert.assertEquals(str, split.toString()); split = new TableSplit((TableName) null, null, null, null); str = "HBase table split(table name: null, start row: null, " + "end row: null, region location: null)"; Assert.assertEquals(str, split.toString()); } }
@Test @SuppressWarnings({"deprecation", "SelfComparison"}) public void testSplitTableCompareTo() { TableSplit aTableSplit = new TableSplit(Bytes.toBytes("tableA"), Bytes.toBytes("aaa"), Bytes.toBytes("ddd"), "locationA"); TableSplit bTableSplit = new TableSplit(Bytes.toBytes("tableA"), Bytes.toBytes("iii"), Bytes.toBytes("kkk"), "locationA"); TableSplit cTableSplit = new TableSplit(Bytes.toBytes("tableA"), Bytes.toBytes("lll"), Bytes.toBytes("zzz"), "locationA"); assertEquals(0, aTableSplit.compareTo(aTableSplit)); assertEquals(0, bTableSplit.compareTo(bTableSplit)); assertEquals(0, cTableSplit.compareTo(cTableSplit)); assertTrue(aTableSplit.compareTo(bTableSplit) < 0); assertTrue(bTableSplit.compareTo(aTableSplit) > 0); assertTrue(aTableSplit.compareTo(cTableSplit) < 0); assertTrue(cTableSplit.compareTo(aTableSplit) > 0); assertTrue(bTableSplit.compareTo(cTableSplit) < 0); assertTrue(cTableSplit.compareTo(bTableSplit) > 0); assertTrue(cTableSplit.compareTo(aTableSplit) > 0); }
@Test @SuppressWarnings("deprecation") public void testSplitTableEquals() { byte[] tableA = Bytes.toBytes("tableA"); byte[] aaa = Bytes.toBytes("aaa"); byte[] ddd = Bytes.toBytes("ddd"); String locationA = "locationA"; TableSplit tablesplit = new TableSplit(tableA, aaa, ddd, locationA); TableSplit tableB = new TableSplit(Bytes.toBytes("tableB"), aaa, ddd, locationA); assertNotEquals(tablesplit.hashCode(), tableB.hashCode()); assertNotEquals(tablesplit, tableB); TableSplit startBbb = new TableSplit(tableA, Bytes.toBytes("bbb"), ddd, locationA); assertNotEquals(tablesplit.hashCode(), startBbb.hashCode()); assertNotEquals(tablesplit, startBbb); TableSplit endEee = new TableSplit(tableA, aaa, Bytes.toBytes("eee"), locationA); assertNotEquals(tablesplit.hashCode(), endEee.hashCode()); assertNotEquals(tablesplit, endEee); TableSplit locationB = new TableSplit(tableA, aaa, ddd, "locationB"); assertNotEquals(tablesplit.hashCode(), locationB.hashCode()); assertNotEquals(tablesplit, locationB); TableSplit same = new TableSplit(tableA, aaa, ddd, locationA); assertEquals(tablesplit.hashCode(), same.hashCode()); assertEquals(tablesplit, same); }
@Override public int compareTo(TableSplit o) { return Bytes.compareTo(getStartRow(), o.getStartRow()); }
@Override public RecordReader<ImmutableBytesWritable, ResultWritable> getRecordReader( InputSplit split, JobConf job, Reporter reporter) throws IOException { String jobString = job.get(HCatConstants.HCAT_KEY_JOB_INFO); InputJobInfo inputJobInfo = (InputJobInfo) HCatUtil.deserialize(jobString); String tableName = job.get(TableInputFormat.INPUT_TABLE); TableSplit tSplit = (TableSplit) split; HbaseSnapshotRecordReader recordReader = new HbaseSnapshotRecordReader(inputJobInfo, job); inputFormat.setConf(job); Scan inputScan = inputFormat.getScan(); // TODO: Make the caching configurable by the user inputScan.setCaching(200); inputScan.setCacheBlocks(false); Scan sc = new Scan(inputScan); sc.setStartRow(tSplit.getStartRow()); sc.setStopRow(tSplit.getEndRow()); recordReader.setScan(sc); recordReader.setHTable(new HTable(job, tableName)); recordReader.init(); return recordReader; }
String regionLocation = table.getRegionLocation(startKeys[startPos]). getHostname(); splits[i] = new TableSplit(this.table.getTableName(), startKeys[startPos], ((i + 1) < realNumSplits) ? startKeys[lastPos]: HConstants.EMPTY_START_ROW, regionLocation);
@Test @SuppressWarnings({"deprecation", "SelfComparison"}) public void testSplitTableCompareTo() { TableSplit aTableSplit = new TableSplit(Bytes.toBytes("tableA"), Bytes.toBytes("aaa"), Bytes.toBytes("ddd"), "locationA"); TableSplit bTableSplit = new TableSplit(Bytes.toBytes("tableA"), Bytes.toBytes("iii"), Bytes.toBytes("kkk"), "locationA"); TableSplit cTableSplit = new TableSplit(Bytes.toBytes("tableA"), Bytes.toBytes("lll"), Bytes.toBytes("zzz"), "locationA"); assertEquals(0, aTableSplit.compareTo(aTableSplit)); assertEquals(0, bTableSplit.compareTo(bTableSplit)); assertEquals(0, cTableSplit.compareTo(cTableSplit)); assertTrue(aTableSplit.compareTo(bTableSplit) < 0); assertTrue(bTableSplit.compareTo(aTableSplit) > 0); assertTrue(aTableSplit.compareTo(cTableSplit) < 0); assertTrue(cTableSplit.compareTo(aTableSplit) > 0); assertTrue(bTableSplit.compareTo(cTableSplit) < 0); assertTrue(cTableSplit.compareTo(bTableSplit) > 0); assertTrue(cTableSplit.compareTo(aTableSplit) > 0); }
@Override public int compareTo(TableSplit o) { return Bytes.compareTo(getStartRow(), o.getStartRow()); }
trr.setStartRow(tSplit.getStartRow()); trr.setEndRow(tSplit.getEndRow()); trr.setHTable(this.table); trr.setInputColumns(this.inputColumns);