hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject svn commit: r897094 - in /hadoop/hbase/trunk: ./ src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/ src/contrib/stargate/src/test/org/apache/hadoop/hbase/stargate/
Date Fri, 08 Jan 2010 05:05:04 GMT
Author: apurtell
Date: Fri Jan  8 05:04:58 2010
New Revision: 897094

URL: http://svn.apache.org/viewvc?rev=897094&view=rev
Log:
HBASE-2093 [stargate] RowSpec parse bug

Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RowResource.java
    hadoop/hbase/trunk/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/package.html
    hadoop/hbase/trunk/src/contrib/stargate/src/test/org/apache/hadoop/hbase/stargate/TestRowResource.java

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=897094&r1=897093&r2=897094&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Fri Jan  8 05:04:58 2010
@@ -65,8 +65,8 @@
    HBASE-1831  Scanning API must be reworked to allow for fully functional
                Filters client-side
    HBASE-1890  hbase-1506 where assignment is done at regionserver doesn't
-                work
-   HBASE-1889 ClassNotFoundException on trunk for REST
+               work
+   HBASE-1889  ClassNotFoundException on trunk for REST
    HBASE-1905  Remove unused config. hbase.hstore.blockCache.blockSize
    HBASE-1906  FilterList of prefix and columnvalue not working properly with
                deletes and multiple values
@@ -150,6 +150,7 @@
                (Scott Wang via Andrew Purtell)
    HBASE-2068  MetricsRate is missing "registry" parameter
                (Lars George and Gary Helmling via Stack)
+   HBASE-2093  [stargate] RowSpec parse bug
 
   IMPROVEMENTS
    HBASE-1760  Cleanup TODOs in HTable

Modified: hadoop/hbase/trunk/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RowResource.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RowResource.java?rev=897094&r1=897093&r2=897094&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RowResource.java
(original)
+++ hadoop/hbase/trunk/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/RowResource.java
Fri Jan  8 05:04:58 2010
@@ -21,6 +21,7 @@
 package org.apache.hadoop.hbase.stargate;
 
 import java.io.IOException;
+import java.net.URLDecoder;
 import java.util.List;
 
 import javax.ws.rs.Consumes;
@@ -60,7 +61,8 @@
   public RowResource(String table, String rowspec, String versions)
       throws IOException {
     this.table = table;
-    this.rowspec = new RowSpec(rowspec);
+    this.rowspec = new RowSpec(URLDecoder.decode(rowspec,
+      HConstants.UTF8_ENCODING));
     if (versions != null) {
       this.rowspec.setMaxVersions(Integer.valueOf(versions));
     }
@@ -143,7 +145,8 @@
     try {
       table = pool.getTable(this.table);
       for (RowModel row: model.getRows()) {
-        Put put = new Put(row.getKey());
+        byte[] key = row.getKey();
+        Put put = new Put(key);
         for (CellModel cell: row.getCells()) {
           byte [][] parts = KeyValue.parseColumn(cell.getColumn());
           if(parts.length == 1) {

Modified: hadoop/hbase/trunk/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/package.html
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/package.html?rev=897094&r1=897093&r2=897094&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/package.html
(original)
+++ hadoop/hbase/trunk/src/contrib/stargate/src/java/org/apache/hadoop/hbase/stargate/package.html
Fri Jan  8 05:04:58 2010
@@ -277,7 +277,26 @@
 Stargate exposes HBase tables, rows, cells, and metadata as URL specified
 resources.
 <p>
-
+<b>NOTE:</b> The characters <tt>/</tt>, <tt>:</tt>, and
<tt>,</tt> are reserved
+within row keys, column names, and column qualifiers. Clients must escape them
+somehow, perhaps by encoding them as hex escapes or by using www-url-encoding. For
+example, the key:
+<p>
+<pre>
+    http://www.google.com/
+</pre>
+<p>
+should first be encoded as:
+<p>
+<pre>
+    http%3A%2F%2Fwww.google.com%2F
+</pre>
+<p>
+to produce a path like:
+<pre>
+    /SomeTable/http%3A%2F%2Fwww.google.com%2F/someColumn:qualifier
+</pre>
+<p>
 <h3>Addressing for cell or row query (GET)</h3>
 <p>
 <pre>

Modified: hadoop/hbase/trunk/src/contrib/stargate/src/test/org/apache/hadoop/hbase/stargate/TestRowResource.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/contrib/stargate/src/test/org/apache/hadoop/hbase/stargate/TestRowResource.java?rev=897094&r1=897093&r2=897094&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/contrib/stargate/src/test/org/apache/hadoop/hbase/stargate/TestRowResource.java
(original)
+++ hadoop/hbase/trunk/src/contrib/stargate/src/test/org/apache/hadoop/hbase/stargate/TestRowResource.java
Fri Jan  8 05:04:58 2010
@@ -23,6 +23,7 @@
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.StringWriter;
+import java.net.URLEncoder;
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
@@ -31,6 +32,7 @@
 
 import org.apache.commons.httpclient.Header;
 import org.apache.hadoop.hbase.HColumnDescriptor;
+import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.KeyValue;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
@@ -301,6 +303,18 @@
     assertEquals(response.getCode(), 200);
   }
 
+  public void testURLEncodedKey() throws IOException, JAXBException {
+    String encodedKey = URLEncoder.encode("http://www.google.com/", 
+      HConstants.UTF8_ENCODING);
+    Response response;
+    response = putValueXML(TABLE, encodedKey, COLUMN_1, VALUE_1);
+    assertEquals(response.getCode(), 200);
+    response = putValuePB(TABLE, encodedKey, COLUMN_2, VALUE_2);
+    assertEquals(response.getCode(), 200);
+    checkValuePB(TABLE, encodedKey, COLUMN_1, VALUE_1);
+    checkValueXML(TABLE, encodedKey, COLUMN_2, VALUE_2);
+  }
+
   public void testMultiCellGetPutXML() throws IOException, JAXBException {
     String path = "/" + TABLE + "/fakerow";  // deliberate nonexistent row
 



Mime
View raw message