Hbase 从put获取postput中列的值
我正在hbase中实现一个potput函数,我需要获取该函数中特殊列的值Hbase 从put获取postput中列的值,hbase,Hbase,我正在hbase中实现一个potput函数,我需要获取该函数中特殊列的值 class AccessControlCoprocessor extends BaseRegionObserver { @Override public void postPut(ObserverContext<RegionCoprocessorEnvironment> e, Put put, WALEdit edit,
class AccessControlCoprocessor extends BaseRegionObserver {
@Override
public void postPut(ObserverContext<RegionCoprocessorEnvironment> e,
Put put,
WALEdit edit,
Durability durability)
throws IOException
{
/*
the original put was added in this way
val p = new Put(Bytes.toBytes(data.hashCode().toString()))
p.add(Bytes.toBytes("cf1"),
Bytes.toBytes("count"), Bytes.toBytes("1"))
I nee to get "1" from the above
*/
}
}
类AccessControlCoprocessor扩展BaseRegionObserver{
@凌驾
public void postPut(观察者),
放,,
沃尔编辑,
耐久性(耐久性)
抛出IOException
{
/*
原来的put就是这样添加的
val p=新的Put(Bytes.toBytes(data.hashCode().toString())
p、 添加(Bytes.toBytes(“cf1”),
字节.toBytes(“计数”),字节.toBytes(“1”)
我需要从上面得到“1”
*/
}
}
如何从上面获取“1”,我想使用行键和列标识符来实现这一点。当您知道列族时,可以直接从传递到协处理器的
Put
对象获取值:
final List<Cell> cells = put.get(Bytes.toBytes("cf1"), Bytes.toBytes("count"));
// we assume that there is only one cell in this Put transaction
Cell cell = cells.get(0)
byte[] value = CellUtil.cloneValue(cell);
String valueAsString = new String(value);
final List cells=put.get(Bytes.toBytes(“cf1”)、Bytes.toBytes(“count”);
//我们假设此Put事务中只有一个单元格
单元格=单元格。获取(0)
字节[]值=CellUtil.cloneValue(单元格);
字符串值字符串=新字符串(值);
CellUtils
可从获取当您知道列族时,可以直接从传递到协处理器的Put
对象获取值:
final List<Cell> cells = put.get(Bytes.toBytes("cf1"), Bytes.toBytes("count"));
// we assume that there is only one cell in this Put transaction
Cell cell = cells.get(0)
byte[] value = CellUtil.cloneValue(cell);
String valueAsString = new String(value);
final List cells=put.get(Bytes.toBytes(“cf1”)、Bytes.toBytes(“count”);
//我们假设此Put事务中只有一个单元格
单元格=单元格。获取(0)
字节[]值=CellUtil.cloneValue(单元格);
字符串值字符串=新字符串(值);
CellUtils
可从