# 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

后端程序员之路 33、Index搜索引擎实现分析2-对外接口和大体流程的更多相关文章

  1. 后端程序员之路 32、Index搜索引擎实现分析1-类的设计

    # 1.forward_index 正排索引(正向索引)- filter_t- filter_judge # 2.inverted_index 倒排索引(反向索引)- inverted_pre_sco ...

  2. 后端程序员之路 22、RESTful API

    理解RESTful架构 - 阮一峰的网络日志http://www.ruanyifeng.com/blog/2011/09/restful.html RESTful API 设计指南 - 阮一峰的网络日 ...

  3. 后端程序员之路 35、Index搜索引擎实现分析4-最终的正排索引与倒排索引

    # index_box 提供搜索功能的实现- 持有std::vector<ITEM> _buffer; 存储所有文章信息- 持有ForwardIndex _forward_index;  ...

  4. 后端程序员之路 34、Index搜索引擎实现分析3-对文章索引的两层分块

    # part_indexer 对文章根据id的hash进行分块索引- 持有 search_index _inc_index[2]; search_index _history_index[2]; 进行 ...

  5. 后端程序员之路 43、Redis list

    Redis数据类型之LIST类型 - Web程序猿 - 博客频道 - CSDN.NEThttp://blog.csdn.net/thinkercode/article/details/46565051 ...

  6. 后端程序员之路 59、go uiprogress

    gosuri/uiprogress: A go library to render progress bars in terminal applicationshttps://github.com/g ...

  7. 后端程序员之路 31、Protocol Buffer

    google/protobuf: Protocol Buffers - Google's data interchange formathttps://github.com/google/protob ...

  8. 后端程序员之路 16、信息熵 、决策树、ID3

    信息论的熵 - guisu,程序人生. 逆水行舟,不进则退. - 博客频道 - CSDN.NEThttp://blog.csdn.net/hguisu/article/details/27305435 ...

  9. 后端程序员之路 13、使用KNN进行数字识别

    尝试一些用KNN来做数字识别,测试数据来自:MNIST handwritten digit database, Yann LeCun, Corinna Cortes and Chris Burgesh ...

随机推荐

  1. [WPF 学习] 18. 摄像头(肢解DirectShow)

    公司的产品需要人脸比对,摄像头相关的需求如下(突然发现除了英文不太好外,实际上中文也不太好,所以直接上一个接口) using System; using System.Drawing; using S ...

  2. LaTeX 环境安装&编译器配置

    推荐网站:https://www.latexstudio.net/articles/ (基本所有的latex疑惑都可以在这里得到解决) 入门视频:两小时短小精悍,让你轻松入门,https://www. ...

  3. hdu 6704 K-th occurrence(后缀数组+可持久化线段树)

    Problem Description You are given a string S consisting of only lowercase english letters and some q ...

  4. 【hdu 4859】海岸线(图论--网络流最小割)

    题意:有一个区域,有'.'的陆地,'D'的深海域,'E'的浅海域.其中浅海域可以填充为陆地.这里的陆地区域不联通,并且整个地图都处在海洋之中.问填充一定浅海域之后所有岛屿的最长的海岸线之和. 解法:最 ...

  5. docker-理论题01

    1.什么是docker?答:docker是开源的应用容器引擎:开发人员把他们的应用及依赖包打包发布到容器当中. 2.docker和VMware的区别? 答:docker是半解耦,VMware是解耦:d ...

  6. leetcode17 电话号码的字母组合 dfs

    就dfs吧.... 然后,我傻了.前一道题不用考虑空,这道题就要考虑.... 还有注意vector要引用传递 class Solution { public: void dfs(string temp ...

  7. Leetcode(82)-删除排序链表中的重复元素 II

    给定一个排序链表,删除所有含有重复数字的节点,只保留原始链表中 没有重复出现 的数字. 示例 1: 输入: 1->2->3->3->4->4->5 输出: 1-&g ...

  8. P4213 【模板】杜教筛(杜教筛)题解

    题意: 求\(\sum_{i=1}^n\varphi(i)\)和\(\sum_{i=1}^n\mu(i)\) 思路: 由性质可知:\(\mu*I=\epsilon,\varphi*I=id\)那么可得 ...

  9. SQL优化这么做就对了

    目录 前言 SQL优化一般步骤 1.通过慢查日志等定位那些执行效率较低的SQL语句 2.explain 分析SQL的执行计划 3.show profile 分析 4.trace 5.确定问题并采用相应 ...

  10. Linux bash shell All In One

    Linux bash shell All In One Linux https://tinylab.gitbooks.io/shellbook/content/zh/chapters/01-chapt ...