hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdcry...@apache.org
Subject svn commit: r700528 - in /hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase: HConstants.java client/HTable.java
Date Tue, 30 Sep 2008 17:18:33 GMT
Author: jdcryans
Date: Tue Sep 30 10:18:33 2008
New Revision: 700528

URL: http://svn.apache.org/viewvc?rev=700528&view=rev
Log:
HBASE-901 Add a limit to key length, check key and value length on client side

Modified:
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HConstants.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HTable.java

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HConstants.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HConstants.java?rev=700528&r1=700527&r2=700528&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HConstants.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HConstants.java Tue Sep 30 10:18:33
2008
@@ -209,6 +209,11 @@
     */
   static final byte [] LAST_ROW = EMPTY_BYTE_ARRAY;
   
+  /**
+   * Max length a row can have because of the limitation in TFile.
+   */
+  static final int MAX_ROW_LENGTH = 1024*64;
+  
   /** When we encode strings, we always specify UTF8 encoding */
   static final String UTF8_ENCODING = "UTF-8";
 

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=700528&r1=700527&r2=700528&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 Tue Sep 30 10:18:33
2008
@@ -34,11 +34,13 @@
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HRegionLocation;
 import org.apache.hadoop.hbase.HServerAddress;
+import org.apache.hadoop.hbase.HStoreKey;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitor;
 import org.apache.hadoop.hbase.filter.RowFilterInterface;
 import org.apache.hadoop.hbase.filter.StopRowFilter;
 import org.apache.hadoop.hbase.filter.WhileMatchRowFilter;
+import org.apache.hadoop.hbase.io.BatchOperation;
 import org.apache.hadoop.hbase.io.BatchUpdate;
 import org.apache.hadoop.hbase.io.Cell;
 import org.apache.hadoop.hbase.io.RowResult;
@@ -979,8 +981,7 @@
   public synchronized void commit(final BatchUpdate batchUpdate,
       final RowLock rl) 
   throws IOException {
-    if (batchUpdate.getRow() == null)
-      throw new IllegalArgumentException("update has null row");
+    checkRowAndColumns(batchUpdate);
     connection.getRegionServerWithRetries(
       new ServerCallable<Boolean>(connection, tableName, batchUpdate.getRow()) {
         public Boolean call() throws IOException {
@@ -1006,6 +1007,24 @@
     for (BatchUpdate batchUpdate : batchUpdates) 
       commit(batchUpdate,null);
   }
+  
+  /**
+   * Utility method that checks rows existence, length and 
+   * columns well formedness.
+   * @param bu
+   * @throws IllegalArgumentException
+   * @throws IOException
+   */
+  private void checkRowAndColumns(BatchUpdate bu)
+      throws IllegalArgumentException, IOException {
+    if (bu.getRow() == null || 
+        bu.getRow().length > HConstants.MAX_ROW_LENGTH) {
+      throw new IllegalArgumentException("Row key is invalid");
+    }
+    for (BatchOperation bo : bu) {
+      HStoreKey.getFamily(bo.getColumn());
+    }
+  }
 
   /**
    * Obtain a row lock



Mime
View raw message