hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r694352 - in /hadoop/hbase/trunk: CHANGES.txt src/java/org/apache/hadoop/hbase/io/BatchUpdate.java src/test/org/apache/hadoop/hbase/client/TestBatchUpdate.java
Date Thu, 11 Sep 2008 17:04:42 GMT
Author: jimk
Date: Thu Sep 11 10:04:39 2008
New Revision: 694352

URL: http://svn.apache.org/viewvc?rev=694352&view=rev
Log:
HBASE-882  The BatchUpdate class provides, put(col, cell) and delete(col) but no get() (Ryan
Smith via Stack and Jim Kellerman)

Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/io/BatchUpdate.java
    hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/client/TestBatchUpdate.java

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=694352&r1=694351&r2=694352&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Thu Sep 11 10:04:39 2008
@@ -64,8 +64,6 @@
                splits (Jonathan Gray via Stack)
    HBASE-877   HCM is unable to find table with multiple regions which contains
                binary (Jonathan Gray via Stack)
-   HBASE-822  The BatchUpdate class provides, put(col, cell) and delete(col)
-              but no get() (Ryan Smith via Stack)
 
   IMPROVEMENTS
    HBASE-801  When a table haven't disable, shell could response in a "user
@@ -89,6 +87,8 @@
    HBASE-871  Major compaction periodicity should be specifyable at the column
               family level, not cluster wide (Jonathan Gray via Stack)
    HBASE-465  Fix javadoc for all public declarations
+   HBASE-882  The BatchUpdate class provides, put(col, cell) and delete(col)
+              but no get() (Ryan Smith via Stack and Jim Kellerman)
 
   NEW FEATURES
    HBASE-787  Postgresql to HBase table replication example (Tim Sell via Stack)

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/io/BatchUpdate.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/io/BatchUpdate.java?rev=694352&r1=694351&r2=694352&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/io/BatchUpdate.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/io/BatchUpdate.java Thu Sep 11 10:04:39
2008
@@ -143,6 +143,43 @@
     return null;
   }
 
+  /**
+   * Get the current columns
+   * 
+   * @return byte[][] an array of byte[] columns
+   */
+  public synchronized byte[][] getColumns() {
+    byte[][] columns = new byte[operations.size()][];
+    for (int i = 0; i < operations.size(); i++) {
+      columns[i] = operations.get(i).getColumn();
+    }
+    return columns;
+  }
+
+  /**
+   * Check if the specified column is currently assigned a value
+   * 
+   * @param column column to check for
+   * @return boolean true if the given column exists
+   */
+  public synchronized boolean hasColumn(String column) {
+    return hasColumn(Bytes.toBytes(column));
+  }
+  
+  /**
+   * Check if the specified column is currently assigned a value
+   * 
+   * @param column column to check for
+   * @return boolean true if the given column exists
+   */
+  public synchronized boolean hasColumn(byte[] column) {
+    byte[] getColumn = get(column);
+    if (getColumn == null) {
+      return false;
+    }
+    return true;
+  }
+  
   /** 
    * Change a value for the specified column
    *

Modified: hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/client/TestBatchUpdate.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/client/TestBatchUpdate.java?rev=694352&r1=694351&r2=694352&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/client/TestBatchUpdate.java (original)
+++ hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/client/TestBatchUpdate.java Thu Sep
11 10:04:39 2008
@@ -86,7 +86,12 @@
 
     bu = new BatchUpdate("row2");
     bu.put(CONTENTS, value);
-    byte[] getValue = bu.get(CONTENTS);
+    byte[][] getColumns = bu.getColumns();
+    assertEquals(getColumns.length, 1);
+    assertTrue(Arrays.equals(getColumns[0], CONTENTS));
+    assertTrue(bu.hasColumn(CONTENTS));
+    assertFalse(bu.hasColumn(new byte[] {}));
+    byte[] getValue = bu.get(getColumns[0]);
     assertTrue(Arrays.equals(getValue, value));
     table.commit(bu);
 



Mime
View raw message