hbase 字段值开头查询
- hbase 查询字段开头
public static List<ContentCommodityDto> loadData(int loadSize) { List<ContentCommodityDto> dataList = new ArrayList<>(); Table table = null; try { table = HbaseUtil.getTable(tableName); Scan scan = new Scan(); scan.setMaxResultSize(10); scan.addColumn(HadoopConfig.FAMILY, "shopType".getBytes()); scan.addColumn(HadoopConfig.FAMILY, "netURL".getBytes()); scan.addColumn(HadoopConfig.FAMILY, "ocr".getBytes()); scan.addColumn(HadoopConfig.FAMILY, "text".getBytes()); scan.addColumn(HadoopConfig.FAMILY, "temp".getBytes()); scan.addColumn(HadoopConfig.FAMILY, "cityCode".getBytes()); FilterList allFilters = new FilterList(FilterList.Operator.MUST_PASS_ALL); SingleColumnValueFilter filterNeedClean = new SingleColumnValueFilter("info".getBytes(), "cityCode".getBytes(), CompareFilter.CompareOp.EQUAL, new BinaryPrefixComparator(Bytes.toBytes("61"))); filterNeedClean.setFilterIfMissing(true); allFilters.addFilter(filterNeedClean); scan.setFilter(allFilters); ResultScanner scaner = table.getScanner(scan); for (Result rs : scaner) { String shopType = Bytes.toString(rs.getValue("info".getBytes(), "shopType".getBytes())); if ("0".equals(shopType) || "1".equals(shopType) || "2".equals(shopType) || "4".equals(shopType) || "5".equals(shopType) || "6".equals(shopType) || "7".equals(shopType)) { String rowkey = Bytes.toString(rs.getRow()); String ocr = Bytes.toString(rs.getValue("info".getBytes(), "ocr".getBytes())); String text = Bytes.toString(rs.getValue("info".getBytes(), "text".getBytes())); text = StringUtils.isEmpty(text) ? "" : text; String filePath = Bytes.toString(rs.getValue("info".getBytes(), "netURL".getBytes())); String temp = Bytes.toString(rs.getValue("info".getBytes(), "temp".getBytes())); if ((StringUtils.isNotEmpty(ocr) && ocr.equals("2")) || (StringUtils.isNotEmpty(ocr) && "1".equals(ocr)) || StringUtils.isEmpty(filePath) || StringUtils.isNotEmpty(text) || "1".equals(temp) || FileUtils.formatUrl(filePath).endsWith(".gif")) { continue; } ContentCommodityDto dto = new ContentCommodityDto(); dto.setFilePath(filePath); dto.setRowkey(rowkey); dto.setOcr(ocr); dataList.add(dto); if (dataList.size() == loadSize) { break; } } } } catch (Exception e) { e.printStackTrace(); } finally { HbaseUtil.closeTable(table); } return dataList; }
故乡明
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
· 25岁的心里话