HBASE CellUtil vs KeyValue
我有一个简单的问题。我是否应该像这样使用CellUtil类:HBASE CellUtil vs KeyValue,hbase,cell,Hbase,Cell,我有一个简单的问题。我是否应该像这样使用CellUtil类: for (Cell cell : result.rawCells()) { byte[] family = CellUtil.cloneFamily(cell); byte[] column = CellUtil.cloneQualifier(cell); byte[] value = CellUtil.cloneValue(cell);
for (Cell cell : result.rawCells()) {
byte[] family = CellUtil.cloneFamily(cell);
byte[] column = CellUtil.cloneQualifier(cell);
byte[] value = CellUtil.cloneValue(cell);
System.out.println("\t" + Bytes.toString(family) + ":" + Bytes.toString(column) + " = " + Bytes.toString(value));
}
或用于访问结果单元格的KeyValue类
for(KeyValue kv : result.list()){
String family = new String(kv.getFamily());
System.out.println(family);
String qualifier = new String(kv.getQualifier());
System.out.println(qualifier);
System.out.println(new String(kv.getValue()));
}
是否不推荐使用KeyValue
非常感谢您的回答KeyValue没有被弃用,但它的方法如getFamily、getQualifier、getValue等却被弃用。 在API文档中,您可以看到建议使用CellUtil类方法(客户端)和CellInterface方法(服务器端)。 这是因为根据HBase文档,
KeyValue是基本的HBase类型,建议HBase应用程序和用户使用Cell接口,避免直接使用未在Cell中定义的KeyValue和成员函数 KeyValue没有被弃用,但它的方法如getFamily、getQualifier、getValue等都被弃用。 在API文档中,您可以看到建议使用CellUtil类方法(客户端)和CellInterface方法(服务器端)。 这是因为根据HBase文档, KeyValue是基本的HBase类型,建议HBase应用程序和用户使用Cell接口,避免直接使用未在Cell中定义的KeyValue和成员函数 请参见此链接: 如果在客户端使用,则访问各个字段的主要方法是getRowArray()、getFamilyArray()、getQualifierArray()、getTimestamp()和getValueArray()。这些方法分配新的字节数组并返回副本。避免在服务器端使用它们 请参阅此链接: 如果在客户端使用,则访问各个字段的主要方法是getRowArray()、getFamilyArray()、getQualifierArray()、getTimestamp()和getValueArray()。这些方法分配新的字节数组并返回副本。避免在服务器端使用它们