后端程序员之路 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 ...
随机推荐
- P1387 最大正方形 && P1736 创意吃鱼法(DP)
题目描述 在一个n*m的只包含0和1的矩阵里找出一个不包含0的最大正方形,输出边长. 输入输出格式 输入格式: 输入文件第一行为两个整数n,m(1<=n,m<=100),接下来n行,每行m ...
- 数据可视化 -- Python
前提条件: 熟悉认知新的编程工具(jupyter notebook) 1.安装:采用pip的方式来安装Jupyter.输入安装命令pip install jupyter即可: 2.启动:安装完成后,我 ...
- Gitlab忘记root用户密码解决办法
一.Gitlab忘记root用户密码,重置用户密码和查看用户ID号方法 1.Gitlab查看用户id号的方法1)方法1:通过api接口查询接口查询地址:http://gitlab的url/api/v ...
- Netty(五)Netty 高性能之道
4.背景介绍 4.1.1 Netty 惊人的性能数据 通过使用 Netty(NIO 框架)相比于传统基于 Java 序列化+BIO(同步阻塞 IO)的通信框架,性能提升了 8 倍多.事 实上,我对这个 ...
- HDU 6623 Minimal Power of Prime(思维)题解
题意: 已知任意大于\(1\)的整数\(a = p_1^{q_1}p_2^{q_2} \cdots p_k^{q_k}\),现给出\(a \in [2,1e18]\),求\(min\{q_i\},q ...
- JPG学习笔记3(附完整代码)
#topics h2 { background: rgba(43, 102, 149, 1); border-radius: 6px; box-shadow: 0 0 1px rgba(95, 90, ...
- React Native & Security
React Native & Security https://reactnative.dev/docs/security React Native blogs https://reactna ...
- Caddyfile 是干什么的?
Caddyfile 是干什么的? The Caddyfile is a convenient Caddy configuration format for humans. It is most peo ...
- js navigator.wakeLock 保持屏幕唤醒状态
let lock; btn.addEventListener("click", async () => { try { if (lock) { lock.release(); ...
- c++ DWORD和uintptr_t
x86模式 DWORD 是4字节 x86模式 uintptr_t 是4字节 x64模式 DWORD 是4字节 x64模式 uintptr_t 是8字节 std::cout << sizeo ...