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

  • 相关阅读:
    C# winfrom容器布局与工具栏&&右键菜单栏&&隐藏显示小图标的的简单事件
    C# Winform ListView控件
    MongoDB3.6.3 windows安装配置、启动
    史蒂夫•乔布斯在斯坦福大学的演讲
    SpringBoot配置文件 application.properties详解
    Elasticsearch分布式安装启动失败
    Couldn't connect to host, port: smtp.163.com, 25; timeout -1;
    CentOS 7 安装jdk9
    生成唯一的随机数(时间+随机数)
    idea 设置背景图片
  • 原文地址:https://www.cnblogs.com/zapline/p/6692641.html
Copyright © 2011-2022 走看看