如何从值列从hbase表中获取最大值?

如何从值列从hbase表中获取最大值?,hbase,Hbase,在这里,我尝试获取最大值行及其值。 我想知道是否存在任何函数,而不是标准迭代 Scan s = new Scan(); ResultScanner re = table.getScanner(s); int maxVal =0; try{ for (Result rr = re.next(); rr != null; rr = re.next()) { byte [] row = rr.getRow(); Get g = new Get(

在这里,我尝试获取最大值行及其值。 我想知道是否存在任何函数,而不是标准迭代

Scan s = new Scan();
ResultScanner re = table.getScanner(s);
int maxVal =0;         
try{
    for (Result rr = re.next(); rr != null; rr = re.next()) {
        byte [] row = rr.getRow();
        Get g = new Get(row);
        Result r = table.get(g);                   
        String rn = Bytes.toString(r.value());
        int temp = Integer.parseInt(rn);
        if(maxVal < temp)
        maxVal = temp;
    }
    System.out.println(maxVal);
}
finally {
    re.close();
}
Scan s=新扫描();
ResultScanner re=table.getScanner(s);
int maxVal=0;
试一试{
for(结果rr=re.next();rr!=null;rr=re.next()){
字节[]行=rr.getRow();
Get g=新Get(行);
结果r=表get(g);
字符串rn=Bytes.toString(r.value());
int temp=整数.parseInt(rn);
如果(最大值<温度)
maxVal=温度;
}
System.out.println(maxVal);
}
最后{
re.close();
}
有一个max()方法,但它出现在“org.apache.hadoop.hbase.client.coprocessor”中。如果您对co procs满意,那么您可以尝试一下。它给出给定范围内给定列族的列的最大值。您可以在此处指定第一列和最后一列作为范围,并获取最大值。有关详细信息,请访问