2016-11-06 53 views
0

我有HBase表,其中包含大约10百万条记录。 我有三个关于HBase的问题如何做HBase部分扫描?

  1. 扫描10百万条记录需要多少时间?
  2. 我应该参加HIVE HBase集成吗?
  3. 如果我在每行中只加入一个标识符FL01,如何执行部分范围扫描?

4294970043 | 1
柱= CF:SegmentMultipleFundbDescription,时间戳= 1478316937790, 值= 4294970043 | 1个
柱= CF:SegmentMultipleFundbDescription_languageId, 时间戳= 1478316937790,值= 505074 4294970043 | 1
柱= CF:StatementTypeCode,时间戳= 1478316937790,值= FTN 4294970929 | 1柱= CF:FFAction, 时间戳= 1478316937790,值= I 4294970929 | 1个
柱= CF:文件名,时间戳= 1478316937 790, 值= Fundamental.FinancialLineItem.FinancialLineItem.ThirdPartyPrivate.FTN.1.2 016-07-15-2108.Full 4294970929 | 1柱= CF:FilePartition, 时间戳= 1478316937790,值= ThirdPartyPrivate 4294970929 | 1
柱=比照:FilePartitionLocation,时间戳= 1478316937790,值= FTN 4294970929 | 1个
柱= CF:FinancialConceptCodeGlobalSecondary, 时间戳= 1478316937790,值= 4294970929 | 1个
柱= CF:FinancialConceptCodeGlobalSecondaryId, 时间戳= 1478316937790,值= 4294970929 | 1
column = cf:FinancialConceptGlobal,timestamp = 1478316937790,value = METL 4294970929 | 1
列= CF:FinancialConceptGlobalId,时间戳= 1478316937790, 值= 3015071

回答

0

HBASE会做一个FTS,除非和直到你提供一个启动和停止行键。因此,如果标识符是行键的一部分,并且行键是固定的,那么您可以尝试设置开始和停止行键,否则尝试使用模糊过滤器。否则,如果标识符不是行键的一部分,HBASE会执行FTS。

多少时间花费在扫描确实取决于多种因素,如行键的大小,多少CF,有多少列预选赛......

0

假设你的钥匙是字符串,该行返回地图列表中,那么你的范围扫描应该看起来像下面的代码。

public List<Map<String,byte[]>> rangeFetch(String valueFrom, String valueTo, String[] columns, int maxrows) { 
    ArrayList<Map<String,byte[]>> rst = new ArrayList<Map<String,byte[]>>(); 
    Scan scn = new Scan(); 
    scn.setStartRow(valueFrom.getBytes()); 
    scn.setStopRow (valueTo.getBytes()); 
    for (String colName : columns) { 
     scn.addColumn(colName.getBytes()); 
    } 
    ResultScanner rsc = null; 
    int rowCount = 0; 
    try { 
     rsc = oTbl.getScanner(scn); 
     for (Result res=rsc.next(); res!=null && rowCount<maxrows; res=rsc.next()) { 
      Map<String,byte[]> row = new HashMap<String,byte[]>(); 
      for (String colName : columns) { 
       KeyValue kvl = res.getColumnLatest("columnFamilyName".getBytes(), colName.getBytes()); 
       if (kvl!=null) { 
        if (kvl.getValue()!=null) 
         row.put(colName, kvl.getValue()); 
       } 
      } // next 
      rst.add(row);    
     } // next 
    } finally { 
     if (rsc!=null) rsc.close(); 
    } 
    return rst; 
} 

然后用

List<Map<String,byte[]>> results = yourObj.rangeFetch("FL01"+"000000", "FL01"+"999999", new String[]{"column1","column2","column3"}, 10000); 
叫它