You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2008/08/12 21:16:26 UTC

svn commit: r685272 - in /hadoop/hbase: branches/0.2/CHANGES.txt branches/0.2/src/java/org/apache/hadoop/hbase/io/HbaseMapWritable.java branches/0.2/src/java/org/apache/hadoop/hbase/io/RowResult.java trunk/CHANGES.txt

Author: stack
Date: Tue Aug 12 12:16:24 2008
New Revision: 685272

URL: http://svn.apache.org/viewvc?rev=685272&view=rev
Log:
HBASE-806 Change HbaseMapWritable and RowResult to implement SortedMap instead of Map

Modified:
    hadoop/hbase/branches/0.2/CHANGES.txt
    hadoop/hbase/branches/0.2/src/java/org/apache/hadoop/hbase/io/HbaseMapWritable.java
    hadoop/hbase/branches/0.2/src/java/org/apache/hadoop/hbase/io/RowResult.java
    hadoop/hbase/trunk/CHANGES.txt

Modified: hadoop/hbase/branches/0.2/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.2/CHANGES.txt?rev=685272&r1=685271&r2=685272&view=diff
==============================================================================
--- hadoop/hbase/branches/0.2/CHANGES.txt (original)
+++ hadoop/hbase/branches/0.2/CHANGES.txt Tue Aug 12 12:16:24 2008
@@ -23,6 +23,8 @@
               friendly" way.
    HBASE-816  TableMap should survive USE (Andrew Purtell via Stack)
    HBASE-812  Compaction needs little better skip algo (Daniel Leffel via Stack)
+   HBASE-806  Change HbaseMapWritable and RowResult to implement SortedMap
+              instead of Map (Jonathan Gray via Stack)
 
   NEW FEATURES
   OPTIMIZATIONS

Modified: hadoop/hbase/branches/0.2/src/java/org/apache/hadoop/hbase/io/HbaseMapWritable.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.2/src/java/org/apache/hadoop/hbase/io/HbaseMapWritable.java?rev=685272&r1=685271&r2=685272&view=diff
==============================================================================
--- hadoop/hbase/branches/0.2/src/java/org/apache/hadoop/hbase/io/HbaseMapWritable.java (original)
+++ hadoop/hbase/branches/0.2/src/java/org/apache/hadoop/hbase/io/HbaseMapWritable.java Tue Aug 12 12:16:24 2008
@@ -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 <K, V>
-implements Map<byte [], V>, Writable, Configurable {
+implements SortedMap<byte [], V>, Writable, Configurable {
   private AtomicReference<Configuration> conf =
     new AtomicReference<Configuration>();
   
@@ -74,7 +76,7 @@
     CODE_TO_CLASS.put(code, clazz);
   }
   
-  private Map<byte [], V> instance =
+  private SortedMap<byte [], V> instance =
     new TreeMap<byte [], V>(Bytes.BYTES_COMPARATOR);
 
   /** @return the conf */
@@ -131,6 +133,42 @@
   public Collection<V> values() {
     return instance.values();
   }
+
+  public void putAll(Map<? extends byte [], ? extends V> 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<? super byte[]> comparator() {
+    return this.instance.comparator();
+  }
+
+  public byte[] firstKey() {
+    return this.instance.firstKey();
+  }
+
+  public SortedMap<byte[], V> headMap(byte[] toKey) {
+    return this.instance.headMap(toKey);
+  }
+
+  public byte[] lastKey() {
+    return this.instance.lastKey();
+  }
+
+  public SortedMap<byte[], V> subMap(byte[] fromKey, byte[] toKey) {
+    return this.instance.subMap(fromKey, toKey);
+  }
+
+  public SortedMap<byte[], V> tailMap(byte[] fromKey) {
+    return this.instance.tailMap(fromKey);
+  }
   
   // Writable
 
@@ -187,16 +225,4 @@
       this.instance.put(key, v);
     }
   }
-
-  public void putAll(Map<? extends byte [], ? extends V> 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

Modified: hadoop/hbase/branches/0.2/src/java/org/apache/hadoop/hbase/io/RowResult.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.2/src/java/org/apache/hadoop/hbase/io/RowResult.java?rev=685272&r1=685271&r2=685272&view=diff
==============================================================================
--- hadoop/hbase/branches/0.2/src/java/org/apache/hadoop/hbase/io/RowResult.java (original)
+++ hadoop/hbase/branches/0.2/src/java/org/apache/hadoop/hbase/io/RowResult.java Tue Aug 12 12:16:24 2008
@@ -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<byte [], Cell> {
+public class RowResult implements Writable, SortedMap<byte [], Cell> {
   private byte [] row = null;
   private final HbaseMapWritable<byte [], Cell> cells;
 
@@ -136,6 +138,31 @@
   public Cell get(String key) {
     return get(Bytes.toBytes(key));
   }
+  
+
+  public Comparator<? super byte[]> comparator() {
+    return this.cells.comparator();
+  }
+
+  public byte[] firstKey() {
+    return this.cells.firstKey();
+  }
+
+  public SortedMap<byte[], Cell> headMap(byte[] toKey) {
+    return this.cells.headMap(toKey);
+  }
+
+  public byte[] lastKey() {
+    return this.cells.lastKey();
+  }
+
+  public SortedMap<byte[], Cell> subMap(byte[] fromKey, byte[] toKey) {
+    return this.cells.subMap(fromKey, toKey);
+  }
+
+  public SortedMap<byte[], Cell> tailMap(byte[] fromKey) {
+    return this.cells.tailMap(fromKey);
+  }
 
   /**
    * Row entry.

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=685272&r1=685271&r2=685272&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Tue Aug 12 12:16:24 2008
@@ -23,6 +23,8 @@
               friendly" way.
    HBASE-816  TableMap should survive USE (Andrew Purtell via Stack)
    HBASE-812  Compaction needs little better skip algo (Daniel Leffel via Stack)
+   HBASE-806  Change HbaseMapWritable and RowResult to implement SortedMap
+              instead of Map (Jonathan Gray via Stack)
 
   NEW FEATURES
    HBASE-787  Postgresql to HBase table replication example (Tim Sell via Stack)