hbase-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "stack (JIRA)" <j...@apache.org>
Subject [jira] Updated: (HBASE-764) The name of column request has padding zero using REST interface
Date Wed, 23 Jul 2008 17:52:31 GMT

     [ https://issues.apache.org/jira/browse/HBASE-764?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

stack updated HBASE-764:
------------------------

       Resolution: Fixed
    Fix Version/s: 0.2.0
           Status: Resolved  (was: Patch Available)

Committed.  Thanks for the patch Sishen.

I think the Text stuff is just left-over from the days when hbase was all Text (now its all
byte arrays).  Regards encoding, when you pass a String into BatchUpdate, it'll do getBytes("UTF-8")
on the passed String so yes, default is UTF-8 everything.  If you want to do another encoding,
you could manage the String.getBytes yourself passing an alternate encoding.

Keep banging on the REST.  There may be more lurkers in there yet, stuff that hasn't been
updated to match the new all-byte-arrays-all-the-time regime.

> The name of column request has padding zero using REST interface
> ----------------------------------------------------------------
>
>                 Key: HBASE-764
>                 URL: https://issues.apache.org/jira/browse/HBASE-764
>             Project: Hadoop HBase
>          Issue Type: Bug
>          Components: rest
>    Affects Versions: 0.2.0
>         Environment: Debian GNU/Linux,  Java5
>            Reporter: sishen.freecity
>             Fix For: 0.2.0
>
>         Attachments: rest_column-v2.patch, rest_column.patch
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> Today when i play with the REST interface and found the column POST/PUT/GET has a problem.
> When i use the hbase shell to check the data, i found the row name has the padding zero.
> The cause is that TableHandler use Text class to encode the string to the UTF-8. But
CharSetEncoder
> will pre-allocate more spaces then the length of String for performance. So we get the
padding zero
> when inserting the value to the table.  The fix is to get the String instead of the byte[]
for the BatchUpdate.
> Below is the patch.  Also, the patch includes fixing the wrong use of (bytes[]).toString()
using Bytes.toString(byte[])
> Index: src/java/org/apache/hadoop/hbase/rest/TableHandler.java
> ===================================================================
> --- src/java/org/apache/hadoop/hbase/rest/TableHandler.java    (revision 678664)
> +++ src/java/org/apache/hadoop/hbase/rest/TableHandler.java    (working copy)
> @@ -174,7 +174,7 @@
>  
>          // copy over those cells with requested column names
>          for(byte [] current_column: columns_retrieved) {
> -          if(requested_columns_set.contains(current_column.toString())){
> +          if(requested_columns_set.contains(Bytes.toString(current_column))){
>              m.put(current_column, prefiltered_result.get(current_column));         
 
>            }
>          }
> @@ -295,7 +295,7 @@
>     
>      try{
>        // start an update
> -      Text key = new Text(row);
> +      String key = new Text(row).toString();
>        batchUpdate = timestamp == null ?
>          new BatchUpdate(key) : new BatchUpdate(key, Long.parseLong(timestamp));
>  
> @@ -308,7 +308,7 @@
>  
>          // extract the name and value children
>          Node name_node = column.getElementsByTagName("name").item(0);
> -        Text name = new Text(name_node.getFirstChild().getNodeValue());
> +        String name = new Text(name_node.getFirstChild().getNodeValue()).toString();
>  
>          Node value_node = column.getElementsByTagName("value").item(0);
>  
> @@ -356,7 +356,7 @@
>            XMLOutputter outputter = getXMLOutputter(response.getWriter());
>            outputter.startTag("regions");
>            for (int i = 0; i < startKeys.length; i++) {
> -            doElement(outputter, "region", startKeys[i].toString());
> +            doElement(outputter, "region", Bytes.toString(startKeys[i]));
>            }
>            outputter.endTag();
>            outputter.endDocument();
> @@ -368,7 +368,7 @@
>            PrintWriter out = response.getWriter();
>            for (int i = 0; i < startKeys.length; i++) {
>              // TODO: Add in the server location.  Is it needed?
> -            out.print(startKeys[i].toString());
> +            out.print(Bytes.toString(startKeys[i]));
>            }
>            out.close();
>          break;
> @@ -454,7 +454,7 @@
>      // pull the row key out of the path
>      String row = URLDecoder.decode(pathSegments[2], HConstants.UTF8_ENCODING);
>     
> -    Text key = new Text(row);
> +    String key = new Text(row).toString();
>  
>      String[] columns = request.getParameterValues(COLUMN);
>         
> @@ -472,7 +472,7 @@
>        } else{
>          // delete each column in turn     
>          for(int i = 0; i < columns.length; i++){
> -          table.deleteAll(key, new Text(columns[i]));
> +          table.deleteAll(key, new Text(columns[i]).toString());
>          }
>        }
>        response.setStatus(202);

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message