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/05/16 00:10:50 UTC

svn commit: r656868 [2/10] - in /hadoop/hbase/trunk: ./ src/java/org/apache/hadoop/hbase/ src/java/org/apache/hadoop/hbase/client/ src/java/org/apache/hadoop/hbase/filter/ src/java/org/apache/hadoop/hbase/hql/ src/java/org/apache/hadoop/hbase/io/ src/j...

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HBaseAdmin.java?rev=656868&r1=656867&r2=656868&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HBaseAdmin.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HBaseAdmin.java Thu May 15 15:10:47 2008
@@ -25,24 +25,24 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.hbase.util.Writables;
-import org.apache.hadoop.io.Text;
-import org.apache.hadoop.ipc.RemoteException;
-import org.apache.hadoop.hbase.ipc.HMasterInterface;
-import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HBaseConfiguration;
-import org.apache.hadoop.hbase.MasterNotRunningException;
-import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.HColumnDescriptor;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HRegionLocation;
-import org.apache.hadoop.hbase.TableNotFoundException;
-import org.apache.hadoop.hbase.TableExistsException;
+import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.MasterNotRunningException;
 import org.apache.hadoop.hbase.RemoteExceptionHandler;
-import org.apache.hadoop.hbase.HRegionInfo;
-import org.apache.hadoop.hbase.io.RowResult;
+import org.apache.hadoop.hbase.TableExistsException;
+import org.apache.hadoop.hbase.TableNotFoundException;
 import org.apache.hadoop.hbase.io.Cell;
-
+import org.apache.hadoop.hbase.io.RowResult;
+import org.apache.hadoop.hbase.ipc.HMasterInterface;
 import org.apache.hadoop.hbase.ipc.HRegionInterface;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.Writables;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.ipc.RemoteException;
 
 /**
  * Provides administrative functions for HBase
@@ -50,11 +50,11 @@
 public class HBaseAdmin implements HConstants {
   protected final Log LOG = LogFactory.getLog(this.getClass().getName());
 
-  protected final HConnection connection;
-  protected final long pause;
-  protected final int numRetries;
-  protected volatile HMasterInterface master;
-  
+  private final HConnection connection;
+  private final long pause;
+  private final int numRetries;
+  private volatile HMasterInterface master;
+
   /**
    * Constructor
    * 
@@ -86,11 +86,31 @@
    * @return True if table exists already.
    * @throws MasterNotRunningException
    */
-  public boolean tableExists(final Text tableName) throws MasterNotRunningException {
+  public boolean tableExists(final String tableName)
+  throws MasterNotRunningException {
+    return tableExists(Bytes.toBytes(tableName));
+  }
+
+  /**
+   * @param tableName Table to check.
+   * @return True if table exists already.
+   * @throws MasterNotRunningException
+   */
+  public boolean tableExists(final Text tableName)
+  throws MasterNotRunningException {
+    return tableExists(tableName.getBytes());
+  }
+  
+  /**
+   * @param tableName Table to check.
+   * @return True if table exists already.
+   * @throws MasterNotRunningException
+   */
+  public boolean tableExists(final byte [] tableName)
+  throws MasterNotRunningException {
     if (this.master == null) {
       throw new MasterNotRunningException("master has been shut down");
     }
-    
     return connection.tableExists(tableName);
   }
 
@@ -122,8 +142,8 @@
    */
   public void createTable(HTableDescriptor desc)
   throws IOException {
+    HTableDescriptor.isLegalTableName(desc.getName());
     createTableAsync(desc);
-
     for (int tries = 0; tries < numRetries; tries++) {
       try {
         // Wait for new table to come on-line
@@ -149,7 +169,7 @@
    * 
    * @param desc table descriptor for table
    * 
-   * @throws IllegalArgumentException if the table name is reserved
+   * @throws IllegalArgumentException Bad table name.
    * @throws MasterNotRunningException if master is not running
    * @throws TableExistsException if table already exists (If concurrent
    * threads, the table may have been created between test-for-existence
@@ -161,13 +181,23 @@
     if (this.master == null) {
       throw new MasterNotRunningException("master has been shut down");
     }
-    checkReservedTableName(desc.getName());
+    HTableDescriptor.isLegalTableName(desc.getName());
     try {
       this.master.createTable(desc);
     } catch (RemoteException e) {
       throw RemoteExceptionHandler.decodeRemoteException(e);
     }
   }
+  
+  /**
+   * Deletes a table
+   * 
+   * @param tableName name of table to delete
+   * @throws IOException
+   */
+  public void deleteTable(final Text tableName) throws IOException {
+    deleteTable(tableName.getBytes());
+  }
 
   /**
    * Deletes a table
@@ -175,14 +205,12 @@
    * @param tableName name of table to delete
    * @throws IOException
    */
-  public void deleteTable(Text tableName) throws IOException {
+  public void deleteTable(final byte [] tableName) throws IOException {
     if (this.master == null) {
       throw new MasterNotRunningException("master has been shut down");
     }
-    
-    checkReservedTableName(tableName);
+    HTableDescriptor.isLegalTableName(tableName);
     HRegionLocation firstMetaServer = getFirstMetaServerForTable(tableName);
-
     try {
       this.master.deleteTable(tableName);
     } catch (RemoteException e) {
@@ -204,12 +232,12 @@
           break;
         }
         boolean found = false;
-        for (Map.Entry<Text, Cell> e: values.entrySet()) {
-          if (e.getKey().equals(COL_REGIONINFO)) {
+        for (Map.Entry<byte [], Cell> e: values.entrySet()) {
+          if (Bytes.equals(e.getKey(), COL_REGIONINFO)) {
             info = (HRegionInfo) Writables.getWritable(
               e.getValue().getValue(), info);
             
-            if (info.getTableDesc().getName().equals(tableName)) {
+            if (Bytes.equals(info.getTableDesc().getName(), tableName)) {
               found = true;
             }
           }
@@ -251,12 +279,21 @@
    * @param tableName name of the table
    * @throws IOException
    */
-  public void enableTable(Text tableName) throws IOException {
+  public void enableTable(final Text tableName) throws IOException {
+    enableTable(tableName.getBytes());
+  }
+  
+  /**
+   * Brings a table on-line (enables it)
+   * 
+   * @param tableName name of the table
+   * @throws IOException
+   */
+  public void enableTable(final byte [] tableName) throws IOException {
     if (this.master == null) {
       throw new MasterNotRunningException("master has been shut down");
     }
-    
-    checkReservedTableName(tableName);
+    HTableDescriptor.isLegalTableName(tableName);
     HRegionLocation firstMetaServer = getFirstMetaServerForTable(tableName);
     
     try {
@@ -291,8 +328,8 @@
             break;
           }
           valuesfound += 1;
-          for (Map.Entry<Text, Cell> e: values.entrySet()) {
-            if (e.getKey().equals(COL_REGIONINFO)) {
+          for (Map.Entry<byte [], Cell> e: values.entrySet()) {
+            if (Bytes.equals(e.getKey(), COL_REGIONINFO)) {
               info = (HRegionInfo) Writables.getWritable(
                 e.getValue().getValue(), info);
             
@@ -351,17 +388,25 @@
    * @param tableName name of table
    * @throws IOException
    */
-  public void disableTable(Text tableName) throws IOException {
+  public void disableTable(final Text tableName) throws IOException {
+    disableTable(tableName.getBytes());
+  }
+  
+  /**
+   * Disables a table (takes it off-line) If it is being served, the master
+   * will tell the servers to stop serving it.
+   * 
+   * @param tableName name of table
+   * @throws IOException
+   */
+  public void disableTable(final byte [] tableName) throws IOException {
     if (this.master == null) {
       throw new MasterNotRunningException("master has been shut down");
     }
-    
-    checkReservedTableName(tableName);
+    HTableDescriptor.isLegalTableName(tableName);
     HRegionLocation firstMetaServer = getFirstMetaServerForTable(tableName);
-
     try {
       this.master.disableTable(tableName);
-      
     } catch (RemoteException e) {
       throw RemoteExceptionHandler.decodeRemoteException(e);
     }
@@ -379,7 +424,6 @@
         scannerId =
           server.openScanner(firstMetaServer.getRegionInfo().getRegionName(),
             COL_REGIONINFO_ARRAY, tableName, HConstants.LATEST_TIMESTAMP, null);
-        
         boolean disabled = false;
         while (true) {
           RowResult values = server.next(scannerId);
@@ -390,8 +434,8 @@
             break;
           }
           valuesfound += 1;
-          for (Map.Entry<Text, Cell> e: values.entrySet()) {
-            if (e.getKey().equals(COL_REGIONINFO)) {
+          for (Map.Entry<byte [], Cell> e: values.entrySet()) {
+            if (Bytes.equals(e.getKey(), COL_REGIONINFO)) {
               info = (HRegionInfo) Writables.getWritable(
                 e.getValue().getValue(), info);
             
@@ -449,16 +493,26 @@
    * @param column column descriptor of column to be added
    * @throws IOException
    */
-  public void addColumn(Text tableName, HColumnDescriptor column)
+  public void addColumn(final Text tableName, HColumnDescriptor column)
+  throws IOException {
+    addColumn(tableName.getBytes(), column);
+  }
+  
+  /**
+   * Add a column to an existing table
+   * 
+   * @param tableName name of the table to add column to
+   * @param column column descriptor of column to be added
+   * @throws IOException
+   */
+  public void addColumn(final byte [] tableName, HColumnDescriptor column)
   throws IOException {
     if (this.master == null) {
       throw new MasterNotRunningException("master has been shut down");
     }
-    
-    checkReservedTableName(tableName);
+    HTableDescriptor.isLegalTableName(tableName);
     try {
       this.master.addColumn(tableName, column);
-      
     } catch (RemoteException e) {
       throw RemoteExceptionHandler.decodeRemoteException(e);
     }
@@ -471,16 +525,26 @@
    * @param columnName name of column to be deleted
    * @throws IOException
    */
-  public void deleteColumn(Text tableName, Text columnName)
+  public void deleteColumn(final Text tableName, final Text columnName)
+  throws IOException {
+    deleteColumn(tableName.getBytes(), columnName.getBytes());
+  }
+  
+  /**
+   * Delete a column from a table
+   * 
+   * @param tableName name of table
+   * @param columnName name of column to be deleted
+   * @throws IOException
+   */
+  public void deleteColumn(final byte [] tableName, final byte [] columnName)
   throws IOException {
     if (this.master == null) {
       throw new MasterNotRunningException("master has been shut down");
     }
-    
-    checkReservedTableName(tableName);
+    HTableDescriptor.isLegalTableName(tableName);
     try {
       this.master.deleteColumn(tableName, columnName);
-      
     } catch (RemoteException e) {
       throw RemoteExceptionHandler.decodeRemoteException(e);
     }
@@ -494,17 +558,29 @@
    * @param descriptor new column descriptor to use
    * @throws IOException
    */
-  public void modifyColumn(Text tableName, Text columnName, 
+  public void modifyColumn(final Text tableName, final Text columnName, 
+      HColumnDescriptor descriptor)
+  throws IOException {
+    modifyColumn(tableName.getBytes(), columnName.getBytes(), descriptor);
+  }
+  
+  /**
+   * Modify an existing column family on a table
+   * 
+   * @param tableName name of table
+   * @param columnName name of column to be modified
+   * @param descriptor new column descriptor to use
+   * @throws IOException
+   */
+  public void modifyColumn(final byte [] tableName, final byte [] columnName, 
     HColumnDescriptor descriptor)
   throws IOException {
     if (this.master == null) {
       throw new MasterNotRunningException("master has been shut down");
     }
-    
-    checkReservedTableName(tableName);
+    HTableDescriptor.isLegalTableName(tableName);
     try {
       this.master.modifyColumn(tableName, columnName, descriptor);
-      
     } catch (RemoteException e) {
       throw RemoteExceptionHandler.decodeRemoteException(e);
     }
@@ -519,7 +595,6 @@
     if (this.master == null) {
       throw new MasterNotRunningException("master has been shut down");
     }
-    
     try {
       this.master.shutdown();
     } catch (RemoteException e) {
@@ -529,28 +604,12 @@
     }
   }
 
-  /*
-   * Verifies that the specified table name is not a reserved name
-   * @param tableName - the table name to be checked
-   * @throws IllegalArgumentException - if the table name is reserved
-   */
-  protected void checkReservedTableName(Text tableName) {
-    if (tableName == null || tableName.getLength() <= 0) {
-      throw new IllegalArgumentException("Null or empty table name");
-    }
-    if(tableName.charAt(0) == '-' ||
-        tableName.charAt(0) == '.' ||
-        tableName.find(",") != -1) {
-      throw new IllegalArgumentException(tableName + " is a reserved table name");
-    }
-  }
-  
-  private HRegionLocation getFirstMetaServerForTable(Text tableName)
+  private HRegionLocation getFirstMetaServerForTable(final byte [] tableName)
   throws IOException {
-    Text tableKey = new Text(tableName.toString() + ",,99999999999999");
-    return connection.locateRegion(META_TABLE_NAME, tableKey);
+    return connection.locateRegion(META_TABLE_NAME,
+      HRegionInfo.createRegionName(tableName, null, NINES));
   }
-  
+
   /**
    * Check to see if HBase is running. Throw an exception if not.
    *

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnection.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnection.java?rev=656868&r1=656867&r2=656868&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnection.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnection.java Thu May 15 15:10:47 2008
@@ -21,12 +21,11 @@
 
 import java.io.IOException;
 
-import org.apache.hadoop.io.Text;
-import org.apache.hadoop.hbase.ipc.HMasterInterface;
-import org.apache.hadoop.hbase.MasterNotRunningException;
-import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.HRegionLocation;
 import org.apache.hadoop.hbase.HServerAddress;
+import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.MasterNotRunningException;
+import org.apache.hadoop.hbase.ipc.HMasterInterface;
 import org.apache.hadoop.hbase.ipc.HRegionInterface;
 
 /**
@@ -47,7 +46,7 @@
    * @param tableName Table to check.
    * @return True if table exists already.
    */
-  public boolean tableExists(final Text tableName);
+  public boolean tableExists(final byte [] tableName);
   
   /**
    * List all the userspace tables.  In other words, scan the META table.
@@ -70,7 +69,8 @@
    * question
    * @throws IOException
    */
-  public HRegionLocation locateRegion(Text tableName, Text row)
+  public HRegionLocation locateRegion(final byte [] tableName,
+      final byte [] row)
   throws IOException;
   
   /**
@@ -82,7 +82,8 @@
    * question
    * @throws IOException
    */
-  public HRegionLocation relocateRegion(Text tableName, Text row)
+  public HRegionLocation relocateRegion(final byte [] tableName,
+      final byte [] row)
   throws IOException;  
   
   /** 
@@ -102,7 +103,8 @@
    * @return Location of row.
    * @throws IOException
    */
-  HRegionLocation getRegionLocation(Text tableName, Text row, boolean reload)
+  HRegionLocation getRegionLocation(byte [] tableName, byte [] row,
+    boolean reload)
   throws IOException;
 
   /**

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java?rev=656868&r1=656867&r2=656868&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java Thu May 15 15:10:47 2008
@@ -31,27 +31,26 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.hbase.ipc.HbaseRPC;
-import org.apache.hadoop.hbase.util.Writables;
-import org.apache.hadoop.io.Text;
-import org.apache.hadoop.ipc.RemoteException;
-import org.apache.hadoop.hbase.ipc.HMasterInterface;
-import org.apache.hadoop.hbase.util.SoftSortedMap;
-import org.apache.hadoop.hbase.HTableDescriptor;
-import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HBaseConfiguration;
-import org.apache.hadoop.hbase.MasterNotRunningException;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HRegionLocation;
 import org.apache.hadoop.hbase.HServerAddress;
+import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.LocalHBaseCluster;
-import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.MasterNotRunningException;
 import org.apache.hadoop.hbase.NoServerForRegionException;
-import org.apache.hadoop.hbase.TableNotFoundException;
 import org.apache.hadoop.hbase.RemoteExceptionHandler;
-
-import org.apache.hadoop.hbase.ipc.HRegionInterface;
+import org.apache.hadoop.hbase.TableNotFoundException;
 import org.apache.hadoop.hbase.io.Cell;
 import org.apache.hadoop.hbase.io.RowResult;
+import org.apache.hadoop.hbase.ipc.HMasterInterface;
+import org.apache.hadoop.hbase.ipc.HRegionInterface;
+import org.apache.hadoop.hbase.ipc.HbaseRPC;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.SoftSortedMap;
+import org.apache.hadoop.hbase.util.Writables;
+import org.apache.hadoop.ipc.RemoteException;
 
 /**
  * A non-instantiable class that manages connections to multiple tables in
@@ -68,7 +67,6 @@
   // A Map of master HServerAddress -> connection information for that instance
   // Note that although the Map is synchronized, the objects it contains
   // are mutable and hence require synchronized access to them
-  
   private static final Map<String, TableServers> HBASE_INSTANCES =
     Collections.synchronizedMap(new HashMap<String, TableServers>());
 
@@ -126,9 +124,9 @@
 
     private HRegionLocation rootRegionLocation; 
     
-    private Map<Text, SoftSortedMap<Text, HRegionLocation>> 
-      cachedRegionLocations = new ConcurrentHashMap<Text, 
-        SoftSortedMap<Text, HRegionLocation>>();
+    private Map<Integer, SoftSortedMap<byte [], HRegionLocation>> 
+      cachedRegionLocations = Collections.synchronizedMap(
+         new HashMap<Integer, SoftSortedMap<byte [], HRegionLocation>>());
     
     /** 
      * constructor
@@ -221,18 +219,18 @@
     }
 
     /** {@inheritDoc} */
-    public boolean tableExists(final Text tableName) {
+    public boolean tableExists(final byte [] tableName) {
       if (tableName == null) {
         throw new IllegalArgumentException("Table name cannot be null");
       }
-      if (tableName.equals(ROOT_TABLE_NAME) || tableName.equals(META_TABLE_NAME)) {
+      if (isMetaTableName(tableName)) {
         return true;
       }
       boolean exists = false;
       try {
         HTableDescriptor[] tables = listTables();
         for (int i = 0; i < tables.length; i++) {
-          if (tables[i].getName().equals(tableName)) {
+          if (Bytes.equals(tables[i].getName(), tableName)) {
             exists = true;
           }
         }
@@ -241,19 +239,28 @@
       }
       return exists;
     }
+    
+    /*
+     * @param n
+     * @return Truen if passed tablename <code>n</code> is equal to the name
+     * of a catalog table.
+     */
+    private static boolean isMetaTableName(final byte [] n) {
+      return Bytes.equals(n, ROOT_TABLE_NAME) ||
+        Bytes.equals(n, META_TABLE_NAME);
+    }
 
     /** {@inheritDoc} */
-    public HRegionLocation getRegionLocation(Text tableName, Text row,
-        boolean reload) throws IOException {
-      return reload ?
-          relocateRegion(tableName, row) :
-            locateRegion(tableName, row);
+    public HRegionLocation getRegionLocation(final byte [] name,
+        final byte [] row, boolean reload)
+    throws IOException {
+      return reload? relocateRegion(name, row): locateRegion(name, row);
     }
 
     /** {@inheritDoc} */
     public HTableDescriptor[] listTables() throws IOException {
       HashSet<HTableDescriptor> uniqueTables = new HashSet<HTableDescriptor>();
-      Text startRow = EMPTY_START_ROW;
+      byte [] startRow = EMPTY_START_ROW;
 
       // scan over the each meta region
       do {
@@ -273,7 +280,7 @@
               Writables.getHRegionInfo(values.get(COL_REGIONINFO));
 
             // Only examine the rows where the startKey is zero length   
-            if (info.getStartKey().getLength() == 0) {
+            if (info.getStartKey().length == 0) {
               uniqueTables.add(info.getTableDesc());
             }
           }
@@ -284,32 +291,34 @@
           callable.setClose();
           getRegionServerWithRetries(callable);
         }
-      } while (startRow.compareTo(LAST_ROW) != 0);
+      } while (Bytes.compareTo(startRow, LAST_ROW) != 0);
       
       return uniqueTables.toArray(new HTableDescriptor[uniqueTables.size()]);
     }
 
     /** {@inheritDoc} */
-    public HRegionLocation locateRegion(Text tableName, Text row)
+    public HRegionLocation locateRegion(final byte [] tableName,
+        final byte [] row)
     throws IOException{
       return locateRegion(tableName, row, true);
     }
 
     /** {@inheritDoc} */
-    public HRegionLocation relocateRegion(Text tableName, Text row)
+    public HRegionLocation relocateRegion(final byte [] tableName,
+        final byte [] row)
     throws IOException{
       return locateRegion(tableName, row, false);
     }
 
-    private HRegionLocation locateRegion(Text tableName, Text row, 
-      boolean useCache)
+    private HRegionLocation locateRegion(final byte [] tableName,
+        final byte [] row, boolean useCache)
     throws IOException{
-      if (tableName == null || tableName.getLength() == 0) {
+      if (tableName == null || tableName.length == 0) {
         throw new IllegalArgumentException(
             "table name cannot be null or zero length");
       }
             
-      if (tableName.equals(ROOT_TABLE_NAME)) {
+      if (Bytes.equals(tableName, ROOT_TABLE_NAME)) {
         synchronized (rootRegionLock) {
           // This block guards against two threads trying to find the root
           // region at the same time. One will go do the find while the 
@@ -320,7 +329,7 @@
           }
           return rootRegionLocation;
         }        
-      } else if (tableName.equals(META_TABLE_NAME)) {
+      } else if (Bytes.equals(tableName, META_TABLE_NAME)) {
         synchronized (metaRegionLock) {
           // This block guards against two threads trying to load the meta 
           // region at the same time. The first will load the meta region and
@@ -339,8 +348,8 @@
       * Search one of the meta tables (-ROOT- or .META.) for the HRegionLocation
       * info that contains the table and row we're seeking.
       */
-    private HRegionLocation locateRegionInMeta(Text parentTable,
-      Text tableName, Text row, boolean useCache)
+    private HRegionLocation locateRegionInMeta(final byte [] parentTable,
+      final byte [] tableName, final byte [] row, boolean useCache)
     throws IOException{
       HRegionLocation location = null;
       
@@ -359,13 +368,9 @@
       // build the key of the meta region we should be looking for.
       // the extra 9's on the end are necessary to allow "exact" matches
       // without knowing the precise region names.
-      Text metaKey = new Text(tableName.toString() + "," 
-        + row.toString() + ",999999999999999");
-
-      int tries = 0;
-      while (true) {
-        tries++;
-        
+      byte [] metaKey = HRegionInfo.createRegionName(tableName, row,
+        HConstants.NINES);
+      for (int tries = 0; true; tries++) {
         if (tries >= numRetries) {
           throw new NoServerForRegionException("Unable to find region for " 
             + row + " after " + numRetries + " tries.");
@@ -382,15 +387,15 @@
             metaLocation.getRegionInfo().getRegionName(), metaKey);
 
           if (regionInfoRow == null) {
-            throw new TableNotFoundException("Table '" + tableName + 
-              "' does not exist.");
+            throw new TableNotFoundException("Table '" +
+              Bytes.toString(tableName) + "' does not exist.");
           }
 
           Cell value = regionInfoRow.get(COL_REGIONINFO);
 
           if (value == null || value.getValue().length == 0) {
             throw new IOException("HRegionInfo was null or empty in " + 
-              parentTable);
+              Bytes.toString(parentTable));
           }
 
           // convert the row result into the HRegionLocation we need!
@@ -398,9 +403,9 @@
               value.getValue(), new HRegionInfo());
 
           // possible we got a region of a different table...
-          if (!regionInfo.getTableDesc().getName().equals(tableName)) {
+          if (!Bytes.equals(regionInfo.getTableDesc().getName(), tableName)) {
             throw new TableNotFoundException(
-              "Table '" + tableName + "' was not found.");
+              "Table '" + Bytes.toString(tableName) + "' was not found.");
           }
 
           if (regionInfo.isOffline()) {
@@ -412,9 +417,9 @@
             Writables.cellToString(regionInfoRow.get(COL_SERVER));
         
           if (serverAddress.equals("")) { 
-            throw new NoServerForRegionException(
-              "No server address listed in " + parentTable + " for region "
-              + regionInfo.getRegionName());
+            throw new NoServerForRegionException("No server address listed " +
+              "in " + Bytes.toString(parentTable) + " for region " +
+              regionInfo.getRegionNameAsString());
           }
         
           // instantiate the location
@@ -452,81 +457,98 @@
       }
     }
 
-    /** 
-      * Search the cache for a location that fits our table and row key.
-      * Return null if no suitable region is located. TODO: synchronization note
-      */
-    private HRegionLocation getCachedLocation(Text tableName, Text row) {
+    /*
+     * Search the cache for a location that fits our table and row key.
+     * Return null if no suitable region is located. TODO: synchronization note
+     * 
+     * <p>TODO: This method during writing consumes 15% of CPU doing lookup
+     * into the Soft Reference SortedMap.  Improve.
+     * 
+     * @param tableName
+     * @param row
+     * @return Null or region location found in cache.
+     */
+    private HRegionLocation getCachedLocation(final byte [] tableName,
+        final byte [] row) {
       // find the map of cached locations for this table
-      SoftSortedMap<Text, HRegionLocation> tableLocations = 
-        cachedRegionLocations.get(tableName);
+      Integer key = Bytes.mapKey(tableName);
+      SoftSortedMap<byte [], HRegionLocation> tableLocations =
+        cachedRegionLocations.get(key);
 
       // if tableLocations for this table isn't built yet, make one
       if (tableLocations == null) {
-        tableLocations = new SoftSortedMap<Text, HRegionLocation>();
-        cachedRegionLocations.put(tableName, tableLocations);
+        tableLocations = new SoftSortedMap<byte [],
+          HRegionLocation>(Bytes.BYTES_COMPARATOR);
+        cachedRegionLocations.put(key, tableLocations);
       }
 
       // start to examine the cache. we can only do cache actions
       // if there's something in the cache for this table.
-      if (!tableLocations.isEmpty()) {
-        if (tableLocations.containsKey(row)) {
-          HRegionLocation rl = tableLocations.get(row);
-          if (rl != null && LOG.isDebugEnabled()) {
-            LOG.debug("Cache hit in table locations for row <" +
-              row + "> and tableName " + tableName +
-              ": location server " + rl.getServerAddress() +
-              ", location region name " + rl.getRegionInfo().getRegionName());
-          }
-          return rl;
+      if (tableLocations.isEmpty()) {
+        return null;
+      }
+
+      HRegionLocation rl = tableLocations.get(row);
+      if (rl != null) {
+        if (LOG.isDebugEnabled()) {
+          LOG.debug("Cache hit in table locations for row <" + row +
+            "> and tableName " + Bytes.toString(tableName) +
+            ": location server " + rl.getServerAddress() +
+            ", location region name " +
+            rl.getRegionInfo().getRegionNameAsString());
         }
-        
-        // cut the cache so that we only get the part that could contain
-        // regions that match our key
-        SoftSortedMap<Text, HRegionLocation> matchingRegions =
-          tableLocations.headMap(row);
+        return rl;
+      }
 
-        // if that portion of the map is empty, then we're done. otherwise,
-        // we need to examine the cached location to verify that it is 
-        // a match by end key as well.
-        if (!matchingRegions.isEmpty()) {
-          HRegionLocation possibleRegion = 
-            matchingRegions.get(matchingRegions.lastKey());
-          
-          // there is a possibility that the reference was garbage collected 
-          // in the instant since we checked isEmpty().
-          if (possibleRegion != null) {
-            Text endKey = possibleRegion.getRegionInfo().getEndKey();
-          
-            // make sure that the end key is greater than the row we're looking 
-            // for, otherwise the row actually belongs in the next region, not 
-            // this one. the exception case is when the endkey is EMPTY_START_ROW,
-            // signifying that the region we're checking is actually the last 
-            // region in the table.
-            if (endKey.equals(EMPTY_TEXT) || endKey.compareTo(row) > 0) {
-              return possibleRegion;
-            }
+      // Cut the cache so that we only get the part that could contain
+      // regions that match our key
+      SoftSortedMap<byte[], HRegionLocation> matchingRegions =
+        tableLocations.headMap(row);
+
+      // if that portion of the map is empty, then we're done. otherwise,
+      // we need to examine the cached location to verify that it is
+      // a match by end key as well.
+      if (!matchingRegions.isEmpty()) {
+        HRegionLocation possibleRegion =
+          matchingRegions.get(matchingRegions.lastKey());
+
+        // there is a possibility that the reference was garbage collected
+        // in the instant since we checked isEmpty().
+        if (possibleRegion != null) {
+          byte[] endKey = possibleRegion.getRegionInfo().getEndKey();
+
+          // make sure that the end key is greater than the row we're looking
+          // for, otherwise the row actually belongs in the next region, not
+          // this one. the exception case is when the endkey is EMPTY_START_ROW,
+          // signifying that the region we're checking is actually the last
+          // region in the table.
+          if (Bytes.equals(endKey, HConstants.EMPTY_END_ROW) ||
+              Bytes.compareTo(endKey, row) > 0) {
+            return possibleRegion;
           }
         }
       }
-      
-      // passed all the way through, so we got nothin - complete cache miss
+
+      // Passed all the way through, so we got nothin - complete cache miss
       return null;
     }
 
     /**
-      * Delete a cached location, if it satisfies the table name and row
-      * requirements.
-      */
-    private void deleteCachedLocation(Text tableName, Text row){
+     * Delete a cached location, if it satisfies the table name and row
+     * requirements.
+     */
+    private void deleteCachedLocation(final byte [] tableName,
+        final byte [] row) {
       // find the map of cached locations for this table
-      SoftSortedMap<Text, HRegionLocation> tableLocations = 
-        cachedRegionLocations.get(tableName);
+      Integer key = Bytes.mapKey(tableName);
+      SoftSortedMap<byte [], HRegionLocation> tableLocations = 
+        cachedRegionLocations.get(key);
 
       // if tableLocations for this table isn't built yet, make one
       if (tableLocations == null) {
-        tableLocations = new SoftSortedMap<Text, HRegionLocation>();
-        cachedRegionLocations.put(tableName, tableLocations);
+        tableLocations =
+          new SoftSortedMap<byte [], HRegionLocation>(Bytes.BYTES_COMPARATOR);
+        cachedRegionLocations.put(key, tableLocations);
       }
 
       // start to examine the cache. we can only do cache actions
@@ -534,7 +556,7 @@
       if (!tableLocations.isEmpty()) {
         // cut the cache so that we only get the part that could contain
         // regions that match our key
-        SoftSortedMap<Text, HRegionLocation> matchingRegions =
+        SoftSortedMap<byte [], HRegionLocation> matchingRegions =
           tableLocations.headMap(row);
 
         // if that portion of the map is empty, then we're done. otherwise,
@@ -544,17 +566,17 @@
           HRegionLocation possibleRegion = 
             matchingRegions.get(matchingRegions.lastKey());
           
-          Text endKey = possibleRegion.getRegionInfo().getEndKey();
+          byte [] endKey = possibleRegion.getRegionInfo().getEndKey();
           
           // by nature of the map, we know that the start key has to be < 
           // otherwise it wouldn't be in the headMap. 
-          if (endKey.compareTo(row) <= 0) {
+          if (Bytes.compareTo(endKey, row) <= 0) {
             // delete any matching entry
             HRegionLocation rl = 
               tableLocations.remove(matchingRegions.lastKey());
             if (rl != null && LOG.isDebugEnabled()) {
-              LOG.debug("Removed " + rl.getRegionInfo().getRegionName() +
-                " from cache because of " + row);
+              LOG.debug("Removed " + rl.getRegionInfo().getRegionNameAsString() +
+                " from cache because of " + Bytes.toString(row));
             }
           }
         }
@@ -564,17 +586,20 @@
     /**
       * Put a newly discovered HRegionLocation into the cache.
       */
-    private void cacheLocation(Text tableName, HRegionLocation location){
-      Text startKey = location.getRegionInfo().getStartKey();
+    private void cacheLocation(final byte [] tableName,
+        final HRegionLocation location){
+      byte [] startKey = location.getRegionInfo().getStartKey();
       
       // find the map of cached locations for this table
-      SoftSortedMap<Text, HRegionLocation> tableLocations = 
-        cachedRegionLocations.get(tableName);
+      Integer key = Bytes.mapKey(tableName);
+      SoftSortedMap<byte [], HRegionLocation> tableLocations = 
+        cachedRegionLocations.get(key);
 
       // if tableLocations for this table isn't built yet, make one
       if (tableLocations == null) {
-        tableLocations = new SoftSortedMap<Text, HRegionLocation>();
-        cachedRegionLocations.put(tableName, tableLocations);
+        tableLocations =
+          new SoftSortedMap<byte [], HRegionLocation>(Bytes.BYTES_COMPARATOR);
+        cachedRegionLocations.put(key, tableLocations);
       }
       
       // save the HRegionLocation under the startKey
@@ -667,9 +692,9 @@
         try {
           // if this works, then we're good, and we have an acceptable address,
           // so we can stop doing retries and return the result.
-          server.getRegionInfo(HRegionInfo.rootRegionInfo.getRegionName());
+          server.getRegionInfo(HRegionInfo.ROOT_REGIONINFO.getRegionName());
           if (LOG.isDebugEnabled()) {
-            LOG.debug("Found ROOT " + HRegionInfo.rootRegionInfo);
+            LOG.debug("Found ROOT " + HRegionInfo.ROOT_REGIONINFO);
           }
           break;
         } catch (IOException e) {
@@ -708,7 +733,7 @@
       
       // return the region location
       return new HRegionLocation(
-        HRegionInfo.rootRegionInfo, rootRegionAddress);
+        HRegionInfo.ROOT_REGIONINFO, rootRegionAddress);
     }
 
     /** {@inheritDoc} */

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HTable.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HTable.java?rev=656868&r1=656867&r2=656868&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HTable.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HTable.java Thu May 15 15:10:47 2008
@@ -42,6 +42,7 @@
 import org.apache.hadoop.hbase.io.Cell;
 import org.apache.hadoop.hbase.io.RowResult;
 import org.apache.hadoop.hbase.ipc.HRegionInterface;
+import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.Writables;
 import org.apache.hadoop.io.Text;
 
@@ -52,7 +53,7 @@
   protected final Log LOG = LogFactory.getLog(this.getClass());
 
   protected final HConnection connection;
-  protected final Text tableName;
+  protected final byte [] tableName;
   protected final long pause;
   protected final int numRetries;
   protected Random rand;
@@ -68,7 +69,32 @@
    * @param tableName name of the table
    * @throws IOException
    */
-  public HTable(HBaseConfiguration conf, Text tableName) throws IOException {
+  public HTable(HBaseConfiguration conf, final Text tableName)
+  throws IOException {
+    this(conf, tableName.getBytes());
+  }
+  
+  /**
+   * Creates an object to access a HBase table
+   * 
+   * @param conf configuration object
+   * @param tableName name of the table
+   * @throws IOException
+   */
+  public HTable(HBaseConfiguration conf, final String tableName)
+  throws IOException {
+    this(conf, Bytes.toBytes(tableName));
+  }
+
+  /**
+   * Creates an object to access a HBase table
+   * 
+   * @param conf configuration object
+   * @param tableName name of the table
+   * @throws IOException
+   */
+  public HTable(HBaseConfiguration conf, final byte [] tableName)
+  throws IOException {
     this.connection = HConnectionManager.getConnection(conf);
     this.tableName = tableName;
     this.pause = conf.getLong("hbase.client.pause", 10 * 1000);
@@ -83,18 +109,18 @@
    * @return Location of row.
    * @throws IOException
    */
-  public HRegionLocation getRegionLocation(Text row) throws IOException {
+  public HRegionLocation getRegionLocation(final byte [] row)
+  throws IOException {
     return connection.getRegionLocation(tableName, row, false);
   }
 
-
   /** @return the connection */
   public HConnection getConnection() {
     return connection;
   }
   
   /** @return the table name */
-  public Text getTableName() {
+  public byte [] getTableName() {
     return this.tableName;
   }
 
@@ -106,7 +132,7 @@
     HTableDescriptor [] metas = this.connection.listTables();
     HTableDescriptor result = null;
     for (int i = 0; i < metas.length; i++) {
-      if (metas[i].getName().equals(this.tableName)) {
+      if (Bytes.equals(metas[i].getName(), this.tableName)) {
         result = metas[i];
         break;
       }
@@ -120,12 +146,12 @@
    * @throws IOException
    */
   @SuppressWarnings("null")
-  public Text[] getStartKeys() throws IOException {
-    List<Text> keyList = new ArrayList<Text>();
+  public byte [][] getStartKeys() throws IOException {
+    List<byte []> keyList = new ArrayList<byte []>();
 
     long scannerId = -1L;
-
-    Text startRow = new Text(tableName.toString() + ",,999999999999999");
+    byte [] startRow =
+      HRegionInfo.createRegionName(this.tableName, null, NINES);
     HRegionLocation metaLocation = null;
     HRegionInterface server;
     
@@ -143,7 +169,7 @@
         // open a scanner over the meta region
         scannerId = server.openScanner(
           metaLocation.getRegionInfo().getRegionName(),
-          new Text[]{COL_REGIONINFO}, tableName, LATEST_TIMESTAMP,
+          new byte[][]{COL_REGIONINFO}, tableName, LATEST_TIMESTAMP,
           null);
         
         // iterate through the scanner, accumulating unique region names
@@ -157,7 +183,7 @@
           info = (HRegionInfo) Writables.getWritable(
             values.get(COL_REGIONINFO).getValue(), info);
           
-          if (!info.getTableDesc().getName().equals(this.tableName)) {
+          if (!Bytes.equals(info.getTableDesc().getName(), this.tableName)) {
             break;
           }
           
@@ -171,14 +197,14 @@
         server.close(scannerId);
           
         // advance the startRow to the end key of the current region
-        startRow = metaLocation.getRegionInfo().getEndKey();          
+        startRow = metaLocation.getRegionInfo().getEndKey();
       } catch (IOException e) {
         // need retry logic?
         throw e;
       }
-    } while (startRow.compareTo(EMPTY_START_ROW) != 0);
+    } while (Bytes.compareTo(startRow, EMPTY_START_ROW) != 0);
     
-    return keyList.toArray(new Text[keyList.size()]);
+    return keyList.toArray(new byte [keyList.size()][]);
   }
   
   /**
@@ -188,15 +214,15 @@
    */
   @SuppressWarnings("null")
   public Map<HRegionInfo, HServerAddress> getRegionsInfo() throws IOException {
-	// TODO This code is a near exact copy of getStartKeys. To be refactored HBASE-626
+    // TODO This code is a near exact copy of getStartKeys. To be refactored HBASE-626
     HashMap<HRegionInfo, HServerAddress> regionMap = new HashMap<HRegionInfo, HServerAddress>();
-
+    
     long scannerId = -1L;
-
-    Text startRow = new Text(tableName.toString() + ",,999999999999999");
+    byte [] startRow =
+      HRegionInfo.createRegionName(this.tableName, null, NINES);
     HRegionLocation metaLocation = null;
     HRegionInterface server;
-    
+        
     // scan over the each meta region
     do {
       try{
@@ -211,7 +237,7 @@
         // open a scanner over the meta region
         scannerId = server.openScanner(
           metaLocation.getRegionInfo().getRegionName(),
-          new Text[]{COL_REGIONINFO}, tableName, LATEST_TIMESTAMP,
+          new byte [][]{COL_REGIONINFO}, tableName, LATEST_TIMESTAMP,
           null);
         
         // iterate through the scanner, accumulating regions and their regionserver
@@ -224,8 +250,8 @@
           HRegionInfo info = new HRegionInfo();
           info = (HRegionInfo) Writables.getWritable(
             values.get(COL_REGIONINFO).getValue(), info);
-          
-          if (!info.getTableDesc().getName().equals(this.tableName)) {
+
+          if (!Bytes.equals(info.getTableDesc().getName(), this.tableName)) {
             break;
           }
           
@@ -239,15 +265,45 @@
         server.close(scannerId);
           
         // advance the startRow to the end key of the current region
-        startRow = metaLocation.getRegionInfo().getEndKey();          
+        startRow = metaLocation.getRegionInfo().getEndKey();
+
+        // turn the start row into a location
+        metaLocation = 
+          connection.locateRegion(META_TABLE_NAME, startRow);
       } catch (IOException e) {
         // need retry logic?
         throw e;
       }
-    } while (startRow.compareTo(EMPTY_START_ROW) != 0);
+    } while (Bytes.compareTo(startRow, EMPTY_START_ROW) != 0);
     
     return regionMap;
   }
+  /** 
+   * Get a single value for the specified row and column
+   *
+   * @param row row key
+   * @param column column name
+   * @return value for specified row/column
+   * @throws IOException
+   */
+  public Cell get(final Text row, final Text column)
+  throws IOException {
+    return get(row.getBytes(), column.getBytes());
+  }
+
+  /** 
+   * Get a single value for the specified row and column
+   *
+   * @param row row key
+   * @param column column name
+   * @param numVersions - number of versions to retrieve
+   * @return value for specified row/column
+   * @throws IOException
+   */
+  public Cell[] get(final Text row, final Text column, int numVersions)
+  throws IOException {
+    return get(row.getBytes(), column.getBytes(), numVersions);
+  }
   
   /** 
    * Get a single value for the specified row and column
@@ -257,7 +313,8 @@
    * @return value for specified row/column
    * @throws IOException
    */
-  public Cell get(final Text row, final Text column) throws IOException {
+  public Cell get(final byte [] row, final byte [] column)
+  throws IOException {
     return connection.getRegionServerWithRetries(
         new ServerCallable<Cell>(connection, tableName, row) {
           public Cell call() throws IOException {
@@ -267,7 +324,7 @@
         }
     );
   }
-    
+
   /** 
    * Get the specified number of versions of the specified row and column
    * 
@@ -277,10 +334,10 @@
    * @return            - array byte values
    * @throws IOException
    */
-  public Cell[] get(final Text row, final Text column, final int numVersions) 
+  public Cell[] get(final byte [] row, final byte [] column,
+    final int numVersions) 
   throws IOException {
     Cell[] values = null;
-
     values = connection.getRegionServerWithRetries(
         new ServerCallable<Cell[]>(connection, tableName, row) {
           public Cell[] call() throws IOException {
@@ -311,11 +368,27 @@
    * @return            - array of values that match the above criteria
    * @throws IOException
    */
-  public Cell[] get(final Text row, final Text column, final long timestamp, 
-    final int numVersions)
+  public Cell[] get(final Text row, final Text column,
+    final long timestamp, final int numVersions)
+  throws IOException {
+    return get(row.getBytes(), column.getBytes(), timestamp, numVersions);
+  }
+  
+  /** 
+   * Get the specified number of versions of the specified row and column with
+   * the specified timestamp.
+   *
+   * @param row         - row key
+   * @param column      - column name
+   * @param timestamp   - timestamp
+   * @param numVersions - number of versions to retrieve
+   * @return            - array of values that match the above criteria
+   * @throws IOException
+   */
+  public Cell[] get(final byte [] row, final byte [] column,
+    final long timestamp, final int numVersions)
   throws IOException {
     Cell[] values = null;
-
     values = connection.getRegionServerWithRetries(
         new ServerCallable<Cell[]>(connection, tableName, row) {
           public Cell[] call() throws IOException {
@@ -334,15 +407,26 @@
     }
     return null;
   }
-      
+
+  /** 
+   * Get all the data for the specified row at the latest timestamp
+   * 
+   * @param row row key
+   * @return RowResult is empty if row does not exist.
+   * @throws IOException
+   */
+  public RowResult getRow(final Text row) throws IOException {
+    return getRow(row.getBytes());
+  }
+
   /** 
    * Get all the data for the specified row at the latest timestamp
    * 
    * @param row row key
-   * @return Map of columns to values.  Map is empty if row does not exist.
+   * @return RowResult is empty if row does not exist.
    * @throws IOException
    */
-  public Map<Text, Cell> getRow(final Text row) throws IOException {
+  public RowResult getRow(final byte [] row) throws IOException {
     return getRow(row, HConstants.LATEST_TIMESTAMP);
   }
 
@@ -351,10 +435,23 @@
    * 
    * @param row row key
    * @param ts timestamp
-   * @return Map of columns to values.  Map is empty if row does not exist.
+   * @return RowResult is empty if row does not exist.
+   * @throws IOException
+   */
+  public RowResult getRow(final Text row, final long ts) 
+  throws IOException {
+    return getRow(row.getBytes(), ts);
+  }
+
+  /** 
+   * Get all the data for the specified row at a specified timestamp
+   * 
+   * @param row row key
+   * @param ts timestamp
+   * @return RowResult is empty if row does not exist.
    * @throws IOException
    */
-  public Map<Text, Cell> getRow(final Text row, final long ts) 
+  public RowResult getRow(final byte [] row, final long ts) 
   throws IOException {
     return connection.getRegionServerWithRetries(
         new ServerCallable<RowResult>(connection, tableName, row) {
@@ -365,16 +462,28 @@
         }
     );
   }
-
   /** 
    * Get selected columns for the specified row at the latest timestamp
    * 
    * @param row row key
    * @param columns Array of column names you want to retrieve.
-   * @return Map of columns to values.  Map is empty if row does not exist.
+   * @return RowResult is empty if row does not exist.
    * @throws IOException
    */
-  public Map<Text, Cell> getRow(final Text row, final Text[] columns) 
+  public RowResult getRow(final Text row, final Text[] columns) 
+  throws IOException {
+    return getRow(row.getBytes(), Bytes.toByteArrays(columns));
+  }
+  
+  /** 
+   * Get selected columns for the specified row at the latest timestamp
+   * 
+   * @param row row key
+   * @param columns Array of column names you want to retrieve.
+   * @return RowResult is empty if row does not exist.
+   * @throws IOException
+   */
+  public RowResult getRow(final byte [] row, final byte [][] columns) 
   throws IOException {
     return getRow(row, columns, HConstants.LATEST_TIMESTAMP);
   }
@@ -385,10 +494,25 @@
    * @param row row key
    * @param columns Array of column names you want to retrieve.   
    * @param ts timestamp
-   * @return Map of columns to values.  Map is empty if row does not exist.
+   * @return RowResult is empty if row does not exist.
+   * @throws IOException
+   */
+  public RowResult getRow(final Text row, final Text[] columns, 
+    final long ts) 
+  throws IOException {  
+    return getRow(row.getBytes(), Bytes.toByteArrays(columns), ts);
+  }
+  
+  /** 
+   * Get selected columns for the specified row at a specified timestamp
+   * 
+   * @param row row key
+   * @param columns Array of column names you want to retrieve.   
+   * @param ts timestamp
+   * @return RowResult is empty if row does not exist.
    * @throws IOException
    */
-  public Map<Text, Cell> getRow(final Text row, final Text[] columns, 
+  public RowResult getRow(final byte [] row, final byte [][] columns, 
     final long ts) 
   throws IOException {       
     return connection.getRegionServerWithRetries(
@@ -414,7 +538,25 @@
    * @return scanner
    * @throws IOException
    */
-  public Scanner getScanner(Text[] columns, Text startRow)
+  public Scanner getScanner(final Text [] columns, final Text startRow)
+  throws IOException {
+    return getScanner(Bytes.toByteArrays(columns), startRow.getBytes());
+  }
+  
+  /** 
+   * Get a scanner on the current table starting at the specified row.
+   * Return the specified columns.
+   *
+   * @param columns columns to scan. If column name is a column family, all
+   * columns of the specified column family are returned.  Its also possible
+   * to pass a regex in the column qualifier. A column qualifier is judged to
+   * be a regex if it contains at least one of the following characters:
+   * <code>\+|^&*$[]]}{)(</code>.
+   * @param startRow starting row in table to scan
+   * @return scanner
+   * @throws IOException
+   */
+  public Scanner getScanner(final byte[][] columns, final byte [] startRow)
   throws IOException {
     return getScanner(columns, startRow, HConstants.LATEST_TIMESTAMP, null);
   }
@@ -433,7 +575,7 @@
    * @return scanner
    * @throws IOException
    */
-  public Scanner getScanner(Text[] columns, Text startRow,
+  public Scanner getScanner(final byte[][] columns, final byte [] startRow,
     long timestamp)
   throws IOException {
     return getScanner(columns, startRow, timestamp, null);
@@ -453,7 +595,7 @@
    * @return scanner
    * @throws IOException
    */
-  public Scanner getScanner(Text[] columns, Text startRow,
+  public Scanner getScanner(final byte[][] columns, final byte [] startRow,
     RowFilterInterface filter)
   throws IOException { 
     return getScanner(columns, startRow, HConstants.LATEST_TIMESTAMP, filter);
@@ -476,13 +618,13 @@
    * @return scanner
    * @throws IOException
    */
-  public Scanner getScanner(final Text[] columns,
-    final Text startRow, final Text stopRow)
+  public Scanner getScanner(final byte [][] columns,
+    final byte [] startRow, final byte [] stopRow)
   throws IOException {
     return getScanner(columns, startRow, stopRow,
       HConstants.LATEST_TIMESTAMP);
   }
-  
+
   /** 
    * Get a scanner on the current table starting at the specified row and
    * ending just before <code>stopRow<code>.
@@ -504,6 +646,31 @@
   public Scanner getScanner(final Text[] columns,
     final Text startRow, final Text stopRow, final long timestamp)
   throws IOException {
+    return getScanner(Bytes.toByteArrays(columns), startRow.getBytes(),
+      stopRow.getBytes(), timestamp);
+  }
+  
+  /** 
+   * Get a scanner on the current table starting at the specified row and
+   * ending just before <code>stopRow<code>.
+   * Return the specified columns.
+   *
+   * @param columns columns to scan. If column name is a column family, all
+   * columns of the specified column family are returned.  Its also possible
+   * to pass a regex in the column qualifier. A column qualifier is judged to
+   * be a regex if it contains at least one of the following characters:
+   * <code>\+|^&*$[]]}{)(</code>.
+   * @param startRow starting row in table to scan
+   * @param stopRow Row to stop scanning on. Once we hit this row we stop
+   * returning values; i.e. we return the row before this one but not the
+   * <code>stopRow</code> itself.
+   * @param timestamp only return results whose timestamp <= this value
+   * @return scanner
+   * @throws IOException
+   */
+  public Scanner getScanner(final byte [][] columns,
+    final byte [] startRow, final byte [] stopRow, final long timestamp)
+  throws IOException {
     return getScanner(columns, startRow, timestamp,
       new WhileMatchRowFilter(new StopRowFilter(stopRow)));
   }  
@@ -526,8 +693,63 @@
   public Scanner getScanner(Text[] columns,
     Text startRow, long timestamp, RowFilterInterface filter)
   throws IOException {
+    return getScanner(Bytes.toByteArrays(columns), startRow.getBytes(),
+      timestamp, filter);
+  }
+  
+  /** 
+   * Get a scanner on the current table starting at the specified row.
+   * Return the specified columns.
+   *
+   * @param columns columns to scan. If column name is a column family, all
+   * columns of the specified column family are returned.  Its also possible
+   * to pass a regex in the column qualifier. A column qualifier is judged to
+   * be a regex if it contains at least one of the following characters:
+   * <code>\+|^&*$[]]}{)(</code>.
+   * @param startRow starting row in table to scan
+   * @param timestamp only return results whose timestamp <= this value
+   * @param filter a row filter using row-key regexp and/or column data filter.
+   * @return scanner
+   * @throws IOException
+   */
+  public Scanner getScanner(final byte [][] columns,
+    final byte [] startRow, long timestamp, RowFilterInterface filter)
+  throws IOException {
     return new ClientScanner(columns, startRow, timestamp, filter);
   }
+  
+  /**
+   * Completely delete the row's cells.
+   *
+   * @param row Key of the row you want to completely delete.
+   * @throws IOException
+   */
+  public void deleteAll(final byte [] row) throws IOException {
+    deleteAll(row, null);
+  }
+  
+  /**
+   * Completely delete the row's cells.
+   *
+   * @param row Key of the row you want to completely delete.
+   * @throws IOException
+   */
+  public void deleteAll(final byte [] row, final byte [] column)
+  throws IOException {
+    deleteAll(row, column, HConstants.LATEST_TIMESTAMP);
+  }
+
+  /**
+   * Completely delete the row's cells.
+   *
+   * @param row Key of the row you want to completely delete.
+   * @param ts Delete all cells of the same timestamp or older.
+   * @throws IOException
+   */
+  public void deleteAll(final byte [] row, final long ts)
+  throws IOException {
+    deleteAll(row, null, ts);
+  }
 
   /** 
    * Delete all cells that match the passed row and column.
@@ -538,7 +760,7 @@
   public void deleteAll(final Text row, final Text column) throws IOException {
     deleteAll(row, column, LATEST_TIMESTAMP);
   }
-  
+
   /** 
    * Delete all cells that match the passed row and column and whose
    * timestamp is equal-to or older than the passed timestamp.
@@ -549,45 +771,42 @@
    */
   public void deleteAll(final Text row, final Text column, final long ts)
   throws IOException {
-    connection.getRegionServerWithRetries(
-        new ServerCallable<Boolean>(connection, tableName, row) {
-          public Boolean call() throws IOException {
-            server.deleteAll(location.getRegionInfo().getRegionName(), row, 
-                column, ts);
-            return null;
-          }
-        }
-    );
+    deleteAll(row.getBytes(), column.getBytes(), ts);
   }
   
-  /**
-   * Completely delete the row's cells of the same timestamp or older.
-   *
-   * @param row Key of the row you want to completely delete.
-   * @param ts Timestamp of cells to delete
-   * @throws IOException
+  /** 
+   * Delete all cells that match the passed row and column and whose
+   * timestamp is equal-to or older than the passed timestamp.
+   * @param row Row to update
+   * @param column name of column whose value is to be deleted
+   * @param ts Delete all cells of the same timestamp or older.
+   * @throws IOException 
    */
-  public void deleteAll(final Text row, final long ts) throws IOException {
+  public void deleteAll(final byte [] row, final byte [] column, final long ts)
+  throws IOException {
     connection.getRegionServerWithRetries(
         new ServerCallable<Boolean>(connection, tableName, row) {
           public Boolean call() throws IOException {
-            server.deleteAll(location.getRegionInfo().getRegionName(), row, ts);
+            server.deleteAll(location.getRegionInfo().getRegionName(), row, 
+                column, ts);
             return null;
           }
         }
     );
   }
-      
+
   /**
-   * Completely delete the row's cells.
+   * Delete all cells for a row with matching column family at all timestamps.
    *
-   * @param row Key of the row you want to completely delete.
+   * @param row The row to operate on
+   * @param family The column family to match
    * @throws IOException
-   */
-  public void deleteAll(final Text row) throws IOException {
-    deleteAll(row, HConstants.LATEST_TIMESTAMP);
+   */  
+  public void deleteFamily(final Text row, final Text family) throws IOException{
+    deleteFamily(row.getBytes(), family.getBytes(),
+      HConstants.LATEST_TIMESTAMP);
   }
-  
+
   /**
    * Delete all cells for a row with matching column family with timestamps
    * less than or equal to <i>timestamp</i>.
@@ -597,7 +816,7 @@
    * @param timestamp Timestamp to match
    * @throws IOException
    */
-  public void deleteFamily(final Text row, final Text family, 
+  public void deleteFamily(final byte [] row, final byte [] family, 
     final long timestamp)
   throws IOException {
     connection.getRegionServerWithRetries(
@@ -612,17 +831,6 @@
   }
 
   /**
-   * Delete all cells for a row with matching column family at all timestamps.
-   *
-   * @param row The row to operate on
-   * @param family The column family to match
-   * @throws IOException
-   */  
-  public void deleteFamily(final Text row, final Text family) throws IOException{
-    deleteFamily(row, family, HConstants.LATEST_TIMESTAMP);
-  }
-
-  /**
    * Commit a BatchUpdate to the table.
    * @param batchUpdate
    * @throws IOException
@@ -639,15 +847,15 @@
       }
     );  
   }
-  
+
   /**
    * Implements the scanner interface for the HBase client.
    * If there are multiple regions in a table, this scanner will iterate
    * through them all.
    */
   private class ClientScanner implements Scanner {
-    protected Text[] columns;
-    private Text startRow;
+    private byte[][] columns;
+    private byte [] startRow;
     protected long scanTime;
     @SuppressWarnings("hiding")
     private boolean closed = false;
@@ -655,15 +863,20 @@
     private ScannerCallable callable = null;
     protected RowFilterInterface filter;
     
-    protected ClientScanner(Text[] columns, Text startRow, long timestamp,
-      RowFilterInterface filter) 
+    protected ClientScanner(final Text [] columns, final Text startRow,
+        long timestamp, RowFilterInterface filter)
     throws IOException {
+      this(Bytes.toByteArrays(columns), startRow.getBytes(), timestamp,
+        filter);
+    }
 
+    protected ClientScanner(final byte[][] columns, final byte [] startRow,
+        final long timestamp, final RowFilterInterface filter) 
+    throws IOException {
       if (LOG.isDebugEnabled()) {
-        LOG.debug("Creating scanner over " + tableName + " starting at key '" +
-            startRow + "'");
+        LOG.debug("Creating scanner over " + Bytes.toString(tableName) +
+          " starting at key '" + startRow + "'");
       }
-
       // save off the simple parameters
       this.columns = columns;
       this.startRow = startRow;
@@ -675,7 +888,6 @@
       if (filter != null) {
         filter.validate(columns);
       }
-
       nextScanner();
     }
         
@@ -698,15 +910,15 @@
           LOG.debug("Advancing forward from region " + currentRegion);
         }
 
-        Text endKey = currentRegion.getEndKey();
-        if (endKey == null || endKey.equals(EMPTY_TEXT)) {
+        byte [] endKey = currentRegion.getEndKey();
+        if (endKey == null || Bytes.equals(endKey, EMPTY_BYTE_ARRAY)) {
           close();
           return false;
         }
       } 
       
       HRegionInfo oldRegion = this.currentRegion;
-      Text localStartKey = oldRegion == null ? startRow : oldRegion.getEndKey();
+      byte [] localStartKey = oldRegion == null? startRow: oldRegion.getEndKey();
 
       if (LOG.isDebugEnabled()) {
         LOG.debug("Advancing internal scanner to startKey " + localStartKey);

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/RetriesExhaustedException.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/RetriesExhaustedException.java?rev=656868&r1=656867&r2=656868&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/RetriesExhaustedException.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/RetriesExhaustedException.java Thu May 15 15:10:47 2008
@@ -15,9 +15,10 @@
  */
 package org.apache.hadoop.hbase.client;
 
-import java.io.IOException; 
+import java.io.IOException;
 import java.util.List;
-import org.apache.hadoop.io.Text;
+
+import org.apache.hadoop.hbase.util.Bytes;
 
 /** 
  * Exception thrown by HTable methods when an attempt to do something (like
@@ -33,23 +34,25 @@
    * @param numTries The number of tries we made
    * @param exceptions List of exceptions that failed before giving up
    */ 
-  public RetriesExhaustedException(String serverName, Text regionName, Text row,
+  public RetriesExhaustedException(String serverName, final byte [] regionName,
+      final byte []  row,
       int numTries, List<Throwable> exceptions) {
     super(getMessage(serverName, regionName, row, numTries, exceptions));
   }
   
-  private static String getMessage(String serverName, Text regionName, Text row,
+
+  private static String getMessage(String serverName, final byte [] regionName,
+      final byte [] row,
       int numTries, List<Throwable> exceptions) {
     StringBuilder buffer = new StringBuilder("Trying to contact region server ");
     buffer.append(serverName);
     buffer.append(" for region ");
-    buffer.append(regionName);
+    buffer.append(Bytes.toString(regionName));
     buffer.append(", row '");
-    buffer.append(row);
+    buffer.append(Bytes.toString(row));
     buffer.append("', but failed after ");
     buffer.append(numTries + 1);
     buffer.append(" attempts.\nExceptions:\n");
-
     for (Throwable t : exceptions) {
       buffer.append(t.toString());
       buffer.append("\n");

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/ScannerCallable.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/ScannerCallable.java?rev=656868&r1=656867&r2=656868&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/ScannerCallable.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/ScannerCallable.java Thu May 15 15:10:47 2008
@@ -25,7 +25,8 @@
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.filter.RowFilterInterface;
 import org.apache.hadoop.hbase.io.RowResult;
-import org.apache.hadoop.io.Text;
+
+
 /**
  * Retryable scanner
  */
@@ -33,12 +34,12 @@
   private long scannerId = -1L;
   private boolean instantiated = false;
   private boolean closed = false;
-  private final Text[] columns;
+  private final byte [][] columns;
   private final long timestamp;
   private final RowFilterInterface filter;
 
-  ScannerCallable (HConnection connection, Text tableName, Text[] columns,
-      Text startRow, long timestamp, RowFilterInterface filter) {
+  ScannerCallable (HConnection connection, byte [] tableName, byte [][] columns,
+      byte [] startRow, long timestamp, RowFilterInterface filter) {
     super(connection, tableName, startRow);
     this.columns = columns;
     this.timestamp = timestamp;
@@ -89,4 +90,4 @@
     }
     return location.getRegionInfo();
   }
-}
+}
\ No newline at end of file

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/ServerCallable.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/ServerCallable.java?rev=656868&r1=656867&r2=656868&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/ServerCallable.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/ServerCallable.java Thu May 15 15:10:47 2008
@@ -25,7 +25,6 @@
 
 import org.apache.hadoop.hbase.HRegionLocation;
 import org.apache.hadoop.hbase.ipc.HRegionInterface;
-import org.apache.hadoop.io.Text;
 
 /**
  * Implements Callable, used to define the particular actions you would
@@ -35,8 +34,8 @@
  */
 public abstract class ServerCallable<T> implements Callable<T> {
   protected final HConnection connection;
-  protected final Text tableName;
-  protected final Text row;
+  protected final byte [] tableName;
+  protected final byte [] row;
   protected HRegionLocation location;
   protected HRegionInterface server;
 
@@ -45,7 +44,7 @@
    * @param tableName
    * @param row
    */
-  public ServerCallable(HConnection connection, Text tableName, Text row) {
+  public ServerCallable(HConnection connection, byte [] tableName, byte [] row) {
     this.connection = connection;
     this.tableName = tableName;
     this.row = row;
@@ -67,12 +66,12 @@
   }
   
   /** @return the region name */
-  public Text getRegionName() {
+  public byte [] getRegionName() {
     return location.getRegionInfo().getRegionName();
   }
   
   /** @return the row */
-  public Text getRow() {
+  public byte [] getRow() {
     return row;
   }
-}
+}
\ No newline at end of file

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/filter/InclusiveStopRowFilter.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/filter/InclusiveStopRowFilter.java?rev=656868&r1=656867&r2=656868&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/filter/InclusiveStopRowFilter.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/filter/InclusiveStopRowFilter.java Thu May 15 15:10:47 2008
@@ -19,7 +19,7 @@
  */
 package org.apache.hadoop.hbase.filter;
 
-import org.apache.hadoop.io.Text;
+import org.apache.hadoop.hbase.util.Bytes;
 
 /**
  * Subclass of StopRowFilter that filters rows > the stop row,
@@ -37,20 +37,19 @@
    * 
    * @param stopRowKey rowKey to filter on.
    */
-  public InclusiveStopRowFilter(final Text stopRowKey) {
+  public InclusiveStopRowFilter(final byte [] stopRowKey) {
     super(stopRowKey);
   }
   
   /** {@inheritDoc} */
   @Override
-  public boolean filterRowKey(final Text rowKey) {
+  public boolean filterRowKey(final byte [] rowKey) {
     if (rowKey == null) {
-      if (this.stopRowKey == null) {
+      if (getStopRowKey() == null) {
         return true;
       }
       return false;
     }    
-    return this.stopRowKey.compareTo(rowKey) < 0;
+    return Bytes.compareTo(getStopRowKey(), rowKey) < 0;
   }
-  
 }

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/filter/PageRowFilter.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/filter/PageRowFilter.java?rev=656868&r1=656867&r2=656868&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/filter/PageRowFilter.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/filter/PageRowFilter.java Thu May 15 15:10:47 2008
@@ -24,7 +24,6 @@
 import java.io.IOException;
 import java.util.SortedMap;
 
-import org.apache.hadoop.io.Text;
 
 /**
  * Implementation of RowFilterInterface that limits results to a specific page
@@ -65,7 +64,7 @@
    * 
    * {@inheritDoc}
    */
-  public void validate(@SuppressWarnings("unused") final Text[] columns) {
+  public void validate(@SuppressWarnings("unused") final byte [][] columns) {
     // Doesn't filter columns
   }
 
@@ -79,7 +78,7 @@
 
   /** {@inheritDoc} */
   public void rowProcessed(boolean filtered,
-      @SuppressWarnings("unused") Text rowKey) {
+      @SuppressWarnings("unused") byte [] rowKey) {
     if (!filtered) {
       this.rowsAccepted++;
     }
@@ -105,7 +104,7 @@
    * 
    * {@inheritDoc}
    */
-  public boolean filterRowKey(@SuppressWarnings("unused") final Text rowKey) {
+  public boolean filterRowKey(@SuppressWarnings("unused") final byte [] r) {
     return filterAllRemaining();
   }
 
@@ -113,8 +112,8 @@
    * 
    * {@inheritDoc}
    */
-  public boolean filterColumn(@SuppressWarnings("unused") final Text rowKey,
-    @SuppressWarnings("unused") final Text colKey,
+  public boolean filterColumn(@SuppressWarnings("unused") final byte [] rowKey,
+    @SuppressWarnings("unused") final byte [] colKey,
     @SuppressWarnings("unused") final byte[] data) {
     return filterAllRemaining();
   }
@@ -124,7 +123,7 @@
    * {@inheritDoc}
    */
   public boolean filterRow(@SuppressWarnings("unused")
-      final SortedMap<Text, byte[]> columns) {
+      final SortedMap<byte [], byte[]> columns) {
     return filterAllRemaining();
   }
 

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/filter/RegExpRowFilter.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/filter/RegExpRowFilter.java?rev=656868&r1=656867&r2=656868&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/filter/RegExpRowFilter.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/filter/RegExpRowFilter.java Thu May 15 15:10:47 2008
@@ -23,17 +23,16 @@
 import java.io.DataOutput;
 import java.io.IOException;
 import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.TreeSet;
 import java.util.Map.Entry;
 import java.util.regex.Pattern;
 
-import org.apache.hadoop.io.Text;
-
 import org.apache.hadoop.hbase.regionserver.HLogEdit;
+import org.apache.hadoop.hbase.util.Bytes;
 
 /**
  * Implementation of RowFilterInterface that can filter by rowkey regular
@@ -45,8 +44,10 @@
   private Pattern rowKeyPattern = null;
   private String rowKeyRegExp = null;
 
-  private Map<Text, byte[]> equalsMap = new HashMap<Text, byte[]>();
-  private Set<Text> nullColumns = new HashSet<Text>();
+  private Map<byte [], byte[]> equalsMap =
+    new TreeMap<byte [], byte[]>(Bytes.BYTES_COMPARATOR);
+  private Set<byte []> nullColumns =
+    new TreeSet<byte []>(Bytes.BYTES_COMPARATOR);
 
   /**
    * Default constructor, filters nothing. Required though for RPC
@@ -72,14 +73,14 @@
    * @param columnFilter
    */
   public RegExpRowFilter(final String rowKeyRegExp,
-      final Map<Text, byte[]> columnFilter) {
+      final Map<byte [], byte[]> columnFilter) {
     this.rowKeyRegExp = rowKeyRegExp;
     this.setColumnFilters(columnFilter);
   }
   
   /** {@inheritDoc} */
   @SuppressWarnings("unused")
-  public void rowProcessed(boolean filtered, Text rowKey) {
+  public void rowProcessed(boolean filtered, byte [] rowKey) {
     //doesn't care
   }
 
@@ -96,7 +97,7 @@
    * @param value
    *          the value that must equal the stored value.
    */
-  public void setColumnFilter(final Text colKey, final byte[] value) {
+  public void setColumnFilter(final byte [] colKey, final byte[] value) {
     if (value == null) {
       nullColumns.add(colKey);
     } else {
@@ -110,12 +111,12 @@
    * @param columnFilter
    *          Map of columns with value criteria.
    */
-  public void setColumnFilters(final Map<Text, byte[]> columnFilter) {
+  public void setColumnFilters(final Map<byte [], byte[]> columnFilter) {
     if (null == columnFilter) {
       nullColumns.clear();
       equalsMap.clear();
     } else {
-      for (Entry<Text, byte[]> entry : columnFilter.entrySet()) {
+      for (Entry<byte [], byte[]> entry : columnFilter.entrySet()) {
         setColumnFilter(entry.getKey(), entry.getValue());
       }
     }
@@ -141,18 +142,17 @@
    * 
    * {@inheritDoc}
    */
-  public boolean filterRowKey(final Text rowKey) {
-    if (filtersByRowKey() && rowKey != null) {
-      return !getRowKeyPattern().matcher(rowKey.toString()).matches();
-    }
-    return false;
+  public boolean filterRowKey(final byte [] rowKey) {
+    return (filtersByRowKey() && rowKey != null)?
+      !getRowKeyPattern().matcher(Bytes.toString(rowKey)).matches():
+      false;
   }
 
   /**
    * 
    * {@inheritDoc}
    */
-  public boolean filterColumn(final Text rowKey, final Text colKey,
+  public boolean filterColumn(final byte [] rowKey, final byte [] colKey,
       final byte[] data) {
     if (filterRowKey(rowKey)) {
       return true;
@@ -175,14 +175,14 @@
    * 
    * {@inheritDoc}
    */
-  public boolean filterRow(final SortedMap<Text, byte[]> columns) {
-    for (Entry<Text, byte[]> col : columns.entrySet()) {
+  public boolean filterRow(final SortedMap<byte [], byte[]> columns) {
+    for (Entry<byte [], byte[]> col : columns.entrySet()) {
       if (nullColumns.contains(col.getKey())
           && !HLogEdit.isDeleted(col.getValue())) {
         return true;
       }
     }
-    for (Text col : equalsMap.keySet()) {
+    for (byte [] col : equalsMap.keySet()) {
       if (!columns.containsKey(col)) {
         return true;
       }
@@ -225,8 +225,7 @@
     equalsMap.clear();
     int size = in.readInt();
     for (int i = 0; i < size; i++) {
-      Text key = new Text();
-      key.readFields(in);
+      byte [] key = Bytes.readByteArray(in);
       int len = in.readInt();
       byte[] value = null;
       if (len >= 0) {
@@ -239,9 +238,7 @@
     nullColumns.clear();
     size = in.readInt();
     for (int i = 0; i < size; i++) {
-      Text key = new Text();
-      key.readFields(in);
-      setColumnFilter(key, null);
+      setColumnFilter(Bytes.readByteArray(in), null);
     }
   }
 
@@ -249,12 +246,12 @@
    * 
    * {@inheritDoc}
    */
-  public void validate(final Text[] columns) {
-    Set<Text> invalids = new HashSet<Text>();
-    for (Text colKey : getFilterColumns()) {
+  public void validate(final byte [][] columns) {
+    Set<byte []> invalids = new TreeSet<byte []>(Bytes.BYTES_COMPARATOR);
+    for (byte [] colKey : getFilterColumns()) {
       boolean found = false;
-      for (Text col : columns) {
-        if (col.equals(colKey)) {
+      for (byte [] col : columns) {
+        if (Bytes.equals(col, colKey)) {
           found = true;
           break;
         }
@@ -271,8 +268,8 @@
     }
   }
 
-  private Set<Text> getFilterColumns() {
-    Set<Text> cols = new HashSet<Text>();
+  private Set<byte []> getFilterColumns() {
+    Set<byte []> cols = new TreeSet<byte []>(Bytes.BYTES_COMPARATOR);
     cols.addAll(equalsMap.keySet());
     cols.addAll(nullColumns);
     return cols;
@@ -292,8 +289,8 @@
 
     // equalsMap
     out.writeInt(equalsMap.size());
-    for (Entry<Text, byte[]> entry : equalsMap.entrySet()) {
-      entry.getKey().write(out);
+    for (Entry<byte [], byte[]> entry : equalsMap.entrySet()) {
+      Bytes.writeByteArray(out, entry.getKey());
       byte[] value = entry.getValue();
       out.writeInt(value.length);
       out.write(value);
@@ -301,8 +298,8 @@
 
     // null columns
     out.writeInt(nullColumns.size());
-    for (Text col : nullColumns) {
-      col.write(out);
+    for (byte [] col : nullColumns) {
+      Bytes.writeByteArray(out, col);
     }
   }
 }
\ No newline at end of file

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/filter/RowFilterInterface.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/filter/RowFilterInterface.java?rev=656868&r1=656867&r2=656868&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/filter/RowFilterInterface.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/filter/RowFilterInterface.java Thu May 15 15:10:47 2008
@@ -21,7 +21,6 @@
 
 import java.util.SortedMap;
 
-import org.apache.hadoop.io.Text;
 import org.apache.hadoop.io.Writable;
 
 /**
@@ -48,7 +47,7 @@
    * @param filtered
    * @param key
    */
-  void rowProcessed(boolean filtered, Text key);
+  void rowProcessed(boolean filtered, byte [] key);
 
   /**
    * Returns whether or not the filter should always be processed in any 
@@ -79,7 +78,7 @@
    * @param rowKey
    * @return true if given row key is filtered and row should not be processed.
    */
-  boolean filterRowKey(final Text rowKey);
+  boolean filterRowKey(final byte [] rowKey);
 
   /**
    * Filters on row key, column name, and column value. This will take individual columns out of a row, 
@@ -90,7 +89,8 @@
    * @param columnValue column value to filter on
    * @return true if row filtered and should not be processed.
    */
-  boolean filterColumn(final Text rowKey, final Text colunmName, final byte[] columnValue);
+  boolean filterColumn(final byte [] rowKey, final byte [] colunmName,
+      final byte[] columnValue);
 
   /**
    * Filter on the fully assembled row. This is the last chance to stop a row. 
@@ -98,7 +98,7 @@
    * @param columns
    * @return true if row filtered and should not be processed.
    */
-  boolean filterRow(final SortedMap<Text, byte[]> columns);
+  boolean filterRow(final SortedMap<byte [], byte[]> columns);
 
   /**
    * Validates that this filter applies only to a subset of the given columns.
@@ -111,5 +111,5 @@
    * 
    * @param columns
    */
-  void validate(final Text[] columns);
+  void validate(final byte [][] columns);
 }
\ No newline at end of file

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/filter/RowFilterSet.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/filter/RowFilterSet.java?rev=656868&r1=656867&r2=656868&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/filter/RowFilterSet.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/filter/RowFilterSet.java Thu May 15 15:10:47 2008
@@ -29,7 +29,6 @@
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.io.ObjectWritable;
-import org.apache.hadoop.io.Text;
 
 /**
  * Implementation of RowFilterInterface that represents a set of RowFilters
@@ -81,7 +80,7 @@
   }
 
   /** {@inheritDoc} */
-  public void validate(final Text[] columns) {
+  public void validate(final byte [][] columns) {
     for (RowFilterInterface filter : filters) {
       filter.validate(columns);
     }
@@ -95,7 +94,7 @@
   }
 
   /** {@inheritDoc} */
-  public void rowProcessed(boolean filtered, Text rowKey) {
+  public void rowProcessed(boolean filtered, byte [] rowKey) {
     for (RowFilterInterface filter : filters) {
       filter.rowProcessed(filtered, rowKey);
     }
@@ -129,7 +128,7 @@
   }
 
   /** {@inheritDoc} */
-  public boolean filterRowKey(final Text rowKey) {
+  public boolean filterRowKey(final byte [] rowKey) {
     boolean resultFound = false;
     boolean result = operator == Operator.MUST_PASS_ONE;
     for (RowFilterInterface filter : filters) {
@@ -153,7 +152,7 @@
   }
 
   /** {@inheritDoc} */
-  public boolean filterColumn(final Text rowKey, final Text colKey, 
+  public boolean filterColumn(final byte [] rowKey, final byte [] colKey, 
     final byte[] data) {
     boolean resultFound = false;
     boolean result = operator == Operator.MUST_PASS_ONE;
@@ -180,7 +179,7 @@
   }
 
   /** {@inheritDoc} */
-  public boolean filterRow(final SortedMap<Text, byte[]> columns) {
+  public boolean filterRow(final SortedMap<byte [], byte[]> columns) {
     boolean resultFound = false;
     boolean result = operator == Operator.MUST_PASS_ONE;
     for (RowFilterInterface filter : filters) {

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/filter/StopRowFilter.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/filter/StopRowFilter.java?rev=656868&r1=656867&r2=656868&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/filter/StopRowFilter.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/filter/StopRowFilter.java Thu May 15 15:10:47 2008
@@ -24,7 +24,7 @@
 import java.io.IOException;
 import java.util.SortedMap;
 
-import org.apache.hadoop.io.Text;
+import org.apache.hadoop.hbase.util.Bytes;
 
 /**
  * Implementation of RowFilterInterface that filters out rows greater than or 
@@ -32,7 +32,7 @@
  */
 public class StopRowFilter implements RowFilterInterface {
 
-  protected Text stopRowKey;
+  private byte [] stopRowKey;
   
   /**
    * Default constructor, filters nothing. Required though for RPC
@@ -47,7 +47,7 @@
    * 
    * @param stopRowKey rowKey to filter on.
    */
-  public StopRowFilter(final Text stopRowKey) {
+  public StopRowFilter(final byte [] stopRowKey) {
     this.stopRowKey = stopRowKey;
   }
   
@@ -56,7 +56,7 @@
    * 
    * @return the filter's stopRowKey
    */
-  public Text getStopRowKey() {
+  public byte [] getStopRowKey() {
     return this.stopRowKey;
   }
 
@@ -64,7 +64,7 @@
    * 
    * {@inheritDoc}
    */
-  public void validate(@SuppressWarnings("unused") final Text[] columns) {
+  public void validate(@SuppressWarnings("unused") final byte [][] columns) {
     // Doesn't filter columns
   }
 
@@ -78,7 +78,7 @@
 
   /** {@inheritDoc} */
   @SuppressWarnings("unused")
-  public void rowProcessed(boolean filtered, Text rowKey) {
+  public void rowProcessed(boolean filtered, byte [] rowKey) {
     // Doesn't care
   }
 
@@ -93,14 +93,14 @@
   }
 
   /** {@inheritDoc} */
-  public boolean filterRowKey(final Text rowKey) {
+  public boolean filterRowKey(final byte [] rowKey) {
     if (rowKey == null) {
       if (this.stopRowKey == null) {
         return true;
       }
       return false;
     }
-    return this.stopRowKey.compareTo(rowKey) <= 0;
+    return Bytes.compareTo(stopRowKey, rowKey) <= 0;
   }
 
   /**
@@ -109,8 +109,8 @@
    * Because StopRowFilter does not examine column information, this method 
    * defaults to calling the rowKey-only version of filter.
    */
-  public boolean filterColumn(@SuppressWarnings("unused") final Text rowKey,
-    @SuppressWarnings("unused") final Text colKey,
+  public boolean filterColumn(@SuppressWarnings("unused") final byte [] rowKey,
+    @SuppressWarnings("unused") final byte [] colKey,
     @SuppressWarnings("unused") final byte[] data) {
     return filterRowKey(rowKey);
   }
@@ -123,17 +123,17 @@
    * @param columns
    */
   public boolean filterRow(@SuppressWarnings("unused")
-      final SortedMap<Text, byte[]> columns) {
+      final SortedMap<byte [], byte[]> columns) {
     return filterAllRemaining();
   }
 
   /** {@inheritDoc} */
   public void readFields(DataInput in) throws IOException {
-    stopRowKey = new Text(in.readUTF());
+    this.stopRowKey = Bytes.readByteArray(in);
   }
 
   /** {@inheritDoc} */
   public void write(DataOutput out) throws IOException {
-    out.writeUTF(stopRowKey.toString());
+    Bytes.writeByteArray(out, this.stopRowKey);
   }
-}
+}
\ No newline at end of file

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/filter/WhileMatchRowFilter.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/filter/WhileMatchRowFilter.java?rev=656868&r1=656867&r2=656868&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/filter/WhileMatchRowFilter.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/filter/WhileMatchRowFilter.java Thu May 15 15:10:47 2008
@@ -24,7 +24,6 @@
 import java.io.IOException;
 import java.util.SortedMap;
 
-import org.apache.hadoop.io.Text;
 
 /**
  * WhileMatchRowFilter is a wrapper filter that filters everything after the 
@@ -86,20 +85,20 @@
   }
   
   /** {@inheritDoc} */
-  public boolean filterRowKey(final Text rowKey) {
+  public boolean filterRowKey(final byte [] rowKey) {
     changeFAR(this.filter.filterRowKey(rowKey));
     return filterAllRemaining();
   }
   
   /** {@inheritDoc} */
-  public boolean filterColumn(final Text rowKey, final Text colKey,
+  public boolean filterColumn(final byte [] rowKey, final byte [] colKey,
     final byte[] data) {
     changeFAR(this.filter.filterColumn(rowKey, colKey, data));
     return filterAllRemaining();
   }
   
   /** {@inheritDoc} */
-  public boolean filterRow(final SortedMap<Text, byte[]> columns) {
+  public boolean filterRow(final SortedMap<byte [], byte[]> columns) {
     changeFAR(this.filter.filterRow(columns));
     return filterAllRemaining();
   }
@@ -115,12 +114,12 @@
   }
 
   /** {@inheritDoc} */
-  public void rowProcessed(boolean filtered, Text rowKey) {
+  public void rowProcessed(boolean filtered, byte [] rowKey) {
     this.filter.rowProcessed(filtered, rowKey);
   }
   
   /** {@inheritDoc} */
-  public void validate(Text[] columns) {
+  public void validate(final byte [][] columns) {
     this.filter.validate(columns);
   }