zoukankan      html  css  js  c++  java
  • 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;
        }
    故乡明
  • 相关阅读:
    【javascript 面试笔试】1、几道笔试题
    【菜鸟学习jquery源码】数据缓存与data()
    【javascript杂谈】你所不知道的replace函数
    001-编译hadoop-2.5.2总结
    静态工厂 + DbHelper
    用Socket来简单实现IIS服务器
    JS产生徐特尔图表
    JS中图片飞飞效果
    基础类型
    Linux-切换启动方式
  • 原文地址:https://www.cnblogs.com/luweiweicode/p/14073609.html
Copyright © 2011-2022 走看看