后端程序员之路 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 ...
随机推荐
- JVM之堆体系结构
1.Heap堆(Java7之前) 一个JVM实例只存在一个堆内存,堆内存的大小是可以调节的.类加载器读取了类文件后,需要把类.方法.常变量放到堆内存中,保存所有引用类型的真实信息,以方便执行器执行,堆 ...
- 手把手教你从Git上导入项目
Git上导入项目 进入Gitlab账户中的项目,点击Clone按钮,复制HTTPS路径.如果配置了SSH,则可以通过SSH导入项目. 在IDEA中,点击VCS-Checkout from Versio ...
- jmespath(1)基础语法
前言 JMESPath是JSON的查询语言.您可以从JSON文档中提取和转换元素 官方文档:https://jmespath.org/tutorial.html 基本表达式 JMESPath用的最多的 ...
- Codeforces Round #656 (Div. 3) B. Restore the Permutation by Merger
题目链接:https://codeforces.com/contest/1385/problem/B 题意 有两个大小为 $n$ 的相同的排列,每次从二者或二者之一的首部取元素排入新的数组,给出这个大 ...
- zoj3299 Fall the Brick
Time Limit: 3 Seconds Memory Limit: 32768 KB Now the God is very angry, so he wants to punish t ...
- PowerShell随笔1---背景
既然是随笔,那就想到什么说什么,既会分享主题知识,也会分享一些其他技巧和个人学习方法,供交流. 我一般学习一个东西,我都会问几个问题: 这东西是什么? 这东西有什么用,为什么会出现,出现是为了解决什么 ...
- css整理之-----------选择器
背景 在20年初时总感觉自己的css 不够用,想把css 相关的东西整理下,去年一整年都比较忙,忙着就到2021了,今天趁着有点时间,先从选择器开始吧. 听说图片可以提升颜值.... 选择器 CSS选 ...
- Pyqt5使用
一.帮助文档 二.PyQt5库结构 三. 面向对象的编程模式 class Windows(QWidget): def __init__(self): #继承父类的QWidget的方法 super(). ...
- Nginx基础 - 常用模块配置
1.Nginx状态监控http_stub_status_module记录Nginx客户端基本访问状态信息 location /mystatus { stub_status on; access_log ...
- Zabbix 监控 SNMP & JMX
Zabbix 配置清华源 # 安装清华源 yum 仓库 [root@db01 ~]# rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabb ...