Index: src/test/org/apache/hadoop/hbase/regionserver/TestHStoreFile.java =================================================================== --- src/test/org/apache/hadoop/hbase/regionserver/TestHStoreFile.java (revision 693170) +++ src/test/org/apache/hadoop/hbase/regionserver/TestHStoreFile.java (working copy) @@ -228,7 +228,7 @@ // file, one from the top and the other from the bottom. // Test bottom half first. bottom = new HStoreFile.HalfMapFileReader(this.fs, p.toString(), - this.conf, HStoreFile.Range.bottom, midkey); + this.conf, HStoreFile.Range.bottom, midkey, null); boolean first = true; while (bottom.next(key, value)) { previous = key.toString(); @@ -243,7 +243,7 @@ } // Now test reading from the top. top = new HStoreFile.HalfMapFileReader(this.fs, p.toString(), this.conf, - HStoreFile.Range.top, midkey); + HStoreFile.Range.top, midkey, null); first = true; while (top.next(key, value)) { assertTrue(key.compareTo(midkey) >= 0); @@ -264,12 +264,12 @@ // properly. WritableComparable badkey = new HStoreKey(" "); bottom = new HStoreFile.HalfMapFileReader(this.fs, p.toString(), - this.conf, HStoreFile.Range.bottom, badkey); + this.conf, HStoreFile.Range.bottom, badkey, null); // When badkey is < than the bottom, should return no values. assertFalse(bottom.next(key, value)); // Now read from the top. top = new HStoreFile.HalfMapFileReader(this.fs, p.toString(), this.conf, - HStoreFile.Range.top, badkey); + HStoreFile.Range.top, badkey, null); first = true; while (top.next(key, value)) { assertTrue(key.compareTo(badkey) >= 0); @@ -291,7 +291,7 @@ // Test when badkey is > than last key in file ('||' > 'zz'). badkey = new HStoreKey("|||"); bottom = new HStoreFile.HalfMapFileReader(this.fs, p.toString(), - this.conf, HStoreFile.Range.bottom, badkey); + this.conf, HStoreFile.Range.bottom, badkey, null); first = true; while (bottom.next(key, value)) { if (first) { @@ -310,7 +310,7 @@ } // Now look at top. Should not return any values. top = new HStoreFile.HalfMapFileReader(this.fs, p.toString(), this.conf, - HStoreFile.Range.top, badkey); + HStoreFile.Range.top, badkey, null); assertFalse(top.next(key, value)); } finally { @@ -343,12 +343,12 @@ // properly. HStoreKey midkey = new HStoreKey(" "); bottom = new HStoreFile.HalfMapFileReader(this.fs, p.toString(), - this.conf, HStoreFile.Range.bottom, midkey); + this.conf, HStoreFile.Range.bottom, midkey, null); // When midkey is < than the bottom, should return no values. assertFalse(bottom.next(key, value)); // Now read from the top. top = new HStoreFile.HalfMapFileReader(this.fs, p.toString(), - this.conf, HStoreFile.Range.top, midkey); + this.conf, HStoreFile.Range.top, midkey, null); boolean first = true; while (top.next(key, value)) { assertTrue(key.compareTo(midkey) >= 0); @@ -364,7 +364,7 @@ // Test when midkey is > than last key in file ('||' > 'zz'). midkey = new HStoreKey("|||"); bottom = new HStoreFile.HalfMapFileReader(this.fs, p.toString(), - this.conf, HStoreFile.Range.bottom, midkey); + this.conf, HStoreFile.Range.bottom, midkey, null); first = true; while (bottom.next(key, value)) { if (first) { @@ -377,7 +377,7 @@ assertEquals("zz", Bytes.toString(key.getRow())); // Now look at top. Should not return any values. top = new HStoreFile.HalfMapFileReader(this.fs, p.toString(), - this.conf, HStoreFile.Range.top, midkey); + this.conf, HStoreFile.Range.top, midkey, null); assertFalse(top.next(key, value)); } finally { if (top != null) { Index: src/java/org/apache/hadoop/hbase/regionserver/HStore.java =================================================================== --- src/java/org/apache/hadoop/hbase/regionserver/HStore.java (revision 693170) +++ src/java/org/apache/hadoop/hbase/regionserver/HStore.java (working copy) @@ -298,7 +298,7 @@ } long maxSeqIdInLog = -1; TreeMap reconstructedCache = - new TreeMap(); + new TreeMap(new HStoreKey.HStoreKeyWritableComparator(info)); SequenceFile.Reader logReader = new SequenceFile.Reader(this.fs, reconstructionLog, this.conf); @@ -934,7 +934,7 @@ ImmutableBytesWritable[] vals = new ImmutableBytesWritable[rdrs.length]; boolean[] done = new boolean[rdrs.length]; for(int i = 0; i < rdrs.length; i++) { - keys[i] = new HStoreKey(); + keys[i] = new HStoreKey(HConstants.EMPTY_BYTE_ARRAY, this.info); vals[i] = new ImmutableBytesWritable(); done[i] = false; } @@ -1451,7 +1451,8 @@ // most closely matches what we're looking for. We'll have to update it as // deletes are found all over the place as we go along before finally // reading the best key out of it at the end. - SortedMap candidateKeys = new TreeMap(); + SortedMap candidateKeys = new TreeMap( + new HStoreKey.HStoreKeyWritableComparator(info)); // Keep a list of deleted cell keys. We need this because as we go through // the store files, the cell with the delete marker may be in one file and @@ -1495,7 +1496,7 @@ final byte [] row, final SortedMap candidateKeys, final Set deletes) throws IOException { - HStoreKey startKey = new HStoreKey(); + HStoreKey startKey = new HStoreKey(HConstants.EMPTY_BYTE_ARRAY, this.info); ImmutableBytesWritable startValue = new ImmutableBytesWritable(); synchronized(map) { // Don't bother with the rest of this if the file is empty @@ -1585,7 +1586,7 @@ final Set deletes, final long now) throws IOException { HStoreKey searchKey = sk; - HStoreKey readkey = new HStoreKey(); + HStoreKey readkey = new HStoreKey(HConstants.EMPTY_BYTE_ARRAY, this.info); ImmutableBytesWritable readval = new ImmutableBytesWritable(); HStoreKey knownNoGoodKey = null; for (boolean foundCandidate = false; !foundCandidate;) { @@ -1667,7 +1668,7 @@ final SortedMap candidateKeys, final Set deletes, final long now) throws IOException { - HStoreKey readkey = new HStoreKey(); + HStoreKey readkey = new HStoreKey(HConstants.EMPTY_BYTE_ARRAY, this.info); ImmutableBytesWritable readval = new ImmutableBytesWritable(); // if there are already candidate keys, we need to start our search @@ -1676,7 +1677,8 @@ // of the row in case there are deletes for this candidate in this mapfile // BUT do not backup before the first key in the mapfile else getClosest // will return null - HStoreKey searchKey = new HStoreKey(candidateKeys.firstKey().getRow()); + HStoreKey searchKey = new HStoreKey(candidateKeys.firstKey().getRow(), + this.info); if (searchKey.compareTo(startKey) < 0) { searchKey = startKey; } @@ -1770,7 +1772,7 @@ * @throws IOException */ private HStoreKey getFinalKey(final MapFile.Reader mf) throws IOException { - HStoreKey finalKey = new HStoreKey(); + HStoreKey finalKey = new HStoreKey(HConstants.EMPTY_BYTE_ARRAY, this.info); mf.finalKey(finalKey); return finalKey; } @@ -1860,8 +1862,8 @@ r.reset(); // get the first and last keys - HStoreKey firstKey = new HStoreKey(); - HStoreKey lastKey = new HStoreKey(); + HStoreKey firstKey = new HStoreKey(HConstants.EMPTY_BYTE_ARRAY, this.info); + HStoreKey lastKey = new HStoreKey(HConstants.EMPTY_BYTE_ARRAY, this.info); Writable value = new ImmutableBytesWritable(); r.next(firstKey, value); r.finalKey(lastKey); Index: src/java/org/apache/hadoop/hbase/regionserver/HStoreFile.java =================================================================== --- src/java/org/apache/hadoop/hbase/regionserver/HStoreFile.java (revision 693170) +++ src/java/org/apache/hadoop/hbase/regionserver/HStoreFile.java (working copy) @@ -408,10 +408,10 @@ return new HStoreFile.HalfMapFileReader(fs, getMapFilePath(reference).toString(), conf, reference.getFileRegion(), reference.getMidkey(), bloomFilter, - blockCacheEnabled); + blockCacheEnabled, this.hri); } return new BloomFilterMapFile.Reader(fs, getMapFilePath().toString(), - conf, bloomFilter, blockCacheEnabled); + conf, bloomFilter, blockCacheEnabled, this.hri); } /** @@ -612,9 +612,10 @@ * @param conf * @throws IOException */ - public HbaseReader(FileSystem fs, String dirName, Configuration conf) + public HbaseReader(FileSystem fs, String dirName, Configuration conf, + HRegionInfo hri) throws IOException { - this(fs, dirName, conf, false); + this(fs, dirName, conf, false, hri); } /** @@ -622,14 +623,16 @@ * @param dirName * @param conf * @param blockCacheEnabled + * @param hri * @throws IOException */ public HbaseReader(FileSystem fs, String dirName, Configuration conf, - boolean blockCacheEnabled) + boolean blockCacheEnabled, HRegionInfo hri) throws IOException { - super(fs, dirName, null, conf, false); // defer opening streams + super(fs, dirName, new HStoreKey.HStoreKeyWritableComparator(hri), + conf, false); // defer opening streams this.blockCacheEnabled = blockCacheEnabled; - open(fs, dirName, null, conf); + open(fs, dirName, new HStoreKey.HStoreKeyWritableComparator(hri), conf); // Force reading of the mapfile index by calling midKey. // Reading the index will bring the index into memory over @@ -671,6 +674,7 @@ * @param fs * @param dirName * @param compression + * @param hri * @throws IOException */ public HbaseWriter(Configuration conf, FileSystem fs, String dirName, @@ -703,12 +707,14 @@ * @param conf * @param filter * @param blockCacheEnabled + * @param hri * @throws IOException */ public Reader(FileSystem fs, String dirName, Configuration conf, - final boolean filter, final boolean blockCacheEnabled) + final boolean filter, final boolean blockCacheEnabled, + HRegionInfo hri) throws IOException { - super(fs, dirName, conf, blockCacheEnabled); + super(fs, dirName, conf, blockCacheEnabled, hri); if (filter) { this.bloomFilter = loadBloomFilter(fs, dirName); } else { @@ -894,17 +900,19 @@ HalfMapFileReader(final FileSystem fs, final String dirName, final Configuration conf, final Range r, - final WritableComparable midKey) + final WritableComparable midKey, + final HRegionInfo hri) throws IOException { - this(fs, dirName, conf, r, midKey, false, false); + this(fs, dirName, conf, r, midKey, false, false, hri); } HalfMapFileReader(final FileSystem fs, final String dirName, final Configuration conf, final Range r, final WritableComparable midKey, final boolean filter, - final boolean blockCacheEnabled) + final boolean blockCacheEnabled, + final HRegionInfo hri) throws IOException { - super(fs, dirName, conf, filter, blockCacheEnabled); + super(fs, dirName, conf, filter, blockCacheEnabled, hri); top = isTopFileRegion(r); midkey = midKey; } Index: src/java/org/apache/hadoop/hbase/regionserver/HStoreScanner.java =================================================================== --- src/java/org/apache/hadoop/hbase/regionserver/HStoreScanner.java (revision 693170) +++ src/java/org/apache/hadoop/hbase/regionserver/HStoreScanner.java (working copy) @@ -86,7 +86,7 @@ // Advance to the first key in each scanner. // All results will match the required column-set and scanTime. for (int i = 0; i < scanners.length; i++) { - keys[i] = new HStoreKey(); + keys[i] = new HStoreKey(HConstants.EMPTY_BYTE_ARRAY, store.getHRegionInfo()); resultSets[i] = new TreeMap(Bytes.BYTES_COMPARATOR); if(scanners[i] != null && !scanners[i].next(keys[i], resultSets[i])) { closeScanner(i); Index: src/java/org/apache/hadoop/hbase/regionserver/HRegion.java =================================================================== --- src/java/org/apache/hadoop/hbase/regionserver/HRegion.java (revision 693170) +++ src/java/org/apache/hadoop/hbase/regionserver/HRegion.java (working copy) @@ -1518,7 +1518,8 @@ for (HStore store : stores.values()) { List keys = store.getKeys(new HStoreKey(row, ts, this.regionInfo), ALL_VERSIONS, now); - TreeMap edits = new TreeMap(); + TreeMap edits = new TreeMap( + new HStoreKey.HStoreKeyWritableComparator(regionInfo)); for (HStoreKey key: keys) { edits.put(key, HLogEdit.deleteBytes.get()); } @@ -1550,7 +1551,8 @@ List keys = store.getKeys(new HStoreKey(row, timestamp, this.regionInfo), ALL_VERSIONS, now); // delete all the cells - TreeMap edits = new TreeMap(); + TreeMap edits = new TreeMap( + new HStoreKey.HStoreKeyWritableComparator(regionInfo)); for (HStoreKey key: keys) { edits.put(key, HLogEdit.deleteBytes.get()); } @@ -1578,7 +1580,8 @@ HStoreKey origin = new HStoreKey(row, column, ts, this.regionInfo); Set keys = getKeys(origin, versions); if (keys.size() > 0) { - TreeMap edits = new TreeMap(); + TreeMap edits = new TreeMap( + new HStoreKey.HStoreKeyWritableComparator(regionInfo)); for (HStoreKey key: keys) { edits.put(key, HLogEdit.deleteBytes.get()); } @@ -1614,7 +1617,8 @@ checkReadOnly(); TreeMap targets = this.targetColumns.get(lockid); if (targets == null) { - targets = new TreeMap(); + targets = new TreeMap( + new HStoreKey.HStoreKeyWritableComparator(regionInfo)); this.targetColumns.put(lockid, targets); } targets.put(key, val); @@ -2151,7 +2155,8 @@ try { HStoreKey key = new HStoreKey(row, COL_REGIONINFO, System.currentTimeMillis(), r.getRegionInfo()); - TreeMap edits = new TreeMap(); + TreeMap edits = new TreeMap( + new HStoreKey.HStoreKeyWritableComparator(meta.getRegionInfo())); edits.put(key, Writables.getBytes(r.getRegionInfo())); meta.update(edits); } finally { Index: src/java/org/apache/hadoop/hbase/util/MetaUtils.java =================================================================== --- src/java/org/apache/hadoop/hbase/util/MetaUtils.java (revision 693170) +++ src/java/org/apache/hadoop/hbase/util/MetaUtils.java (working copy) @@ -194,7 +194,8 @@ HConstants.LATEST_TIMESTAMP, null); try { - HStoreKey key = new HStoreKey(); + HStoreKey key = new HStoreKey(HConstants.EMPTY_BYTE_ARRAY, + HRegionInfo.FIRST_META_REGIONINFO); SortedMap results = new TreeMap(Bytes.BYTES_COMPARATOR); while (rootScanner.next(key, results)) { @@ -246,7 +247,8 @@ InternalScanner metaScanner = m.getScanner(HConstants.COL_REGIONINFO_ARRAY, HConstants.EMPTY_START_ROW, HConstants.LATEST_TIMESTAMP, null); try { - HStoreKey key = new HStoreKey(); + HStoreKey key = new HStoreKey(HConstants.EMPTY_BYTE_ARRAY, + HRegionInfo.FIRST_META_REGIONINFO); SortedMap results = new TreeMap(Bytes.BYTES_COMPARATOR); while (metaScanner.next(key, results)) {