HBASE-2093 [stargate] RowSpec parse bug

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@897094 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew Kyle Purtell 2010-01-08 05:04:58 +00:00
parent a9482a2382
commit 9039e79ec2
4 changed files with 42 additions and 5 deletions

View File

@ -65,8 +65,8 @@ Release 0.21.0 - Unreleased
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 @@ Release 0.21.0 - Unreleased
(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

View File

@ -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 class RowResource implements Constants {
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 @@ public class RowResource implements Constants {
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) {

View File

@ -277,7 +277,26 @@ scheme://user:pass@example.net:8080/path/to/file;type=foo?name=val#frag
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>

View File

@ -23,6 +23,7 @@ package org.apache.hadoop.hbase.stargate;
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 javax.xml.bind.Unmarshaller;
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 @@ public class TestRowResource extends MiniClusterTestCase {
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