后端程序员之路 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
后端程序员之路 33、Index搜索引擎实现分析2-对外接口和大体流程的更多相关文章
- 后端程序员之路 32、Index搜索引擎实现分析1-类的设计
# 1.forward_index 正排索引(正向索引)- filter_t- filter_judge # 2.inverted_index 倒排索引(反向索引)- inverted_pre_sco ...
- 后端程序员之路 22、RESTful API
理解RESTful架构 - 阮一峰的网络日志http://www.ruanyifeng.com/blog/2011/09/restful.html RESTful API 设计指南 - 阮一峰的网络日 ...
- 后端程序员之路 35、Index搜索引擎实现分析4-最终的正排索引与倒排索引
# index_box 提供搜索功能的实现- 持有std::vector<ITEM> _buffer; 存储所有文章信息- 持有ForwardIndex _forward_index; ...
- 后端程序员之路 34、Index搜索引擎实现分析3-对文章索引的两层分块
# part_indexer 对文章根据id的hash进行分块索引- 持有 search_index _inc_index[2]; search_index _history_index[2]; 进行 ...
- 后端程序员之路 43、Redis list
Redis数据类型之LIST类型 - Web程序猿 - 博客频道 - CSDN.NEThttp://blog.csdn.net/thinkercode/article/details/46565051 ...
- 后端程序员之路 59、go uiprogress
gosuri/uiprogress: A go library to render progress bars in terminal applicationshttps://github.com/g ...
- 后端程序员之路 31、Protocol Buffer
google/protobuf: Protocol Buffers - Google's data interchange formathttps://github.com/google/protob ...
- 后端程序员之路 16、信息熵 、决策树、ID3
信息论的熵 - guisu,程序人生. 逆水行舟,不进则退. - 博客频道 - CSDN.NEThttp://blog.csdn.net/hguisu/article/details/27305435 ...
- 后端程序员之路 13、使用KNN进行数字识别
尝试一些用KNN来做数字识别,测试数据来自:MNIST handwritten digit database, Yann LeCun, Corinna Cortes and Chris Burgesh ...
随机推荐
- linux中在某个目录下多个文件中搜索关键字
有四种方法: find 文件目录 -name '*.*' -exec grep 'xxx' {} + -n 或是 find 文件目录 -name '*.*' | xargs grep 'xxx' -n ...
- hdu5402 Travelling Salesman Problem
Problem Description Teacher Mai is in a maze with n rows and m columns. There is a non-negative numb ...
- 流程的python PDF高清版
免费下载链接:https://pan.baidu.com/s/1qcPjLlFXhVXosIGBKHVVXQ 提取码:qfiz
- Python3.7.9+Locust1.4.3版本性能测试工具案例分享
一.Locust工具介绍 1.概述 Locust是一款易于使用的分布式负载测试工具,完全基于事件,使用python开发,即一个locust节点也可以在一个进程中支持数千并发用户,不使用回调,通过gev ...
- 在kubernetes集群里集成Apollo配置中心(5)之dubbo服务消费者连接apollo实战
1.在Apollo的portal创建dubbo消费者项目 (1)添加dubbo消费者项目 (2)在dubbo消费者项目中添加配置项 (3)发布 2.通过jenkins构建dubbo消费者镜像 3.登录 ...
- HDU 4675 GCD of Sequence(莫比乌斯反演 + 打表注意事项)题解
题意: 给出\(M\)和\(a数组\),询问每一个\(d\in[1,M]\),有多少组数组满足:正好修改\(k\)个\(a\)数组里的数使得和原来不同,并且要\(\leq M\),并且\(gcd(a_ ...
- postman skills
postman skills variables https://learning.postman.com/docs/sending-requests/variables/ https://learn ...
- 如何给 GitHub 添加 SSH key, 如何生成 SSH key 详细图文教程!
如何给 GitHub 添加 SSH key, 如何生成 SSH key 详细图文教程! 一. 生成 SSH key https://ide.c9.io/xgqfrms/ 创建一个空项目:(或使用 ...
- 使用 js 实现一个简易版的 GIPHY 动图搜索 web 应用程序
使用 js 实现一个简易版的 GIPHY 动图搜索 web 应用程序 具有挑战性的前端面试题 API JAMstack refs https://www.infoq.cn/article/0NUjpx ...
- Git Best Practice All In One
Git Best Practice All In One git workflow 本地开发环境: 开发人员自测的,可以是自己本地部署的静态服务器,当然也可类似是运行 npm server类似的环境, ...