当前位置: 首页>>代码示例>>C++>>正文


C++ IndexReader::front方法代码示例

本文整理汇总了C++中IndexReader::front方法的典型用法代码示例。如果您正苦于以下问题:C++ IndexReader::front方法的具体用法?C++ IndexReader::front怎么用?C++ IndexReader::front使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IndexReader的用法示例。


在下文中一共展示了IndexReader::front方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: MinimumHeap

int
SmallFileIndex::init_data_source(void *init_para,
                                 RecordReader **reader)
{
    int ret = 0;
    vector<plfs_pathback> &droppings = *(((index_init_para_t *)init_para)->namefiles);
    list<index_mapping_t> *fid = ((index_init_para_t *)init_para)->fids;
    MinimumHeap *min_heap = new MinimumHeap(fid->size(), index_compare_func);

    mlog(SMF_DAPI, "Start to build index %p.", this);
    if (fid->size() == 0) {
        *reader = min_heap;
        return 0;
    }
    unsigned int buf_size = get_read_buffer_size(fid->size());
    list<index_mapping_t>::const_iterator itr;
    for (itr = fid->begin(); itr != fid->end(); itr++ ) {
        string index_fname;
        IndexReader *indexfile;
        int pop_result;
        struct plfs_pathback entry;
        entry.back = droppings[itr->second].back;
        assert(itr->second < droppings.size());
        ret = dropping_name2index(droppings[itr->second].bpath, entry.bpath);
        if (ret) {
            mlog(SMF_ERR, "Unable to get index file name from name file:%s.",
                 droppings[itr->second].bpath.c_str());
            break;
        }
        indexfile = new IndexReader(entry, *itr, buf_size);
        /* Only after this pop_front(), we can get the first record. */
        pop_result = indexfile->pop_front();
        if (pop_result == 1 && indexfile->front()) {
            mlog(SMF_DAPI, "Load index entries from %s.", entry.bpath.c_str());
            min_heap->push_back(indexfile);
        } else if (pop_result == 0 || pop_result == -ENOENT) {
            delete indexfile;
            mlog(SMF_DAPI, "Skip empty or non-existent index file:%s.",
                 entry.bpath.c_str());
        } else {
            delete indexfile;
            mlog(SMF_ERR, "Unable to read index entries from %s, err = %d!",
                 entry.bpath.c_str(), pop_result);
            ret = pop_result;
            break;
        }
    }
    if (ret == 0) {
        mlog(SMF_DAPI, "Successfully build index %p.", this);
        *reader = min_heap;
    } else {
        delete min_heap;
        mlog(SMF_DAPI, "Failed to build index %p. errno = %d.", this, ret);
    }
    return ret;
}
开发者ID:ZhangZhenhua,项目名称:plfs-core,代码行数:56,代码来源:SmallFileIndex.cpp


注:本文中的IndexReader::front方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。