hbase-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jonathan Hsieh (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HBASE-9477) Add deprecation compat shim for Result#raw and Result#list for 0.96
Date Tue, 10 Sep 2013 00:04:52 GMT

    [ https://issues.apache.org/jira/browse/HBASE-9477?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13762494#comment-13762494
] 

Jonathan Hsieh commented on HBASE-9477:
---------------------------------------

Every instance inside hbase moves to new api.  Here's the meat of the patch:

{code}
diff --git hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java
index 9039b01..0d7406f 100644
--- hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java
+++ hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java
@@ -61,7 +61,7 @@ import org.apache.hadoop.hbase.util.Bytes;
  * A Result is backed by an array of {@link KeyValue} objects, each representing
  * an HBase cell defined by the row, family, qualifier, timestamp, and value.<p>
  *
- * The underlying {@link KeyValue} objects can be accessed through the method {@link #list()}.
+ * The underlying {@link KeyValue} objects can be accessed through the method {@link #listCells()}.
  * Each KeyValue can then be accessed through
  * {@link KeyValue#getRow()}, {@link KeyValue#getFamily()}, {@link KeyValue#getQualifier()},
  * {@link KeyValue#getTimestamp()}, and {@link KeyValue#getValue()}.<p>
@@ -85,7 +85,7 @@ public class Result implements CellScannable {
   public static final Result EMPTY_RESULT = new Result();
 
   /**
-   * Creates an empty Result w/ no KeyValue payload; returns null if you call {@link #raw()}.
+   * Creates an empty Result w/ no KeyValue payload; returns null if you call {@link #rawCells()}.
    * Use this to represent no results if <code>null</code> won't do or in old
'mapred' as oppposed to 'mapreduce' package
    * MapReduce where you need to overwrite a Result
    * instance with a {@link #copyFrom(Result)} call.
@@ -147,20 +147,55 @@ public class Result implements CellScannable {
    *
    * @return array of Cells; can be null if nothing in the result
    */
-  public Cell[] raw() {
+  public Cell[] rawCells() {
     return cells;
   }
 
   /**
+   * Return an cells of a Result as an array of KeyValues 
+   * 
+   * WARNING do not use, expensive.  This does an arraycopy of the cell[]'s value.
+   *
+   * Added to ease transition from  0.94 -> 0.96.
+   * 
+   * @deprecated as of 0.96, use {@link #rawCells()}  
+   * @return
+   */
+  @Deprecated
+  public KeyValue[] raw() {
+    KeyValue[] kvs = new KeyValue[cells.length];
+    for (int i = 0 ; i < kvs.length; i++) {
+      kvs[i] = KeyValueUtil.ensureKeyValue(cells[i]);
+    }
+    return kvs;
+  }
+
+  /**
    * Create a sorted list of the Cell's in this result.
    *
    * Since HBase 0.20.5 this is equivalent to raw().
    *
    * @return The sorted list of Cell's.
    */
-  public List<Cell> list() {
-    return isEmpty()? null: Arrays.asList(raw());
+  public List<Cell> listCells() {
+    return isEmpty()? null: Arrays.asList(rawCells());
   }
+  
+  /**
+   * Return an cells of a Result as an array of KeyValues 
+   * 
+   * WARNING do not use, expensive.  This does  an arraycopy of the cell[]'s value.
+   *
+   * Added to ease transition from  0.94 -> 0.96.
+   * 
+   * @deprecated as of 0.96, use {@link #listCells()}  
+   * @return
+   */
+  @Deprecated
+  public List<KeyValue> list() {
+    return isEmpty() ? null : Arrays.asList(raw());
+  }
+
 
   /**
    * Return the Cells for the specific column.  The Cells are sorted in
{code}

                
> Add deprecation compat shim for Result#raw and Result#list for 0.96
> -------------------------------------------------------------------
>
>                 Key: HBASE-9477
>                 URL: https://issues.apache.org/jira/browse/HBASE-9477
>             Project: HBase
>          Issue Type: Sub-task
>    Affects Versions: 0.95.2
>            Reporter: Jonathan Hsieh
>            Assignee: Jonathan Hsieh
>            Priority: Blocker
>             Fix For: 0.96.0
>
>         Attachments: hbase-9477.patch
>
>
> Discussion in HBASE-9359 brought up that applications commonly use the Keyvalue[] Result#raw
(and similarly Result#list).  Let's rename the 0.96 version to something like #listCells and
#rawCells and revert #raw and #list to their old signature to easy upgrade deprecation issues.


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message