Pinot中的Forward Index源码分析

本文通过Quickstart分析Pinot中Forward Index的创建过程,包括收集列统计数据、按行处理索引,以及对每行索引的详细步骤。对于single value field,使用二分查找在dictionary index中定位,存储为int类型,与column类型无关。Forward Index实质上是一个一维数组,存储每个值在dictionary index中的位置,配合dictionary index实现快速查找。

还是以Quickstart为例,说一下forward index的创建过程。

  1. 收集各个column的统计数据

    代码同dictionary index。

  2. 再次遍历,按行处理每列的索引

    iterator复位

    // Build the index
    recordReader.rewind();

    重新遍历,对每行索引

    LOGGER.info("Start building IndexCreator!");
    while (recordReader.hasNext()) {
      long start = System.currentTimeMillis();
      GenericRow row = recordReader.next();
      long stop = System.currentTimeMillis();
      indexCreator.indexRow(row);
      long stop1 = System.currentTimeMillis();
      totalRecordReadTime += (stop - start);
      totalIndexTime += (stop1 - stop);
    }

    indexRow的实现:

    @Override
    public void indexRow(GenericRow row) {
        for (final String column : dictionaryCreatorMap.keySet()) {
    
            Object columnValueToIndex = row.getValue(column);
            Object dictionaryIndex;
            if (dictionaryCache.get(column).containsKey(columnValueToIndex)) {
                dictionaryIndex = dictionaryCache.get(column).get(columnValueToIndex
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值