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); @@ -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 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/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 {