HBASE-882 The BatchUpdate class provides, put(col, cell) and delete(col) but no get().
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@693987 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
16a2c45780
commit
748b21e94a
|
@ -64,6 +64,8 @@ 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
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.io.DataInput;
|
|||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.hadoop.hbase.HConstants;
|
||||
|
@ -117,6 +118,31 @@ public class BatchUpdate implements Writable, Iterable<BatchOperation> {
|
|||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current value of the specified column
|
||||
*
|
||||
* @param column column name
|
||||
* @return byte[] the cell value, returns null if the column does not exist.
|
||||
*/
|
||||
public synchronized byte[] get(final String column) {
|
||||
return get(Bytes.toBytes(column));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current value of the specified column
|
||||
*
|
||||
* @param column column name
|
||||
* @return byte[] the cell value, returns null if the column does not exist.
|
||||
*/
|
||||
public synchronized byte[] get(final byte[] column) {
|
||||
for (BatchOperation operation: operations) {
|
||||
if (Arrays.equals(column, operation.getColumn())) {
|
||||
return operation.getValue();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change a value for the specified column
|
||||
*
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.apache.hadoop.hbase.client;
|
|||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.hadoop.hbase.HBaseClusterTestCase;
|
||||
|
@ -85,6 +86,8 @@ public class TestBatchUpdate extends HBaseClusterTestCase {
|
|||
|
||||
bu = new BatchUpdate("row2");
|
||||
bu.put(CONTENTS, value);
|
||||
byte[] getValue = bu.get(CONTENTS);
|
||||
assertTrue(Arrays.equals(getValue, value));
|
||||
table.commit(bu);
|
||||
|
||||
byte [][] columns = { CONTENTS };
|
||||
|
|
Loading…
Reference in New Issue