后端程序员之路 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 ...
随机推荐
- OsgEarth开发笔记(三):Osg3.6.3+OsgEarth3.1+vs2019x64开发环境搭建(下)
前言 上一篇编译了proj6.2.0.gdal3.2.1,本篇继续. OsgEarth编译过程简介 OsgEarth的编译,是基于Osg和OsgEarth结合在一起的,先要编译Osg,然后 ...
- std::thread线程库详解(4)
目录 目录 前言 条件变量 一些需要注意的地方 总结 前言 本文主要介绍了多线程中的条件变量,条件变量在多线程同步中用的也比较多.我第一次接触到条件变量的时候是在完成一个多线程队列的时候.条件变量用在 ...
- 2019牛客暑期多校训练营(第二场)A Eddy Walker(打表求概率)
题意:给你n,m分别表示 长度为n的环 和最后走到的位置m 问从0点出发每次都能能往前或者往后走 求最后在m点的概率思路:我们可以先打表模拟一下 发现好像每个点的概率大概都是1/(n-1) 打表代码: ...
- POJ1113:Wall (凸包算法学习)
题意: 给你一个由n个点构成的多边形城堡(看成二维),按顺序给你n个点,相邻两个点相连. 让你围着这个多边形城堡建一个围墙,城堡任意一点到围墙的距离要求大于等于L,让你求这个围墙的最小周长(看成二维平 ...
- Educational Codeforces Round 94 (Rated for Div. 2) B. RPG Protagonist (数学)
题意:你和你的随从去偷剑和战斧,你可以最多可以拿\(p\)重的东西,随从可以拿\(f\)重的东西,总共有\(cnt_{s}\)把剑,\(cnt_{w}\)把战斧,每把剑重\(s\),战斧重\(w\), ...
- Codeforces Global Round 8 D. AND, OR and square sum (贪心,位运算)
题意:有\(n\)个数,选择某一对数使二者分别\(or\)和\(and\)得到两个新值,求操作后所有数平方和的最大值. 题解:不难发现每次操作后,两个数的二进制表示下的\(1\)的个数总是不变的,所以 ...
- 力扣992.K个不同整数的子数组-C语言实现
题目 原题链接 给定一个正整数数组 A,如果 A 的某个子数组中不同整数的个数恰好为 K,则称 A 的这个连续.不一定独立的子数组为好子数组. (例如,[1,2,3,1,2] 中有 3 个不同的整数: ...
- CentOS 7 架设LNMP动态网站
1.安装Nginx 1)使用Nginx官方的yum源 [root@localhost ~]# vim /etc/yum.repos.d/nginx.repo [nginx] name=nginx re ...
- haproxy 2.2代理后端https服务
globalmaxconn 100000chroot /usr/local/haproxystats socket /var/lib/haproxy/haproxy.sock mode 600 lev ...
- H.264视频压缩标准
H.264 这部分一直在讲,但是却没有系统的来说.接下来要详细. 参看:H.264视频压缩标准 一.简介 H.264是最新的视频压缩标准,它也称为MPEG-4 Part 10或AVC(高级视频编码). ...