diff --git a/CHANGES.txt b/CHANGES.txt index 9f25b33daa4..b211c788aba 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -64,8 +64,6 @@ Release 0.18.0 - Unreleased 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 @@ Release 0.18.0 - Unreleased 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) diff --git a/src/java/org/apache/hadoop/hbase/io/BatchUpdate.java b/src/java/org/apache/hadoop/hbase/io/BatchUpdate.java index c4aa50e6fd3..6c68743d3cf 100644 --- a/src/java/org/apache/hadoop/hbase/io/BatchUpdate.java +++ b/src/java/org/apache/hadoop/hbase/io/BatchUpdate.java @@ -143,6 +143,43 @@ public class BatchUpdate implements Writable, Iterable { 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 * diff --git a/src/test/org/apache/hadoop/hbase/client/TestBatchUpdate.java b/src/test/org/apache/hadoop/hbase/client/TestBatchUpdate.java index 8a214ddcfa4..6c81cb85f4f 100644 --- a/src/test/org/apache/hadoop/hbase/client/TestBatchUpdate.java +++ b/src/test/org/apache/hadoop/hbase/client/TestBatchUpdate.java @@ -86,7 +86,12 @@ public class TestBatchUpdate extends HBaseClusterTestCase { 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);