Index: src/java/org/apache/hadoop/hbase/io/RowResult.java =================================================================== --- src/java/org/apache/hadoop/hbase/io/RowResult.java (revision 684584) +++ src/java/org/apache/hadoop/hbase/io/RowResult.java (working copy) @@ -25,8 +25,10 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.Comparator; import java.util.Map; import java.util.Set; +import java.util.SortedMap; import java.util.TreeSet; import org.apache.hadoop.hbase.HConstants; @@ -37,7 +39,7 @@ /** * Holds row name and then a map of columns to cells. */ -public class RowResult implements Writable, Map { +public class RowResult implements Writable, SortedMap { private byte [] row = null; private final HbaseMapWritable cells; @@ -136,7 +138,32 @@ public Cell get(String key) { return get(Bytes.toBytes(key)); } + + public Comparator comparator() { + return this.cells.comparator(); + } + + public byte[] firstKey() { + return this.cells.firstKey(); + } + + public SortedMap headMap(byte[] toKey) { + return this.cells.headMap(toKey); + } + + public byte[] lastKey() { + return this.cells.lastKey(); + } + + public SortedMap subMap(byte[] fromKey, byte[] toKey) { + return this.cells.subMap(fromKey, toKey); + } + + public SortedMap tailMap(byte[] fromKey) { + return this.cells.tailMap(fromKey); + } + /** * Row entry. */ Index: src/java/org/apache/hadoop/hbase/io/HbaseMapWritable.java =================================================================== --- src/java/org/apache/hadoop/hbase/io/HbaseMapWritable.java (revision 684584) +++ src/java/org/apache/hadoop/hbase/io/HbaseMapWritable.java (working copy) @@ -23,9 +23,11 @@ import java.io.DataOutput; import java.io.IOException; import java.util.Collection; +import java.util.Comparator; import java.util.HashMap; import java.util.Map; import java.util.Set; +import java.util.SortedMap; import java.util.TreeMap; import java.util.concurrent.atomic.AtomicReference; @@ -47,7 +49,7 @@ * only. */ public class HbaseMapWritable -implements Map, Writable, Configurable { +implements SortedMap, Writable, Configurable { private AtomicReference conf = new AtomicReference(); @@ -74,7 +76,7 @@ CODE_TO_CLASS.put(code, clazz); } - private Map instance = + private SortedMap instance = new TreeMap(Bytes.BYTES_COMPARATOR); /** @return the conf */ @@ -131,6 +133,42 @@ public Collection values() { return instance.values(); } + + public void putAll(Map m) { + this.instance.putAll(m); + } + + public V remove(Object key) { + return this.instance.remove(key); + } + + public V put(byte [] key, V value) { + return this.instance.put(key, value); + } + + public Comparator comparator() { + return this.instance.comparator(); + } + + public byte[] firstKey() { + return this.instance.firstKey(); + } + + public SortedMap headMap(byte[] toKey) { + return this.instance.headMap(toKey); + } + + public byte[] lastKey() { + return this.instance.lastKey(); + } + + public SortedMap subMap(byte[] fromKey, byte[] toKey) { + return this.instance.subMap(fromKey, toKey); + } + + public SortedMap tailMap(byte[] fromKey) { + return this.instance.tailMap(fromKey); + } // Writable @@ -187,16 +225,4 @@ this.instance.put(key, v); } } - - public void putAll(Map m) { - this.instance.putAll(m); - } - - public V remove(Object key) { - return this.instance.remove(key); - } - - public V put(byte [] key, V value) { - return this.instance.put(key, value); - } } \ No newline at end of file