zoukankan      html  css  js  c++  java
  • 后端程序员之路 33、Index搜索引擎实现分析2-对外接口和大体流程

    # index_manager的单例是index server对外的唯一接口,part_indexer是index搜索的核心部分,index_manager持有了一组part_indexer。

    typedef std::vector<std::shared_ptr<part_indexer>> part_indexers;
    part_indexers _part_indexers;

    index_manager.init
    - 对incremental和history两种索引从文件或内存进行初始化,过滤超时的文章
    - 一条线程 inc_rebuild_thread_handler(含build_inc_index)
    - 一条线程 history_rebuild_thread_handler
    - n条线程 part_indexer_func

    index_manager.get_size,累加_part_indexers的get_size
    index_manager.get_item,_part_indexers[doc_id%_index_part_num].get_item

    index_manager.trigger
    - 填充search_params,调用main_trigger
    - main_trigger里构造partition_task_t,丢到_query_tasks_queue处理
    - 等结果

    part_indexer_func
    - 从_query_tasks_queue获取partition_task_t,执行查询任务
    - _part_indexers[task.index_part_id]->search() (task.index_part_id是main_trigger里写的随机值)

    # inc_reader,用于向index server添加新数据
    - util::BlockingQueue<ITEM>* _buffer,_file_buffer; gmp_cache_t _gmp_cache;
    - dump_data
        - detach a thread to dump data
        - pthread_create dump_thread_handler
    - inc_data
        - _file_buffer->push( item );
        - if (item.build_inc()) _buffer->push( item );
    - inc_gmp
        _gmp_cache.insert
    - get_datas
        - take data from _buffer
    - get_gmp_cache
        - _gmp_cache.swap(gmp_cache)
        - used by history_rebuild_thread_handler
    - copy_gmp_cache
        - gmp_cache.insert(_gmp_cache.begin(), _gmp_cache.end());
        - used by inc_rebuild_thread_handler
    - dump_thread_handler
        - take item from _file_buffer
        - items.SerializeToString save to file

  • 相关阅读:
    VUE 引入element ui 样式不生效解决
    Spark项目故障思路整理总结
    Spark-环境安装
    01.Kettle的安装-千亿级数仓环境搭建
    千亿级数仓day01-项目的简介
    Umeng项目day04
    Umengday12-统计指标
    Umengday11-azkaban调度
    Umengday09-hive自定义UDTF函数叉分函数
    Docker配置jdk1.8
  • 原文地址:https://www.cnblogs.com/zapline/p/6692641.html
Copyright © 2011-2022 走看看