不解释,看代码去吧,很简单。
private long findBatterHisDataCount(BatteryHisDto dto) throws Exception{ long totalSize=0; Table table=runner.getTable(tableName); Scan countScan = new Scan(); ResultScanner countScanner = null; List<Filter> countFilters = new ArrayList<Filter>(); if(StringUtils.isNotBlank(dto.getBatteryNo())){//电池组编号过滤 Filter filter=new RowFilter(CompareFilter.CompareOp.EQUAL, new SubstringComparator(dto.getBatteryNo()+"_")); countFilters.add(filter); } countFilters.add(new FirstKeyOnlyFilter()); FilterList countFilterList = new FilterList(FilterList.Operator.MUST_PASS_ALL, countFilters); countScan.setFilter(countFilterList); countScan.setCaching(500); countScan.setCacheBlocks(false); countScanner = table.getScanner(countScan); for (Result result : countScanner) { totalSize ++; } return totalSize; }