【C++项目】boost搜索引擎

文章目录

  • 一、项目的相关背景
    • 1.1 boost基本介绍
    • 1.2 为什么要自主实现boost搜索引擎
  • 二、搜索引擎的相关宏观原理和项目演示
    • 2.1 项目演示:
  • 三、搜索引擎技术栈和项目环境
  • 四、正排索引 vs 倒排索引 - 搜索引擎具体原理
  • 五、编写数据去标签与数据清洗的模块 Parser
  • 六、编写建立索引的模块 Index
  • 七、编写搜索引擎模块 Searcher
  • 八、编写http_server 模块
  • 九、编写前端模块
  • 十、添加日志
    • 10.1 部署服务到 linux 上
  • 十一、结项总结


一、项目的相关背景

1.1 boost基本介绍

boost官网

Boost库是为C++语言标准库提供扩展的一些C++程序库的总称。

  • Boost库由Boost社区组织开发、维护。其目的是为C++程序员提供免费、同行审查的、可移植的程序库。Boost库可以与C++标准库完美共同工作,并且为其提供扩展功能。Boost库使用Boost License来授权使用,根据该协议,商业的非商业的使用都是允许并鼓励的。
  • Boost社区建立的初衷之一就是为C++的标准化工作提供可供参考的实现,Boost社区的发起人Dawes本人就是C++标准委员会的成员之一。在Boost库的开发中,Boost社区也在这个方向上取得了丰硕的成果。在送审的C++标准库TR1中,有十个Boost库成为标准库的候选方案。在更新的TR2中,有更多的Boost库被加入到其中。从某种意义上来讲,Boost库成为具有实践意义的准标准库。
  • 大部分boost库功能的使用只需包括相应头文件即可,少数(如正则表达式库,文件系统库等)需要链接库。里面有许多具有工业强度的库,如graph库。
  • 很多Boost中的库功能堪称对语言功能的扩展,其构造用尽精巧的手法,不要贸然的花费时间研读。Boost另外一面,比如Graph这样的库则是具有工业强度,结构良好,非常值得研读的精品代码,并且也可以放心的在产品代码中多多利用

1.2 为什么要自主实现boost搜索引擎

  • 百度、搜狗、360搜索、头条新闻客户端 - 我们自己实现是不可能的!(全网搜索)
    【C++项目】boost搜索引擎_第1张图片
    【C++项目】boost搜索引擎_第2张图片
    【C++项目】boost搜索引擎_第3张图片

  • boost的官网是没有站内搜索的,需要我们自己做一个
    【C++项目】boost搜索引擎_第4张图片
    站内搜索:搜索的数据更垂直,数据量其实更小

二、搜索引擎的相关宏观原理和项目演示

【C++项目】boost搜索引擎_第5张图片
用户输入:关键字 -> 倒排索引中查找 -> 提取出文档ID -> 根据正排索引 -> 找到文档的内容 ->title+conent(desc)+url 文档结果进行摘要->构建响应结果

2.1 项目演示:

三、搜索引擎技术栈和项目环境

  • 技术栈: C/C++ C++11, STL, 准标准库Boost,Jsoncpp,cppjieba,cpp-httplib , 选学: html5,css,js、jQuery、Ajax
  • 项目环境: Centos 7云服务器,vim/gcc(g++)/Makefile , vs2019 or vs code

四、正排索引 vs 倒排索引 - 搜索引擎具体原理

  • 文档1: 雷军买了四斤小米
  • 文档2: 雷军发布了小米手机

正排索引:就是从文档ID找到文档内容(文档内的关键字)

文档ID 文档内容
1 雷军买了四斤小米
2 雷军发布了小米手机

目标文档进行分词(目的:方便建立倒排索引和查找):

  • 文档1[雷军买了四斤小米 ]: 雷军/买/四斤/小米/四斤小米
  • 文档2[雷军发布了小米手机]:雷军/发布/小米/小米手机

停止词:了,的,吗,a,the,一般我们在分词的时候可以不考虑

关键字(具有唯一性) 文档ID
雷军 文档1,文档2
文档1
四斤 文档1
小米 文档1,文档2
四斤小米 文档1
发布 文档2
小米手机 文档2

模拟一次查找的过程:
用户输入:小米 -> 倒排索引中查找 -> 提取出文档ID(1,2) -> 根据正排索引 -> 找到文档的内容 ->
title+conent(desc)+url 文档结果进行摘要->构建响应结果

五、编写数据去标签与数据清洗的模块 Parser

目前只需要boost_1_79_0/doc/html目录下的html文件,用它来进行建立索引

【C++项目】boost搜索引擎_第6张图片
【C++项目】boost搜索引擎_第7张图片
【C++项目】boost搜索引擎_第8张图片

#include 
#include 
#include 
#include 
#include "Util.hpp"

const std::string src_path = "data/input";
const std::string output = "data/raw_html/raw.txt";

typedef struct DocInfo
{
public:
    std::string title;   // 文档标题
    std::string content; // 文档内容
    std::string url;     // 网址
} DocInfo_t;

// const & 输入
// * 输出
// & 输入输出
bool EnumFile(const std::string &src_path, std::vector<std::string> *file_list);

bool ParseHtml(const std::vector<std::string> &files_list, std::vector<DocInfo_t> *results);

bool SaveHtml(const std::vector<DocInfo_t> &results, const std::string &output);

int main()
{
    std::vector<std::string> files_list;
    // 第一步,递归式将每个HTML文件名带路径,保存在files_list当中;方便后期一个一个读取
    if (!EnumFile(src_path, &files_list))
    {
        std::cerr << "EnumFile error" << std::endl;
        return 1;
    }
    // 第二步,按照file_list读取每一个文件中的内容,并进行解析
    std::vector<DocInfo_t> results;
    if (!ParseHtml(files_list, &results))
    {
        std::cerr << "ParseHtml error" << std::endl;
        return 2;
    }
    // 第三步,把解析完成的各个文件内容,写入到output里面,按照\n作为每个文档的分隔符 \3作为分割doc里面的各个数据
    if (!SaveHtml(results, output))
    {
        std::cerr << "SaveHtml error" << std::endl;
        return 3;
    }
    return 0;
}

bool EnumFile(const std::string &src_path, std::vector<std::string> *files_list)
{
    namespace fs = boost::filesystem;
    fs::path root_path(src_path);
    // 判断当前路径是否存在
    if (!fs::exists(root_path))
    {
        std::cerr << src_path << " not exists" << std::endl;
        return false;
    }
    // 定义一个迭代器,来判断递归结束
    fs::recursive_directory_iterator end;
    for (fs::recursive_directory_iterator iter(root_path); iter != end; ++iter)
    {
        // 判断是否是普通文件,HTML是普通文件
        if (!fs::is_regular_file(*iter))
        {
            continue;
        }
        // 判断后缀是否是html
        if (iter->path().extension() != ".html")
        {
            continue;
        }
        // std::cout << "debug:" << iter->path().string() << std::endl;
        //  当前路径一定是合法的,一html为后缀的普通文件
        //将当前路径后缀为HTML的文件名保存在files_list,方便进行文本分析
        files_list->push_back(std::move(iter->path().string())); // move 减少拷贝
    }
    return true;
}

static bool ParseTitle(const std::string &file, std::string *title)
{
    size_t begin = file.find(""</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>begin <span class="token operator">==</span> std<span class="token double-colon punctuation">::</span>string<span class="token double-colon punctuation">::</span>npos<span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    size_t end <span class="token operator">=</span> file<span class="token punctuation">.</span><span class="token function">find</span><span class="token punctuation">(</span><span class="token string">"");
    if (end == std::string::npos)
    {
        return false;
    }

    begin += std::string(""</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// begin指向正文</span>
    <span class="token operator">*</span>title <span class="token operator">=</span> file<span class="token punctuation">.</span><span class="token function">substr</span><span class="token punctuation">(</span>begin<span class="token punctuation">,</span> end <span class="token operator">-</span> begin<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">static</span> <span class="token keyword">bool</span> <span class="token function">ParseContent</span><span class="token punctuation">(</span><span class="token keyword">const</span> std<span class="token double-colon punctuation">::</span>string <span class="token operator">&</span>file<span class="token punctuation">,</span> std<span class="token double-colon punctuation">::</span>string <span class="token operator">*</span>content<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    <span class="token comment">// 去标签,编写一个简单的状态机</span>
    <span class="token keyword">enum</span> <span class="token class-name">status</span>
    <span class="token punctuation">{</span>
        LABLE<span class="token punctuation">,</span>
        CONTENT
    <span class="token punctuation">}</span><span class="token punctuation">;</span>

    <span class="token keyword">enum</span> <span class="token class-name">status</span> s <span class="token operator">=</span> LABLE<span class="token punctuation">;</span>
    <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">char</span> ch <span class="token operator">:</span> file<span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token keyword">switch</span> <span class="token punctuation">(</span>s<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
        <span class="token keyword">case</span> LABLE<span class="token operator">:</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>ch <span class="token operator">==</span> <span class="token char">'>'</span><span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                s <span class="token operator">=</span> CONTENT<span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            <span class="token keyword">break</span><span class="token punctuation">;</span>
        <span class="token keyword">case</span> CONTENT<span class="token operator">:</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>ch <span class="token operator">==</span> <span class="token char">'<'</span><span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                s <span class="token operator">=</span> LABLE<span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            <span class="token keyword">else</span>
            <span class="token punctuation">{</span>
                <span class="token keyword">if</span> <span class="token punctuation">(</span>ch <span class="token operator">==</span> <span class="token char">'\n'</span><span class="token punctuation">)</span>
                <span class="token punctuation">{</span>
                    ch <span class="token operator">=</span> <span class="token char">' '</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
                <span class="token operator">*</span>content <span class="token operator">+=</span> ch<span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            <span class="token keyword">break</span><span class="token punctuation">;</span>
        <span class="token keyword">default</span><span class="token operator">:</span>
            <span class="token keyword">break</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">return</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">static</span> <span class="token keyword">bool</span> <span class="token function">ParseUrl</span><span class="token punctuation">(</span><span class="token keyword">const</span> std<span class="token double-colon punctuation">::</span>string <span class="token operator">&</span>file_path<span class="token punctuation">,</span> std<span class="token double-colon punctuation">::</span>string <span class="token operator">*</span>url<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    std<span class="token double-colon punctuation">::</span>string url_head <span class="token operator">=</span> <span class="token string">"https://www.boost.org/doc/libs/1_79_0/doc/html"</span><span class="token punctuation">;</span>
    std<span class="token double-colon punctuation">::</span>string url_tail <span class="token operator">=</span> file_path<span class="token punctuation">.</span><span class="token function">substr</span><span class="token punctuation">(</span>src_path<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token operator">*</span>url <span class="token operator">=</span> url_head <span class="token operator">+</span> url_tail<span class="token punctuation">;</span>
    <span class="token keyword">return</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token comment">// for debug</span>
<span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">ShowDoc</span><span class="token punctuation">(</span>DocInfo_t <span class="token operator">&</span>doc<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    std<span class="token double-colon punctuation">::</span>cout <span class="token operator"><<</span> doc<span class="token punctuation">.</span>title <span class="token operator"><<</span> std<span class="token double-colon punctuation">::</span>endl<span class="token punctuation">;</span>
    std<span class="token double-colon punctuation">::</span>cout <span class="token operator"><<</span> doc<span class="token punctuation">.</span>content <span class="token operator"><<</span> std<span class="token double-colon punctuation">::</span>endl<span class="token punctuation">;</span>
    std<span class="token double-colon punctuation">::</span>cout <span class="token operator"><<</span> doc<span class="token punctuation">.</span>url <span class="token operator"><<</span> std<span class="token double-colon punctuation">::</span>endl<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">bool</span> <span class="token function">ParseHtml</span><span class="token punctuation">(</span><span class="token keyword">const</span> std<span class="token double-colon punctuation">::</span>vector<span class="token operator"><</span>std<span class="token double-colon punctuation">::</span>string<span class="token operator">></span> <span class="token operator">&</span>files_list<span class="token punctuation">,</span> std<span class="token double-colon punctuation">::</span>vector<span class="token operator"><</span>DocInfo_t<span class="token operator">></span> <span class="token operator">*</span>results<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">const</span> std<span class="token double-colon punctuation">::</span>string <span class="token operator">&</span>file <span class="token operator">:</span> files_list<span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token comment">// 1,读取文件内容</span>
        std<span class="token double-colon punctuation">::</span>string result<span class="token punctuation">;</span> <span class="token comment">// 文件内容</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>ns_util<span class="token double-colon punctuation">::</span><span class="token class-name">FileUtil</span><span class="token double-colon punctuation">::</span><span class="token function">ReadFile</span><span class="token punctuation">(</span>file<span class="token punctuation">,</span> <span class="token operator">&</span>result<span class="token punctuation">)</span><span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            <span class="token keyword">continue</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        DocInfo_t doc<span class="token punctuation">;</span>
        <span class="token comment">// 2.解析指定文件的title</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span><span class="token function">ParseTitle</span><span class="token punctuation">(</span>result<span class="token punctuation">,</span> <span class="token operator">&</span>doc<span class="token punctuation">.</span>title<span class="token punctuation">)</span><span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            <span class="token keyword">continue</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token comment">// 解析指定文件的content</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span><span class="token function">ParseContent</span><span class="token punctuation">(</span>result<span class="token punctuation">,</span> <span class="token operator">&</span>doc<span class="token punctuation">.</span>content<span class="token punctuation">)</span><span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            <span class="token keyword">continue</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token comment">// 解析指定文件的url</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span><span class="token function">ParseUrl</span><span class="token punctuation">(</span>file<span class="token punctuation">,</span> <span class="token operator">&</span>doc<span class="token punctuation">.</span>url<span class="token punctuation">)</span><span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            <span class="token keyword">continue</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token comment">// debug doc</span>
        <span class="token comment">// ShowDoc(doc);</span>
        <span class="token comment">// break;</span>
        <span class="token comment">// 提取完毕,当前文件的相关结果都保存在了doc里面</span>
        results<span class="token operator">-></span><span class="token function">push_back</span><span class="token punctuation">(</span>doc<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 细节,会发生拷贝</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">return</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">bool</span> <span class="token function">SaveHtml</span><span class="token punctuation">(</span><span class="token keyword">const</span> std<span class="token double-colon punctuation">::</span>vector<span class="token operator"><</span>DocInfo_t<span class="token operator">></span> <span class="token operator">&</span>results<span class="token punctuation">,</span> <span class="token keyword">const</span> std<span class="token double-colon punctuation">::</span>string <span class="token operator">&</span>output<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">define</span> <span class="token macro-name">SEP</span> <span class="token char">'\3'</span></span>
    std<span class="token double-colon punctuation">::</span>ofstream <span class="token function">out</span><span class="token punctuation">(</span>output<span class="token punctuation">,</span> std<span class="token double-colon punctuation">::</span>ios<span class="token double-colon punctuation">::</span>out <span class="token operator">|</span> std<span class="token double-colon punctuation">::</span>ios<span class="token double-colon punctuation">::</span>binary<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>out<span class="token punctuation">.</span><span class="token function">is_open</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        std<span class="token double-colon punctuation">::</span>cerr <span class="token operator"><<</span> <span class="token string">"open "</span> <span class="token operator"><<</span> output <span class="token operator"><<</span> <span class="token string">" failed"</span> <span class="token operator"><<</span> std<span class="token double-colon punctuation">::</span>endl<span class="token punctuation">;</span>
        <span class="token keyword">return</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token comment">// 把解析完成的各个文件内容,写入到output里面,按照\n作为每个文档的分隔符 \3作为分割doc里面的各个数据</span>
    <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">auto</span> <span class="token operator">&</span>it <span class="token operator">:</span> results<span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        std<span class="token double-colon punctuation">::</span>string out_string<span class="token punctuation">;</span>
        out_string <span class="token operator">+=</span> it<span class="token punctuation">.</span>title<span class="token punctuation">;</span>
        out_string <span class="token operator">+=</span> SEP<span class="token punctuation">;</span>
        out_string <span class="token operator">+=</span> it<span class="token punctuation">.</span>content<span class="token punctuation">;</span>
        out_string <span class="token operator">+=</span> SEP<span class="token punctuation">;</span>
        out_string <span class="token operator">+=</span> it<span class="token punctuation">.</span>url<span class="token punctuation">;</span>
        out_string <span class="token operator">+=</span> <span class="token char">'\n'</span><span class="token punctuation">;</span>
        out<span class="token punctuation">.</span><span class="token function">write</span><span class="token punctuation">(</span>out_string<span class="token punctuation">.</span><span class="token function">c_str</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> out_string<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    out<span class="token punctuation">.</span><span class="token function">close</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

</code></pre> 
  <h1>六、编写建立索引的模块 Index</h1> 
  <pre><code class="prism language-cpp"><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">pragma</span> <span class="token expression">once</span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string"><iostream></span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string"><string></span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string"><vector></span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string"><unordered_map></span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string"><fstream></span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">"Util.hpp"</span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string"><mutex></span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">"Log.hpp"</span></span>

<span class="token keyword">namespace</span> ns_index
<span class="token punctuation">{</span>
    <span class="token comment">//</span>
    <span class="token keyword">struct</span> <span class="token class-name">DocInfo</span>
    <span class="token punctuation">{</span>
        std<span class="token double-colon punctuation">::</span>string _title<span class="token punctuation">;</span>   <span class="token comment">// 文档标题</span>
        std<span class="token double-colon punctuation">::</span>string _content<span class="token punctuation">;</span> <span class="token comment">// 文档内容</span>
        std<span class="token double-colon punctuation">::</span>string _url<span class="token punctuation">;</span>     <span class="token comment">// 文档url</span>
        <span class="token keyword">uint64_t</span> _doc_id<span class="token punctuation">;</span>     <span class="token comment">// 文档id,方便构建倒排拉链</span>
    <span class="token punctuation">}</span><span class="token punctuation">;</span>

    <span class="token comment">//倒排拉链</span>
    <span class="token keyword">struct</span> <span class="token class-name">InvertedElem</span>
    <span class="token punctuation">{</span>
        <span class="token keyword">uint64_t</span> _doc_id<span class="token punctuation">;</span>
        std<span class="token double-colon punctuation">::</span>string _word<span class="token punctuation">;</span>
        <span class="token keyword">int</span> _weight<span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">;</span>
    <span class="token keyword">typedef</span> std<span class="token double-colon punctuation">::</span>vector<span class="token operator"><</span>InvertedElem<span class="token operator">></span> InvertedList<span class="token punctuation">;</span>

    <span class="token keyword">class</span> <span class="token class-name">Index</span>
    <span class="token punctuation">{</span>
    <span class="token keyword">private</span><span class="token operator">:</span>
        <span class="token function">Index</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
        <span class="token punctuation">}</span>
        <span class="token function">Index</span><span class="token punctuation">(</span><span class="token keyword">const</span> Index <span class="token operator">&</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token keyword">delete</span><span class="token punctuation">;</span>
        Index <span class="token operator">&</span><span class="token keyword">operator</span><span class="token operator">=</span><span class="token punctuation">(</span><span class="token keyword">const</span> Index <span class="token operator">&</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token keyword">delete</span><span class="token punctuation">;</span>

    <span class="token keyword">public</span><span class="token operator">:</span>
        <span class="token keyword">static</span> Index <span class="token operator">*</span><span class="token function">GetInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>_instance <span class="token operator">==</span> <span class="token keyword">nullptr</span><span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                std<span class="token double-colon punctuation">::</span>unique_lock<span class="token operator"><</span>std<span class="token double-colon punctuation">::</span>mutex<span class="token operator">></span> <span class="token function">ulck</span><span class="token punctuation">(</span>_mtx<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token keyword">if</span> <span class="token punctuation">(</span>_instance <span class="token operator">==</span> <span class="token keyword">nullptr</span><span class="token punctuation">)</span>
                <span class="token punctuation">{</span>
                    _instance <span class="token operator">=</span> <span class="token keyword">new</span> Index<span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
            <span class="token punctuation">}</span>
            <span class="token keyword">return</span> _instance<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        <span class="token operator">~</span><span class="token function">Index</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
        <span class="token punctuation">}</span>

    <span class="token keyword">public</span><span class="token operator">:</span>
        DocInfo <span class="token operator">*</span><span class="token function">GetForwardIndex</span><span class="token punctuation">(</span><span class="token keyword">uint64_t</span> doc_id<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>doc_id <span class="token operator">>=</span> _forward_index<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                std<span class="token double-colon punctuation">::</span>cerr <span class="token operator"><<</span> <span class="token string">"doc_id out of range"</span> <span class="token operator"><<</span> std<span class="token double-colon punctuation">::</span>endl<span class="token punctuation">;</span>
                <span class="token keyword">return</span> <span class="token keyword">nullptr</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            <span class="token keyword">return</span> <span class="token operator">&</span>_forward_index<span class="token punctuation">[</span>doc_id<span class="token punctuation">]</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        InvertedList <span class="token operator">*</span><span class="token function">GetInvertedIndex</span><span class="token punctuation">(</span><span class="token keyword">const</span> std<span class="token double-colon punctuation">::</span>string <span class="token operator">&</span>word<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            <span class="token keyword">auto</span> iter <span class="token operator">=</span> _inverted_index<span class="token punctuation">.</span><span class="token function">find</span><span class="token punctuation">(</span>word<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>iter <span class="token operator">==</span> _inverted_index<span class="token punctuation">.</span><span class="token function">end</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                std<span class="token double-colon punctuation">::</span>cerr <span class="token operator"><<</span> word <span class="token operator"><<</span> <span class="token string">"have no Inverted!"</span> <span class="token operator"><<</span> std<span class="token double-colon punctuation">::</span>endl<span class="token punctuation">;</span>
                <span class="token keyword">return</span> <span class="token keyword">nullptr</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            <span class="token keyword">return</span> <span class="token operator">&</span><span class="token punctuation">(</span>iter<span class="token operator">-></span>second<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        <span class="token comment">// parse.cc处理完的数据给我</span>
        <span class="token comment">// /home/ts/procedure_life/program/boost_sercher/data/raw_html</span>
        <span class="token keyword">bool</span> <span class="token function">BuildIndex</span><span class="token punctuation">(</span><span class="token keyword">const</span> std<span class="token double-colon punctuation">::</span>string <span class="token operator">&</span>input<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            std<span class="token double-colon punctuation">::</span>ifstream <span class="token function">in</span><span class="token punctuation">(</span>input<span class="token punctuation">,</span> std<span class="token double-colon punctuation">::</span>ios<span class="token double-colon punctuation">::</span>in <span class="token operator">|</span> std<span class="token double-colon punctuation">::</span>ios<span class="token double-colon punctuation">::</span>binary<span class="token punctuation">)</span><span class="token punctuation">;</span>
            std<span class="token double-colon punctuation">::</span>cout <span class="token operator"><<</span> <span class="token string">"file name: "</span> <span class="token operator"><<</span> input <span class="token operator"><<</span> std<span class="token double-colon punctuation">::</span>endl<span class="token punctuation">;</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>in<span class="token punctuation">.</span><span class="token function">is_open</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                std<span class="token double-colon punctuation">::</span>cerr <span class="token operator"><<</span> <span class="token string">"open "</span> <span class="token operator"><<</span> input <span class="token operator"><<</span> <span class="token string">" failed!"</span> <span class="token operator"><<</span> std<span class="token double-colon punctuation">::</span>endl<span class="token punctuation">;</span>
                <span class="token keyword">return</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            std<span class="token double-colon punctuation">::</span>string line<span class="token punctuation">;</span>
            <span class="token keyword">int</span> count <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
            <span class="token keyword">while</span> <span class="token punctuation">(</span>std<span class="token double-colon punctuation">::</span><span class="token function">getline</span><span class="token punctuation">(</span>in<span class="token punctuation">,</span> line<span class="token punctuation">)</span><span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                <span class="token operator">++</span>count<span class="token punctuation">;</span>
                DocInfo <span class="token operator">*</span>doc <span class="token operator">=</span> <span class="token function">BuildForwardIndex</span><span class="token punctuation">(</span>line<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token comment">// 构建正排</span>
                <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token keyword">nullptr</span> <span class="token operator">==</span> doc<span class="token punctuation">)</span>
                <span class="token punctuation">{</span>
                    std<span class="token double-colon punctuation">::</span>cerr <span class="token operator"><<</span> <span class="token string">"bulid "</span> <span class="token operator"><<</span> line <span class="token operator"><<</span> <span class="token string">" error"</span> <span class="token operator"><<</span> std<span class="token double-colon punctuation">::</span>endl<span class="token punctuation">;</span>
                    <span class="token keyword">continue</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
                <span class="token comment">// 构建倒排</span>
                <span class="token function">BuildInvertedIndex</span><span class="token punctuation">(</span><span class="token operator">*</span>doc<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token keyword">if</span> <span class="token punctuation">(</span>count <span class="token operator">%</span> <span class="token number">50</span> <span class="token operator">==</span> <span class="token number">0</span><span class="token punctuation">)</span>
                    <span class="token comment">// std::cout << "当前正在建立文档:" << count << std::endl;</span>
                    <span class="token function">LOG</span><span class="token punctuation">(</span>NORMAL<span class="token punctuation">,</span> <span class="token string">"构建正排和倒排索引:"</span> <span class="token operator">+</span> std<span class="token double-colon punctuation">::</span><span class="token function">to_string</span><span class="token punctuation">(</span>count<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>

            in<span class="token punctuation">.</span><span class="token function">close</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">return</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

    <span class="token keyword">private</span><span class="token operator">:</span>
        DocInfo <span class="token operator">*</span><span class="token function">BuildForwardIndex</span><span class="token punctuation">(</span><span class="token keyword">const</span> std<span class="token double-colon punctuation">::</span>string <span class="token operator">&</span>line<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            <span class="token comment">// 1.解析line,字符串切分</span>
            std<span class="token double-colon punctuation">::</span>vector<span class="token operator"><</span>std<span class="token double-colon punctuation">::</span>string<span class="token operator">></span> results<span class="token punctuation">;</span>
            <span class="token keyword">const</span> std<span class="token double-colon punctuation">::</span>string sep <span class="token operator">=</span> <span class="token string">"\3"</span><span class="token punctuation">;</span> <span class="token comment">// 行内分隔符</span>
            ns_util<span class="token double-colon punctuation">::</span><span class="token class-name">StringUtil</span><span class="token double-colon punctuation">::</span><span class="token function">Split</span><span class="token punctuation">(</span>line<span class="token punctuation">,</span> <span class="token operator">&</span>results<span class="token punctuation">,</span> sep<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>results<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">!=</span> <span class="token number">3</span><span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                <span class="token keyword">return</span> <span class="token keyword">nullptr</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            <span class="token comment">// 2.将字符串填充到DocInfo</span>
            DocInfo doc<span class="token punctuation">;</span>
            doc<span class="token punctuation">.</span>_title <span class="token operator">=</span> results<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
            doc<span class="token punctuation">.</span>_content <span class="token operator">=</span> results<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
            doc<span class="token punctuation">.</span>_url <span class="token operator">=</span> results<span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
            doc<span class="token punctuation">.</span>_doc_id <span class="token operator">=</span> _forward_index<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment">// 3.插入到正排索引_forward_index中</span>
            _forward_index<span class="token punctuation">.</span><span class="token function">push_back</span><span class="token punctuation">(</span>std<span class="token double-colon punctuation">::</span><span class="token function">move</span><span class="token punctuation">(</span>doc<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">return</span> <span class="token operator">&</span>_forward_index<span class="token punctuation">.</span><span class="token function">back</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        <span class="token keyword">bool</span> <span class="token function">BuildInvertedIndex</span><span class="token punctuation">(</span><span class="token keyword">const</span> DocInfo <span class="token operator">&</span>doc<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            <span class="token comment">// title conten url id</span>
            <span class="token comment">// word -> 倒排拉链</span>

            <span class="token comment">// 1.对title和content进行jieba分词</span>
            std<span class="token double-colon punctuation">::</span>vector<span class="token operator"><</span>std<span class="token double-colon punctuation">::</span>string<span class="token operator">></span> title_words<span class="token punctuation">;</span>
            ns_util<span class="token double-colon punctuation">::</span><span class="token class-name">JiebaUtil</span><span class="token double-colon punctuation">::</span><span class="token function">CutString</span><span class="token punctuation">(</span>doc<span class="token punctuation">.</span>_title<span class="token punctuation">,</span> <span class="token operator">&</span>title_words<span class="token punctuation">)</span><span class="token punctuation">;</span>
            std<span class="token double-colon punctuation">::</span>vector<span class="token operator"><</span>std<span class="token double-colon punctuation">::</span>string<span class="token operator">></span> content_words<span class="token punctuation">;</span>
            ns_util<span class="token double-colon punctuation">::</span><span class="token class-name">JiebaUtil</span><span class="token double-colon punctuation">::</span><span class="token function">CutString</span><span class="token punctuation">(</span>doc<span class="token punctuation">.</span>_content<span class="token punctuation">,</span> <span class="token operator">&</span>content_words<span class="token punctuation">)</span><span class="token punctuation">;</span>

            <span class="token comment">// 2.统计词频</span>
            <span class="token keyword">struct</span> <span class="token class-name">word_cnt</span>
            <span class="token punctuation">{</span>
                <span class="token keyword">int</span> title_cnt<span class="token punctuation">;</span>
                <span class="token keyword">int</span> content_cnt<span class="token punctuation">;</span>

                <span class="token function">word_cnt</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">:</span> <span class="token function">title_cnt</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">content_cnt</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span><span class="token punctuation">}</span>
            <span class="token punctuation">}</span><span class="token punctuation">;</span>

            std<span class="token double-colon punctuation">::</span>unordered_map<span class="token operator"><</span>std<span class="token double-colon punctuation">::</span>string<span class="token punctuation">,</span> word_cnt<span class="token operator">></span> word_map<span class="token punctuation">;</span>
            <span class="token comment">// title Hello</span>
            <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">auto</span> iter <span class="token operator">:</span> title_words<span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                boost<span class="token double-colon punctuation">::</span><span class="token function">to_lower</span><span class="token punctuation">(</span>iter<span class="token punctuation">)</span><span class="token punctuation">;</span>
                word_map<span class="token punctuation">[</span>iter<span class="token punctuation">]</span><span class="token punctuation">.</span>title_cnt<span class="token operator">++</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>

            <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">auto</span> iter <span class="token operator">:</span> content_words<span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                boost<span class="token double-colon punctuation">::</span><span class="token function">to_lower</span><span class="token punctuation">(</span>iter<span class="token punctuation">)</span><span class="token punctuation">;</span>
                word_map<span class="token punctuation">[</span>iter<span class="token punctuation">]</span><span class="token punctuation">.</span>content_cnt<span class="token operator">++</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>

            <span class="token comment">// 3.自定义相关性</span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">define</span> <span class="token macro-name">X</span> <span class="token expression"><span class="token number">10</span></span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">define</span> <span class="token macro-name">Y</span> <span class="token expression"><span class="token number">1</span></span></span>
            <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">auto</span> <span class="token operator">&</span>iter <span class="token operator">:</span> word_map<span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                InvertedElem tmp<span class="token punctuation">;</span>
                tmp<span class="token punctuation">.</span>_doc_id <span class="token operator">=</span> doc<span class="token punctuation">.</span>_doc_id<span class="token punctuation">;</span>
                tmp<span class="token punctuation">.</span>_word <span class="token operator">=</span> iter<span class="token punctuation">.</span>first<span class="token punctuation">;</span>
                tmp<span class="token punctuation">.</span>_weight <span class="token operator">=</span> iter<span class="token punctuation">.</span>second<span class="token punctuation">.</span>title_cnt <span class="token operator">*</span> X <span class="token operator">+</span> iter<span class="token punctuation">.</span>second<span class="token punctuation">.</span>content_cnt <span class="token operator">*</span> Y<span class="token punctuation">;</span>
                InvertedList <span class="token operator">&</span>inver_list <span class="token operator">=</span> _inverted_index<span class="token punctuation">[</span>iter<span class="token punctuation">.</span>first<span class="token punctuation">]</span><span class="token punctuation">;</span>
                inver_list<span class="token punctuation">.</span><span class="token function">push_back</span><span class="token punctuation">(</span>tmp<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            <span class="token keyword">return</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

    <span class="token keyword">private</span><span class="token operator">:</span>
        <span class="token comment">// 正排索引用数组就可以</span>
        std<span class="token double-colon punctuation">::</span>vector<span class="token operator"><</span>DocInfo<span class="token operator">></span> _forward_index<span class="token punctuation">;</span>
        <span class="token comment">// 倒排索引是关键字和一组InverteLIst的对应  [关键字和倒排拉链的映射]</span>
        std<span class="token double-colon punctuation">::</span>unordered_map<span class="token operator"><</span>std<span class="token double-colon punctuation">::</span>string<span class="token punctuation">,</span> InvertedList<span class="token operator">></span> _inverted_index<span class="token punctuation">;</span>
        <span class="token keyword">static</span> Index <span class="token operator">*</span>_instance<span class="token punctuation">;</span>
        <span class="token keyword">static</span> std<span class="token double-colon punctuation">::</span>mutex _mtx<span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">;</span>
    Index <span class="token operator">*</span>Index<span class="token double-colon punctuation">::</span>_instance <span class="token operator">=</span> <span class="token keyword">nullptr</span><span class="token punctuation">;</span>
    std<span class="token double-colon punctuation">::</span>mutex Index<span class="token double-colon punctuation">::</span>_mtx<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre> 
  <h1>七、编写搜索引擎模块 Searcher</h1> 
  <pre><code class="prism language-cpp"><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">pragma</span> <span class="token expression">once</span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">"Index.hpp"</span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">"Util.hpp"</span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string"><algorithm></span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string"><jsoncpp/json/json.h></span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string"><iterator></span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">"Log.hpp"</span></span>

<span class="token keyword">namespace</span> ns_sercher
<span class="token punctuation">{</span>
    <span class="token keyword">struct</span> <span class="token class-name">InvertedElemPrint</span>
    <span class="token punctuation">{</span>
        <span class="token keyword">uint64_t</span> _doc_id <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
        <span class="token keyword">int</span> _weight <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
        std<span class="token double-colon punctuation">::</span>vector<span class="token operator"><</span>std<span class="token double-colon punctuation">::</span>string<span class="token operator">></span> _words<span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">;</span>

    <span class="token keyword">class</span> <span class="token class-name">Searcher</span>
    <span class="token punctuation">{</span>
    <span class="token keyword">public</span><span class="token operator">:</span>
        <span class="token function">Searcher</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span><span class="token punctuation">}</span>
        <span class="token operator">~</span><span class="token function">Searcher</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span><span class="token punctuation">}</span>

    <span class="token keyword">public</span><span class="token operator">:</span>
        <span class="token keyword">void</span> <span class="token function">InitSearcher</span><span class="token punctuation">(</span><span class="token keyword">const</span> std<span class="token double-colon punctuation">::</span>string <span class="token operator">&</span>input<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            <span class="token comment">// 1. 获取或则创建index对象</span>
            _index <span class="token operator">=</span> ns_index<span class="token double-colon punctuation">::</span><span class="token class-name">Index</span><span class="token double-colon punctuation">::</span><span class="token function">GetInstance</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment">// std::cout << "获取单例成功" << std::endl;</span>
            <span class="token function">LOG</span><span class="token punctuation">(</span>NORMAL<span class="token punctuation">,</span> <span class="token string">"获取单例成功..."</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment">// 2. 根据index对象建立索引</span>
            _index<span class="token operator">-></span><span class="token function">BuildIndex</span><span class="token punctuation">(</span>input<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment">// std::cout << "建立正排和倒排成功" << std::endl;</span>
            <span class="token function">LOG</span><span class="token punctuation">(</span>NORMAL<span class="token punctuation">,</span> <span class="token string">"建立正排和倒排索引成功..."</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token punctuation">}</span>

        <span class="token keyword">void</span> <span class="token function">Search</span><span class="token punctuation">(</span><span class="token keyword">const</span> std<span class="token double-colon punctuation">::</span>string <span class="token operator">&</span>query<span class="token punctuation">,</span> std<span class="token double-colon punctuation">::</span>string <span class="token operator">*</span>json_string<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            <span class="token comment">// 1.分词,对我们的query进行按照searcher的要求</span>
            std<span class="token double-colon punctuation">::</span>vector<span class="token operator"><</span>std<span class="token double-colon punctuation">::</span>string<span class="token operator">></span> words<span class="token punctuation">;</span>
            ns_util<span class="token double-colon punctuation">::</span><span class="token class-name">JiebaUtil</span><span class="token double-colon punctuation">::</span><span class="token function">CutString</span><span class="token punctuation">(</span>query<span class="token punctuation">,</span> <span class="token operator">&</span>words<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment">// 2.触发,根据分词的各个词进行index查找</span>
            <span class="token comment">//ns_index::InvertedList inverted_list_all;</span>
            std<span class="token double-colon punctuation">::</span>vector<span class="token operator"><</span>InvertedElemPrint<span class="token operator">></span> inverted_list_all<span class="token punctuation">;</span>
            std<span class="token double-colon punctuation">::</span>unordered_map<span class="token operator"><</span><span class="token keyword">uint64_t</span><span class="token punctuation">,</span> InvertedElemPrint<span class="token operator">></span> tokens_map<span class="token punctuation">;</span>

            <span class="token keyword">for</span> <span class="token punctuation">(</span>std<span class="token double-colon punctuation">::</span>string word <span class="token operator">:</span> words<span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                boost<span class="token double-colon punctuation">::</span><span class="token function">to_lower</span><span class="token punctuation">(</span>word<span class="token punctuation">)</span><span class="token punctuation">;</span>
                ns_index<span class="token double-colon punctuation">::</span>InvertedList <span class="token operator">*</span>inverted_List <span class="token operator">=</span> _index<span class="token operator">-></span><span class="token function">GetInvertedIndex</span><span class="token punctuation">(</span>word<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token keyword">nullptr</span> <span class="token operator">==</span> inverted_List<span class="token punctuation">)</span>
                <span class="token punctuation">{</span>
                    <span class="token keyword">continue</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
                <span class="token comment">//inverted_list_all.insert(inverted_list_all.begin(), (*inverted_List).begin(), (*inverted_List).end());</span>
                <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">const</span> <span class="token keyword">auto</span><span class="token operator">&</span> elem <span class="token operator">:</span> <span class="token operator">*</span>inverted_List<span class="token punctuation">)</span>
                <span class="token punctuation">{</span>
                    InvertedElemPrint<span class="token operator">&</span> item <span class="token operator">=</span> tokens_map<span class="token punctuation">[</span>elem<span class="token punctuation">.</span>_doc_id<span class="token punctuation">]</span><span class="token punctuation">;</span>
                    item<span class="token punctuation">.</span>_weight <span class="token operator">+=</span> elem<span class="token punctuation">.</span>_weight<span class="token punctuation">;</span>
                    item<span class="token punctuation">.</span>_doc_id <span class="token operator">=</span> elem<span class="token punctuation">.</span>_doc_id<span class="token punctuation">;</span>
                    item<span class="token punctuation">.</span>_words<span class="token punctuation">.</span><span class="token function">push_back</span><span class="token punctuation">(</span>elem<span class="token punctuation">.</span>_word<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
            <span class="token punctuation">}</span>
            
            <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">const</span> <span class="token keyword">auto</span><span class="token operator">&</span> item <span class="token operator">:</span>  tokens_map<span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                inverted_list_all<span class="token punctuation">.</span><span class="token function">push_back</span><span class="token punctuation">(</span>std<span class="token double-colon punctuation">::</span><span class="token function">move</span><span class="token punctuation">(</span>item<span class="token punctuation">.</span>second<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>

            <span class="token comment">// 3.合并排序,汇总查询结果,按照相关性(weight)降序排列</span>
            <span class="token comment">// std::sort(inverted_list_all.begin(), inverted_list_all.end(), </span>
            <span class="token comment">// [](const ns_index::InvertedElem& e1, const ns_index::InvertedElem& e2) {</span>
            <span class="token comment">//     return e1._weight > e2._weight;</span>
            <span class="token comment">// });</span>
            std<span class="token double-colon punctuation">::</span><span class="token function">sort</span><span class="token punctuation">(</span>inverted_list_all<span class="token punctuation">.</span><span class="token function">begin</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> inverted_list_all<span class="token punctuation">.</span><span class="token function">end</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> 
            <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">(</span><span class="token keyword">const</span> InvertedElemPrint<span class="token operator">&</span> e1<span class="token punctuation">,</span> <span class="token keyword">const</span> InvertedElemPrint<span class="token operator">&</span> e2<span class="token punctuation">)</span><span class="token punctuation">{</span>
                <span class="token keyword">return</span> e1<span class="token punctuation">.</span>_weight <span class="token operator">></span> e2<span class="token punctuation">.</span>_weight<span class="token punctuation">;</span>
            <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment">// 4.构建,根据查找结果,构建json串,</span>
            Json<span class="token double-colon punctuation">::</span>Value root<span class="token punctuation">;</span>
            <span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">auto</span><span class="token operator">&</span> iter <span class="token operator">:</span> inverted_list_all<span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                ns_index<span class="token double-colon punctuation">::</span>DocInfo<span class="token operator">*</span> pdoc <span class="token operator">=</span> _index<span class="token operator">-></span><span class="token function">GetForwardIndex</span><span class="token punctuation">(</span>iter<span class="token punctuation">.</span>_doc_id<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token keyword">nullptr</span> <span class="token operator">==</span> pdoc<span class="token punctuation">)</span>
                <span class="token punctuation">{</span>
                    <span class="token keyword">continue</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
                Json<span class="token double-colon punctuation">::</span>Value elem<span class="token punctuation">;</span>
                elem<span class="token punctuation">[</span><span class="token string">"title"</span><span class="token punctuation">]</span> <span class="token operator">=</span> pdoc<span class="token operator">-></span>_title<span class="token punctuation">;</span>
                elem<span class="token punctuation">[</span><span class="token string">"content"</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token function">GetDes</span><span class="token punctuation">(</span>pdoc<span class="token operator">-></span>_content<span class="token punctuation">,</span> iter<span class="token punctuation">.</span>_words<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 文档是去掉标签后的结果,但是不是我们想要的结果,我们想要的是一部分</span>
                <span class="token comment">// elem["content"] = pdoc->_content; // 文档是去掉标签后的结果,但是不是我们想要的结果,我们想要的是一部分</span>
                elem<span class="token punctuation">[</span><span class="token string">"url"</span><span class="token punctuation">]</span> <span class="token operator">=</span> pdoc<span class="token operator">-></span>_url<span class="token punctuation">;</span>
                <span class="token comment">//elem["id"] = (int)iter._doc_id;</span>
                <span class="token comment">//elem["weight"] = iter._weight;</span>
                root<span class="token punctuation">.</span><span class="token function">append</span><span class="token punctuation">(</span>elem<span class="token punctuation">)</span><span class="token punctuation">;</span> 
            <span class="token punctuation">}</span>
            Json<span class="token double-colon punctuation">::</span>FastWriter writer<span class="token punctuation">;</span>
            <span class="token operator">*</span>json_string <span class="token operator">=</span> writer<span class="token punctuation">.</span><span class="token function">write</span><span class="token punctuation">(</span>root<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        std<span class="token double-colon punctuation">::</span>string <span class="token function">GetDes</span><span class="token punctuation">(</span><span class="token keyword">const</span> std<span class="token double-colon punctuation">::</span>string<span class="token operator">&</span> html_content<span class="token punctuation">,</span> <span class="token keyword">const</span> std<span class="token double-colon punctuation">::</span>string<span class="token operator">&</span> word<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            <span class="token comment">// 从第一次出现word的位置开始向前找50个字节,向后找100个字节</span>
            <span class="token keyword">const</span> size_t prev_step <span class="token operator">=</span> <span class="token number">50</span><span class="token punctuation">;</span>
            <span class="token keyword">const</span> size_t next_step <span class="token operator">=</span> <span class="token number">100</span><span class="token punctuation">;</span>
            <span class="token comment">// 找到在content中第一次出现word的位置</span>
            <span class="token keyword">auto</span> iter <span class="token operator">=</span> std<span class="token double-colon punctuation">::</span><span class="token function">search</span><span class="token punctuation">(</span>html_content<span class="token punctuation">.</span><span class="token function">begin</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span>html_content<span class="token punctuation">.</span><span class="token function">end</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> word<span class="token punctuation">.</span><span class="token function">begin</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span>word<span class="token punctuation">.</span><span class="token function">end</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> 
            <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">(</span><span class="token keyword">int</span> x<span class="token punctuation">,</span> <span class="token keyword">int</span> y<span class="token punctuation">)</span><span class="token punctuation">{</span> <span class="token keyword">return</span> std<span class="token double-colon punctuation">::</span><span class="token function">tolower</span><span class="token punctuation">(</span>x<span class="token punctuation">)</span> <span class="token operator">==</span> std<span class="token double-colon punctuation">::</span><span class="token function">tolower</span><span class="token punctuation">(</span>y<span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">if</span><span class="token punctuation">(</span>iter <span class="token operator">==</span> html_content<span class="token punctuation">.</span><span class="token function">end</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                <span class="token keyword">return</span> <span class="token string">"None1"</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            size_t pos <span class="token operator">=</span> std<span class="token double-colon punctuation">::</span><span class="token function">distance</span><span class="token punctuation">(</span>html_content<span class="token punctuation">.</span><span class="token function">begin</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> iter<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment">//错误查找</span>
            <span class="token comment">// size_t pos = html_content.find(word);</span>
            <span class="token comment">// if(pos == std::string::npos)</span>
            <span class="token comment">// {</span>
            <span class="token comment">//     return "None word";</span>
            <span class="token comment">// }</span>

            size_t start <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
            size_t end <span class="token operator">=</span> html_content<span class="token punctuation">.</span><span class="token function">size</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">;</span>
            <span class="token keyword">if</span><span class="token punctuation">(</span>start <span class="token operator">+</span> prev_step <span class="token operator"><</span> pos<span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                start <span class="token operator">=</span> pos <span class="token operator">-</span> prev_step<span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            <span class="token keyword">if</span><span class="token punctuation">(</span>pos <span class="token operator">+</span> next_step <span class="token operator"><</span> end<span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                end <span class="token operator">=</span> pos <span class="token operator">+</span> next_step<span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            <span class="token keyword">if</span><span class="token punctuation">(</span>start <span class="token operator">></span> end<span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                <span class="token keyword">return</span> <span class="token string">"None2"</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            <span class="token comment">// 获取start-end之间的字符串</span>
            <span class="token keyword">return</span> html_content<span class="token punctuation">.</span><span class="token function">substr</span><span class="token punctuation">(</span>start<span class="token punctuation">,</span> end <span class="token operator">-</span> start<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

    <span class="token keyword">private</span><span class="token operator">:</span>
        ns_index<span class="token double-colon punctuation">::</span>Index<span class="token operator">*</span> _index<span class="token punctuation">;</span> <span class="token comment">// 提供查找的索引</span>
    <span class="token punctuation">}</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre> 
  <h1>八、编写http_server 模块</h1> 
  <pre><code class="prism language-cpp"><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">"./cpp-httplib/httplib.h"</span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">"Sercher.hpp"</span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">"Log.hpp"</span></span>

<span class="token keyword">const</span> std<span class="token double-colon punctuation">::</span>string root_path <span class="token operator">=</span> <span class="token string">"./wwwroot"</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> std<span class="token double-colon punctuation">::</span>string input <span class="token operator">=</span> <span class="token string">"data/raw_html/raw.txt"</span><span class="token punctuation">;</span>

<span class="token keyword">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    httplib<span class="token double-colon punctuation">::</span>Server svr<span class="token punctuation">;</span>
    ns_sercher<span class="token double-colon punctuation">::</span>Searcher searcher<span class="token punctuation">;</span>
    searcher<span class="token punctuation">.</span><span class="token function">InitSearcher</span><span class="token punctuation">(</span>input<span class="token punctuation">)</span><span class="token punctuation">;</span>
    svr<span class="token punctuation">.</span><span class="token function">set_base_dir</span><span class="token punctuation">(</span>root_path<span class="token punctuation">.</span><span class="token function">c_str</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    svr<span class="token punctuation">.</span><span class="token function">Get</span><span class="token punctuation">(</span><span class="token string">"/s"</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token operator">&</span>searcher<span class="token punctuation">]</span><span class="token punctuation">(</span><span class="token keyword">const</span> httplib<span class="token double-colon punctuation">::</span>Request<span class="token operator">&</span> req<span class="token punctuation">,</span> httplib<span class="token double-colon punctuation">::</span>Response<span class="token operator">&</span> res<span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token operator">!</span>req<span class="token punctuation">.</span><span class="token function">has_param</span><span class="token punctuation">(</span><span class="token string">"word"</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            res<span class="token punctuation">.</span><span class="token function">set_content</span><span class="token punctuation">(</span><span class="token string">"必须要有搜索关键系!"</span><span class="token punctuation">,</span> <span class="token string">"text/plain; charset=utf-8"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">return</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token function">LOG</span><span class="token punctuation">(</span>NORMAL<span class="token punctuation">,</span> <span class="token string">"搜索关键词成功..."</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        std<span class="token double-colon punctuation">::</span>string word <span class="token operator">=</span> req<span class="token punctuation">.</span><span class="token function">get_param_value</span><span class="token punctuation">(</span><span class="token string">"word"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        std<span class="token double-colon punctuation">::</span>string json_string<span class="token punctuation">;</span>
        searcher<span class="token punctuation">.</span><span class="token function">Search</span><span class="token punctuation">(</span>word<span class="token punctuation">,</span> <span class="token operator">&</span>json_string<span class="token punctuation">)</span><span class="token punctuation">;</span>
        res<span class="token punctuation">.</span><span class="token function">set_content</span><span class="token punctuation">(</span>json_string<span class="token punctuation">,</span> <span class="token string">"application/json; charset=utf-8"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//res.set_content("Hello World!", "text/plain; charset=utf-8");</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">LOG</span><span class="token punctuation">(</span>NORMAL<span class="token punctuation">,</span> <span class="token string">"服务器启动成功..."</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    svr<span class="token punctuation">.</span><span class="token function">listen</span><span class="token punctuation">(</span><span class="token string">"0.0.0.0"</span><span class="token punctuation">,</span> <span class="token number">8080</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre> 
  <h1>九、编写前端模块</h1> 
  <pre><code class="prism language-cpp"><span class="token operator"><</span><span class="token operator">!</span>DOCTYPE html<span class="token operator">></span>
<span class="token operator"><</span>html lang<span class="token operator">=</span><span class="token string">"en"</span><span class="token operator">></span>
<span class="token operator"><</span>head<span class="token operator">></span>
    <span class="token operator"><</span>meta charset<span class="token operator">=</span><span class="token string">"UTF-8"</span><span class="token operator">></span>
    <span class="token operator"><</span>meta http<span class="token operator">-</span>equiv<span class="token operator">=</span><span class="token string">"X-UA-Compatible"</span> content<span class="token operator">=</span><span class="token string">"IE=edge"</span><span class="token operator">></span>
    <span class="token operator"><</span>meta name<span class="token operator">=</span><span class="token string">"viewport"</span> content<span class="token operator">=</span><span class="token string">"width=device-width, initial-scale=1.0"</span><span class="token operator">></span>
    <span class="token operator"><</span>script src<span class="token operator">=</span><span class="token string">"http://code.jquery.com/jquery-2.1.1.min.js"</span><span class="token operator">></span><span class="token operator"><</span><span class="token operator">/</span>script<span class="token operator">></span>

    <span class="token operator"><</span>title<span class="token operator">></span>boost 搜索引擎<span class="token operator"><</span><span class="token operator">/</span>title<span class="token operator">></span>
    <span class="token operator"><</span>style<span class="token operator">></span>
        <span class="token comment">/* 去掉网页中的所有的默认内外边距,html的盒子模型 */</span>
        <span class="token operator">*</span> <span class="token punctuation">{</span>
            <span class="token comment">/* 设置外边距 */</span>
            margin<span class="token operator">:</span> <span class="token number">0</span><span class="token punctuation">;</span>
            <span class="token comment">/* 设置内边距 */</span>
            padding<span class="token operator">:</span> <span class="token number">0</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token comment">/* 将我们的body内的内容100%和html的呈现吻合 */</span>
        html<span class="token punctuation">,</span>
        body <span class="token punctuation">{</span>
            height<span class="token operator">:</span> <span class="token number">100</span><span class="token operator">%</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token comment">/* 类选择器.container */</span>
        <span class="token punctuation">.</span>container <span class="token punctuation">{</span>
            <span class="token comment">/* 设置div的宽度 */</span>
            width<span class="token operator">:</span> <span class="token number">800</span>px<span class="token punctuation">;</span>
            <span class="token comment">/* 通过设置外边距达到居中对齐的目的 */</span>
            margin<span class="token operator">:</span> <span class="token number">0</span>px <span class="token keyword">auto</span><span class="token punctuation">;</span>
            <span class="token comment">/* 设置外边距的上边距,保持元素和网页的上部距离 */</span>
            margin<span class="token operator">-</span>top<span class="token operator">:</span> <span class="token number">15</span>px<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token comment">/* 复合选择器,选中container 下的 search */</span>
        <span class="token punctuation">.</span>container <span class="token punctuation">.</span>search <span class="token punctuation">{</span>
            <span class="token comment">/* 宽度与父标签保持一致 */</span>
            width<span class="token operator">:</span> <span class="token number">100</span><span class="token operator">%</span><span class="token punctuation">;</span>
            <span class="token comment">/* 高度设置为52px */</span>
            height<span class="token operator">:</span> <span class="token number">52</span>px<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token comment">/* 先选中input标签, 直接设置标签的属性,先要选中, input:标签选择器*/</span>
        <span class="token comment">/* input在进行高度设置的时候,没有考虑边框的问题 */</span>
        <span class="token punctuation">.</span>container <span class="token punctuation">.</span>search input <span class="token punctuation">{</span>
            <span class="token comment">/* 设置left浮动 */</span>
            <span class="token keyword">float</span><span class="token operator">:</span> left<span class="token punctuation">;</span>
            width<span class="token operator">:</span> <span class="token number">600</span>px<span class="token punctuation">;</span>
            height<span class="token operator">:</span> <span class="token number">50</span>px<span class="token punctuation">;</span>
            <span class="token comment">/* 设置边框属性:边框的宽度,样式,颜色 */</span>
            border<span class="token operator">:</span> <span class="token number">1</span>px solid black<span class="token punctuation">;</span>
            <span class="token comment">/* 去掉input输入框的有边框 */</span>
            border<span class="token operator">-</span>right<span class="token operator">:</span> none<span class="token punctuation">;</span>
            <span class="token comment">/* 设置内边距,默认文字不要和左侧边框紧挨着 */</span>
            padding<span class="token operator">-</span>left<span class="token operator">:</span> <span class="token number">10</span>px<span class="token punctuation">;</span>
            <span class="token comment">/* 设置input内部的字体的颜色和样式 */</span>
            color<span class="token operator">:</span> #CCC<span class="token punctuation">;</span>
            font<span class="token operator">-</span>size<span class="token operator">:</span> <span class="token number">14</span>px<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token comment">/* 先选中button标签, 直接设置标签的属性,先要选中, button:标签选择器*/</span>
        <span class="token punctuation">.</span>container <span class="token punctuation">.</span>search button <span class="token punctuation">{</span>
            <span class="token comment">/* 设置left浮动 */</span>
            <span class="token keyword">float</span><span class="token operator">:</span> left<span class="token punctuation">;</span>
            width<span class="token operator">:</span> <span class="token number">150</span>px<span class="token punctuation">;</span>
            height<span class="token operator">:</span> <span class="token number">52</span>px<span class="token punctuation">;</span>
            <span class="token comment">/* 设置button的背景颜色,#4e6ef2 */</span>
            background<span class="token operator">-</span>color<span class="token operator">:</span> #<span class="token number">4e6</span>ef2<span class="token punctuation">;</span>
            <span class="token comment">/* 设置button中的字体颜色 */</span>
            color<span class="token operator">:</span> #FFF<span class="token punctuation">;</span>
            <span class="token comment">/* 设置字体的大小 */</span>
            font<span class="token operator">-</span>size<span class="token operator">:</span> <span class="token number">19</span>px<span class="token punctuation">;</span>
            font<span class="token operator">-</span>family<span class="token operator">:</span>Georgia<span class="token punctuation">,</span> <span class="token char">'Times New Roman'</span><span class="token punctuation">,</span> Times<span class="token punctuation">,</span> serif<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token punctuation">.</span>container <span class="token punctuation">.</span>result <span class="token punctuation">{</span>
            width<span class="token operator">:</span> <span class="token number">100</span><span class="token operator">%</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token punctuation">.</span>container <span class="token punctuation">.</span>result <span class="token punctuation">.</span>item <span class="token punctuation">{</span>
            margin<span class="token operator">-</span>top<span class="token operator">:</span> <span class="token number">15</span>px<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        <span class="token punctuation">.</span>container <span class="token punctuation">.</span>result <span class="token punctuation">.</span>item a <span class="token punctuation">{</span>
            <span class="token comment">/* 设置为块级元素,单独站一行 */</span>
            display<span class="token operator">:</span> block<span class="token punctuation">;</span>
            <span class="token comment">/* a标签的下划线去掉 */</span>
            text<span class="token operator">-</span>decoration<span class="token operator">:</span> none<span class="token punctuation">;</span>
            <span class="token comment">/* 设置a标签中的文字的字体大小 */</span>
            font<span class="token operator">-</span>size<span class="token operator">:</span> <span class="token number">20</span>px<span class="token punctuation">;</span>
            <span class="token comment">/* 设置字体的颜色 */</span>
            color<span class="token operator">:</span> #<span class="token number">4e6</span>ef2<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token punctuation">.</span>container <span class="token punctuation">.</span>result <span class="token punctuation">.</span>item a<span class="token operator">:</span>hover <span class="token punctuation">{</span>
            text<span class="token operator">-</span>decoration<span class="token operator">:</span> underline<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token punctuation">.</span>container <span class="token punctuation">.</span>result <span class="token punctuation">.</span>item p <span class="token punctuation">{</span>
            margin<span class="token operator">-</span>top<span class="token operator">:</span> <span class="token number">5</span>px<span class="token punctuation">;</span>
            font<span class="token operator">-</span>size<span class="token operator">:</span> <span class="token number">16</span>px<span class="token punctuation">;</span>
            font<span class="token operator">-</span>family<span class="token operator">:</span><span class="token char">'Lucida Sans'</span><span class="token punctuation">,</span> <span class="token char">'Lucida Sans Regular'</span><span class="token punctuation">,</span> <span class="token char">'Lucida Grande'</span><span class="token punctuation">,</span> <span class="token char">'Lucida Sans Unicode'</span><span class="token punctuation">,</span> Geneva<span class="token punctuation">,</span> Verdana<span class="token punctuation">,</span> sans<span class="token operator">-</span>serif<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        <span class="token punctuation">.</span>container <span class="token punctuation">.</span>result <span class="token punctuation">.</span>item i<span class="token punctuation">{</span>
            <span class="token comment">/* 设置为块级元素,单独站一行 */</span>
            display<span class="token operator">:</span> block<span class="token punctuation">;</span>
            <span class="token comment">/* 取消斜体风格 */</span>
            font<span class="token operator">-</span>style<span class="token operator">:</span> normal<span class="token punctuation">;</span>
            color<span class="token operator">:</span> green<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token operator"><</span><span class="token operator">/</span>style<span class="token operator">></span>
<span class="token operator"><</span><span class="token operator">/</span>head<span class="token operator">></span>
<span class="token operator"><</span>body<span class="token operator">></span>
    <span class="token operator"><</span>div <span class="token keyword">class</span><span class="token operator">=</span><span class="token string">"container"</span><span class="token operator">></span>
        <span class="token operator"><</span>div <span class="token keyword">class</span><span class="token operator">=</span><span class="token string">"search"</span><span class="token operator">></span>
            <span class="token operator"><</span>input type<span class="token operator">=</span><span class="token string">"text"</span> value<span class="token operator">=</span><span class="token string">"请输入搜索关键字"</span><span class="token operator">></span>
            <span class="token operator"><</span>button onclick<span class="token operator">=</span><span class="token string">"Search()"</span><span class="token operator">></span>搜索一下<span class="token operator"><</span><span class="token operator">/</span>button<span class="token operator">></span>
        <span class="token operator"><</span><span class="token operator">/</span>div<span class="token operator">></span>
        <span class="token operator"><</span>div <span class="token keyword">class</span><span class="token operator">=</span><span class="token string">"result"</span><span class="token operator">></span>
            <span class="token operator"><</span><span class="token operator">!</span><span class="token operator">--</span> 动态生成网页内容 <span class="token operator">--</span><span class="token operator">></span>
            <span class="token operator"><</span><span class="token operator">!</span><span class="token operator">--</span> <span class="token operator"><</span>div <span class="token keyword">class</span><span class="token operator">=</span><span class="token string">"item"</span><span class="token operator">></span>
                <span class="token operator"><</span>a href<span class="token operator">=</span><span class="token string">"#"</span><span class="token operator">></span>这是标题<span class="token operator"><</span><span class="token operator">/</span>a<span class="token operator">></span>
                <span class="token operator"><</span>p<span class="token operator">></span>这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要<span class="token operator"><</span><span class="token operator">/</span>p<span class="token operator">></span>
                <span class="token operator"><</span>i<span class="token operator">></span>https<span class="token operator">:</span><span class="token comment">//search.gitee.com/?skin=rec&type=repository&q=cpp-httplib</i></span>
            <span class="token operator"><</span><span class="token operator">/</span>div<span class="token operator">></span>
            <span class="token operator"><</span>div <span class="token keyword">class</span><span class="token operator">=</span><span class="token string">"item"</span><span class="token operator">></span>
                <span class="token operator"><</span>a href<span class="token operator">=</span><span class="token string">"#"</span><span class="token operator">></span>这是标题<span class="token operator"><</span><span class="token operator">/</span>a<span class="token operator">></span>
                <span class="token operator"><</span>p<span class="token operator">></span>这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要<span class="token operator"><</span><span class="token operator">/</span>p<span class="token operator">></span>
                <span class="token operator"><</span>i<span class="token operator">></span>https<span class="token operator">:</span><span class="token comment">//search.gitee.com/?skin=rec&type=repository&q=cpp-httplib</i></span>
            <span class="token operator"><</span><span class="token operator">/</span>div<span class="token operator">></span>
            <span class="token operator"><</span>div <span class="token keyword">class</span><span class="token operator">=</span><span class="token string">"item"</span><span class="token operator">></span>
                <span class="token operator"><</span>a href<span class="token operator">=</span><span class="token string">"#"</span><span class="token operator">></span>这是标题<span class="token operator"><</span><span class="token operator">/</span>a<span class="token operator">></span>
                <span class="token operator"><</span>p<span class="token operator">></span>这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要<span class="token operator"><</span><span class="token operator">/</span>p<span class="token operator">></span>
                <span class="token operator"><</span>i<span class="token operator">></span>https<span class="token operator">:</span><span class="token comment">//search.gitee.com/?skin=rec&type=repository&q=cpp-httplib</i></span>
            <span class="token operator"><</span><span class="token operator">/</span>div<span class="token operator">></span>
            <span class="token operator"><</span>div <span class="token keyword">class</span><span class="token operator">=</span><span class="token string">"item"</span><span class="token operator">></span>
                <span class="token operator"><</span>a href<span class="token operator">=</span><span class="token string">"#"</span><span class="token operator">></span>这是标题<span class="token operator"><</span><span class="token operator">/</span>a<span class="token operator">></span>
                <span class="token operator"><</span>p<span class="token operator">></span>这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要<span class="token operator"><</span><span class="token operator">/</span>p<span class="token operator">></span>
                <span class="token operator"><</span>i<span class="token operator">></span>https<span class="token operator">:</span><span class="token comment">//search.gitee.com/?skin=rec&type=repository&q=cpp-httplib</i></span>
            <span class="token operator"><</span><span class="token operator">/</span>div<span class="token operator">></span>
            <span class="token operator"><</span>div <span class="token keyword">class</span><span class="token operator">=</span><span class="token string">"item"</span><span class="token operator">></span>
                <span class="token operator"><</span>a href<span class="token operator">=</span><span class="token string">"#"</span><span class="token operator">></span>这是标题<span class="token operator"><</span><span class="token operator">/</span>a<span class="token operator">></span>
                <span class="token operator"><</span>p<span class="token operator">></span>这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要这是摘要<span class="token operator"><</span><span class="token operator">/</span>p<span class="token operator">></span>
                <span class="token operator"><</span>i<span class="token operator">></span>https<span class="token operator">:</span><span class="token comment">//search.gitee.com/?skin=rec&type=repository&q=cpp-httplib</i></span>
            <span class="token operator"><</span><span class="token operator">/</span>div<span class="token operator">></span> <span class="token operator">--</span><span class="token operator">></span>
        <span class="token operator"><</span><span class="token operator">/</span>div<span class="token operator">></span>
    <span class="token operator"><</span><span class="token operator">/</span>div<span class="token operator">></span>
    <span class="token operator"><</span>script<span class="token operator">></span>
        function <span class="token function">Search</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
            <span class="token comment">// 是浏览器的一个弹出框</span>
            <span class="token comment">// alert("hello js!");</span>
            <span class="token comment">// 1. 提取数据, $可以理解成就是JQuery的别称</span>
            let query <span class="token operator">=</span> $<span class="token punctuation">(</span><span class="token string">".container .search input"</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">val</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">"query = "</span> <span class="token operator">+</span> query<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//console是浏览器的对话框,可以用来进行查看js数据</span>

            <span class="token comment">//2. 发起http请求,ajax: 属于一个和后端进行数据交互的函数,JQuery中的</span>
            $<span class="token punctuation">.</span><span class="token function">ajax</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
                type<span class="token operator">:</span> <span class="token string">"GET"</span><span class="token punctuation">,</span>
                url<span class="token operator">:</span> <span class="token string">"/s?word="</span> <span class="token operator">+</span> query<span class="token punctuation">,</span>
                success<span class="token operator">:</span> <span class="token function">function</span><span class="token punctuation">(</span>data<span class="token punctuation">)</span><span class="token punctuation">{</span>
                    console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>data<span class="token punctuation">)</span><span class="token punctuation">;</span>
                    <span class="token function">BuildHtml</span><span class="token punctuation">(</span>data<span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
            <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        function <span class="token function">BuildHtml</span><span class="token punctuation">(</span>data<span class="token punctuation">)</span><span class="token punctuation">{</span>
            <span class="token comment">// 获取html中的result标签</span>
            let result_lable <span class="token operator">=</span> $<span class="token punctuation">(</span><span class="token string">".container .result"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment">// 清空历史搜索结果</span>
            result_lable<span class="token punctuation">.</span><span class="token function">empty</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

            <span class="token keyword">for</span><span class="token punctuation">(</span> let elem of data<span class="token punctuation">)</span><span class="token punctuation">{</span>
                <span class="token comment">// console.log(elem.title);</span>
                <span class="token comment">// console.log(elem.url);</span>
                let a_lable <span class="token operator">=</span> $<span class="token punctuation">(</span><span class="token string">"<a>"</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
                    text<span class="token operator">:</span> elem<span class="token punctuation">.</span>title<span class="token punctuation">,</span>
                    href<span class="token operator">:</span> elem<span class="token punctuation">.</span>url<span class="token punctuation">,</span>
                    <span class="token comment">// 跳转到新的页面</span>
                    target<span class="token operator">:</span> <span class="token string">"_blank"</span>
                <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                let p_lable <span class="token operator">=</span> $<span class="token punctuation">(</span><span class="token string">"<p>"</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
                    text<span class="token operator">:</span> elem<span class="token punctuation">.</span>desc
                <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                let i_lable <span class="token operator">=</span> $<span class="token punctuation">(</span><span class="token string">"<i>"</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
                    text<span class="token operator">:</span> elem<span class="token punctuation">.</span>url
                <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                let div_lable <span class="token operator">=</span> $<span class="token punctuation">(</span><span class="token string">"<div>"</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
                    <span class="token keyword">class</span><span class="token operator">:</span> <span class="token string">"item"</span>
                <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                a_lable<span class="token punctuation">.</span><span class="token function">appendTo</span><span class="token punctuation">(</span>div_lable<span class="token punctuation">)</span><span class="token punctuation">;</span>
                p_lable<span class="token punctuation">.</span><span class="token function">appendTo</span><span class="token punctuation">(</span>div_lable<span class="token punctuation">)</span><span class="token punctuation">;</span>
                i_lable<span class="token punctuation">.</span><span class="token function">appendTo</span><span class="token punctuation">(</span>div_lable<span class="token punctuation">)</span><span class="token punctuation">;</span>
                div_lable<span class="token punctuation">.</span><span class="token function">appendTo</span><span class="token punctuation">(</span>result_lable<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
    <span class="token operator"><</span><span class="token operator">/</span>script<span class="token operator">></span>
<span class="token operator"><</span><span class="token operator">/</span>body<span class="token operator">></span>
<span class="token operator"><</span><span class="token operator">/</span>html<span class="token operator">></span>
</code></pre> 
  <h1>十、添加日志</h1> 
  <pre><code class="prism language-cpp"><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">pragma</span> <span class="token expression">once</span></span>

<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string"><iostream></span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string"><string></span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string"><ctime></span></span>

<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">define</span> <span class="token macro-name">NORMAL</span> <span class="token expression"><span class="token number">1</span></span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">define</span> <span class="token macro-name">WARNING</span> <span class="token expression"><span class="token number">2</span></span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">define</span> <span class="token macro-name">DEBUG</span> <span class="token expression"><span class="token number">3</span></span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">define</span> <span class="token macro-name">FATAL</span> <span class="token expression"><span class="token number">4</span></span></span>

<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">define</span> <span class="token macro-name function">LOG</span><span class="token expression"><span class="token punctuation">(</span>LEVEL<span class="token punctuation">,</span> MESSAGE<span class="token punctuation">)</span> <span class="token function">Log</span><span class="token punctuation">(</span>#LEVEL<span class="token punctuation">,</span> MESSAGE<span class="token punctuation">,</span> <span class="token constant">__FILE__</span><span class="token punctuation">,</span> <span class="token constant">__LINE__</span><span class="token punctuation">)</span></span></span>

<span class="token keyword">void</span> <span class="token function">Log</span><span class="token punctuation">(</span><span class="token keyword">const</span> std<span class="token double-colon punctuation">::</span>string<span class="token operator">&</span> level<span class="token punctuation">,</span> <span class="token keyword">const</span> std<span class="token double-colon punctuation">::</span>string<span class="token operator">&</span> message<span class="token punctuation">,</span> <span class="token keyword">const</span> std<span class="token double-colon punctuation">::</span>string<span class="token operator">&</span> file<span class="token punctuation">,</span> <span class="token keyword">int</span> line<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    std<span class="token double-colon punctuation">::</span>cout <span class="token operator"><<</span> <span class="token string">"[level:"</span> <span class="token operator"><<</span> level <span class="token operator"><<</span> <span class="token string">"]"</span> <span class="token operator"><<</span> <span class="token string">"[time:"</span> <span class="token operator"><<</span> <span class="token function">time</span><span class="token punctuation">(</span><span class="token keyword">nullptr</span><span class="token punctuation">)</span> <span class="token operator"><<</span> <span class="token string">"]"</span> <span class="token operator"><<</span> <span class="token string">"[message:"</span> <span class="token operator"><<</span> message <span class="token operator"><<</span> <span class="token string">"]"</span>
    <span class="token operator"><<</span> <span class="token string">"[file:"</span> <span class="token operator"><<</span> file <span class="token operator"><<</span> <span class="token string">"]"</span> <span class="token operator"><<</span> <span class="token string">"[line:"</span> <span class="token operator"><<</span> line <span class="token operator"><<</span> <span class="token string">"]"</span> <span class="token operator"><<</span> std<span class="token double-colon punctuation">::</span>endl<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

</code></pre> 
  <h2>10.1 部署服务到 linux 上</h2> 
  <blockquote> 
   <p>nohup ./http_server > log/log.txt 2>&1 &</p> 
  </blockquote> 
  <h1>十一、结项总结</h1> 
  <p>项目扩展方向</p> 
  <ol> 
   <li>建立整站搜索</li> 
   <li>设计一个在线更新的方案,信号,爬虫,完成整个服务器的设计</li> 
   <li>不使用组件,而是自己设计一下对应的各种方案(有时间,有精力)</li> 
   <li>在我们的搜索引擎中,添加竞价排名(强烈推荐)</li> 
   <li>热次统计,智能显示搜索关键词(字典树,优先级队列)(比较推荐)</li> 
   <li>设置登陆注册,引入对mysql的使用(比较推荐的)</li> 
  </ol> 
 </div> 
</div>
                            </div>
                        </div>
                    </div>
                    <!--PC和WAP自适应版-->
                    <div id="SOHUCS" sid="1566743644843610112"></div>
                    <script type="text/javascript" src="/views/front/js/chanyan.js"></script>
                    <!-- 文章页-底部 动态广告位 -->
                    <div class="youdao-fixed-ad" id="detail_ad_bottom"></div>
                </div>
                <div class="col-md-3">
                    <div class="row" id="ad">
                        <!-- 文章页-右侧1 动态广告位 -->
                        <div id="right-1" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad">
                            <div class="youdao-fixed-ad" id="detail_ad_1"> </div>
                        </div>
                        <!-- 文章页-右侧2 动态广告位 -->
                        <div id="right-2" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad">
                            <div class="youdao-fixed-ad" id="detail_ad_2"></div>
                        </div>
                        <!-- 文章页-右侧3 动态广告位 -->
                        <div id="right-3" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad">
                            <div class="youdao-fixed-ad" id="detail_ad_3"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="container">
        <h4 class="pt20 mb15 mt0 border-top">你可能感兴趣的:(项目,搜索引擎,c++,开发语言)</h4>
        <div id="paradigm-article-related">
            <div class="recommend-post mb30">
                <ul class="widget-links">
                    <li><a href="/article/1883020731848126464.htm"
                           title="Python3【字符串】:文本操作的瑞士军刀" target="_blank">Python3【字符串】:文本操作的瑞士军刀</a>
                        <span class="text-muted">李智 - 重庆</span>
<a class="tag" taget="_blank" href="/search/Python/1.htm">Python</a><a class="tag" taget="_blank" href="/search/%E7%B2%BE%E8%AE%B2%E7%B2%BE%E7%BB%83/1.htm">精讲精练</a><a class="tag" taget="_blank" href="/search/-/1.htm">-</a><a class="tag" taget="_blank" href="/search/%E4%BB%8E%E5%85%A5%E9%97%A8%E5%88%B0%E5%AE%9E%E6%88%98/1.htm">从入门到实战</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E8%AF%AD%E8%A8%80/1.htm">开发语言</a><a class="tag" taget="_blank" href="/search/%E7%BB%8F%E9%AA%8C%E5%88%86%E4%BA%AB/1.htm">经验分享</a><a class="tag" taget="_blank" href="/search/%E7%BC%96%E7%A8%8B%E5%AE%9E%E6%88%98/1.htm">编程实战</a><a class="tag" taget="_blank" href="/search/%E8%B6%A3%E5%91%B3%E7%BC%96%E7%A8%8B/1.htm">趣味编程</a><a class="tag" taget="_blank" href="/search/%E7%BC%96%E7%A8%8B%E6%8A%80%E5%B7%A7/1.htm">编程技巧</a>
                        <div>Python3【字符串】:文本操作的瑞士军刀内容简介本系列文章是为Python3学习者精心设计的一套全面、实用的学习指南,旨在帮助读者从基础入门到项目实战,全面提升编程能力。文章结构由5个版块组成,内容层层递进,逻辑清晰。基础速通:n个浓缩提炼的核心知识点,夯实编程基础;经典范例:10个贴近实际的应用场景,深入理解Python3的编程技巧和应用方法;避坑宝典:10个典型错误解析,提供解决方案,帮助</div>
                    </li>
                    <li><a href="/article/1883020353844867072.htm"
                           title="使用Python实现并行计算算法:效率提升的利器" target="_blank">使用Python实现并行计算算法:效率提升的利器</a>
                        <span class="text-muted">Echo_Wish</span>
<a class="tag" taget="_blank" href="/search/Python%E8%BF%9B%E9%98%B6/1.htm">Python进阶</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E7%AE%97%E6%B3%95/1.htm">算法</a><a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E8%AF%AD%E8%A8%80/1.htm">开发语言</a>
                        <div>在处理大规模数据和计算密集型任务时,单线程的处理方式往往显得力不从心。并行计算作为一种提升计算效率的重要手段,能够充分利用多核处理器的优势,加速任务的完成。Python作为一种灵活且功能强大的编程语言,提供了丰富的并行计算工具。本文将详细介绍如何使用Python实现并行计算算法,并通过具体代码示例展示其实现过程。项目概述本项目旨在通过Python实现一个并行计算算法,展示如何利用Python的多线</div>
                    </li>
                    <li><a href="/article/1883018212879167488.htm"
                           title="华为OD机试2024年E卷-分苹果[100分]( Java | Python3 | C++ | C语言 | JsNode | Go )实现100%通过率" target="_blank">华为OD机试2024年E卷-分苹果[100分]( Java | Python3 | C++ | C语言 | JsNode | Go )实现100%通过率</a>
                        <span class="text-muted">梅花C</span>
<a class="tag" taget="_blank" href="/search/%E5%8D%8E%E4%B8%BAOD%E9%A2%98%E5%BA%93/1.htm">华为OD题库</a><a class="tag" taget="_blank" href="/search/%E5%8D%8E%E4%B8%BAod/1.htm">华为od</a>
                        <div>题目描述A、B两个人把苹果分为两堆,A希望按照他的计算规则等分苹果Q,他的计算规则是按照二进制加法计算,并且不计算进位12+5=9(1100+0101=9),B的计算规则是十进制加法,包括正常进位,B希望在满足A的情况下获取苹果重量最多。输入苹果的数量和每个苹果重量,输出满足A的情况下B获取的苹果总重量。如果无法满足A的要求,输出-1。数据范围1<=总苹果数量<=200001<=每个苹果重量<=1</div>
                    </li>
                    <li><a href="/article/1883015942426914816.htm"
                           title="使用IDEA创建一个SpringBoot项目" target="_blank">使用IDEA创建一个SpringBoot项目</a>
                        <span class="text-muted">web13293720476</span>
<a class="tag" taget="_blank" href="/search/%E9%9D%A2%E8%AF%95/1.htm">面试</a><a class="tag" taget="_blank" href="/search/%E5%AD%A6%E4%B9%A0%E8%B7%AF%E7%BA%BF/1.htm">学习路线</a><a class="tag" taget="_blank" href="/search/%E9%98%BF%E9%87%8C%E5%B7%B4%E5%B7%B4/1.htm">阿里巴巴</a><a class="tag" taget="_blank" href="/search/spring/1.htm">spring</a><a class="tag" taget="_blank" href="/search/boot/1.htm">boot</a><a class="tag" taget="_blank" href="/search/intellij-idea/1.htm">intellij-idea</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/%E6%9C%8D%E5%8A%A1%E5%99%A8/1.htm">服务器</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a>
                        <div>文章目录一、SpringBoot是什么?二、使用idea创建SpringBoot项目1.使用idea的SpringInitiallizr创建项目2.初步配置3.编写简单代码及运行4.两个好玩的小东西总结一、SpringBoot是什么?Spring框架是Java平台上的一种开源应用框架,提供具有控制反转特性的容器。SpringBoot基于Spring4.0设计,不仅继承了Spring框架原有的优秀特</div>
                    </li>
                    <li><a href="/article/1883012536568180736.htm"
                           title="Web 应用服务器:Tomcat环境变量配置、Intellij idea配置Tomcat及运行JavaWeb项目测试" target="_blank">Web 应用服务器:Tomcat环境变量配置、Intellij idea配置Tomcat及运行JavaWeb项目测试</a>
                        <span class="text-muted">啊Q老师</span>
<a class="tag" taget="_blank" href="/search/Java%E5%BC%80%E5%8F%91%E6%8A%80%E6%9C%AF%E4%BB%8E%E9%9B%B6%E5%88%B0%E5%A3%B9/1.htm">Java开发技术从零到壹</a><a class="tag" taget="_blank" href="/search/%23/1.htm">#</a><a class="tag" taget="_blank" href="/search/JavaWeb%E7%AF%87/1.htm">JavaWeb篇</a><a class="tag" taget="_blank" href="/search/tomcat/1.htm">tomcat</a><a class="tag" taget="_blank" href="/search/%E6%9C%8D%E5%8A%A1%E5%99%A8/1.htm">服务器</a><a class="tag" taget="_blank" href="/search/intellij-idea/1.htm">intellij-idea</a>
                        <div>TomcatTomcat环境变量配置Intellijidea配置TomcatTomcat运行JavaWeb项目测试上篇文章中,我们简单地学习了Tomcat服务器简介、下载、安装及控制台中文乱码化脓性解决的内容,现在我们继续学习Tomcat的配置及测试。Tomcat环境变量配置首先,点击我的电脑—>属性—>高级系统设置—>环境变量(N)…,在系统变量中新建两个系统变量。变量名:CATALINA_BA</div>
                    </li>
                    <li><a href="/article/1883011906847961088.htm"
                           title="Springboot启动原理" target="_blank">Springboot启动原理</a>
                        <span class="text-muted">长乐_</span>
<a class="tag" taget="_blank" href="/search/%E7%9F%A5%E8%AF%86%E6%9D%82%E8%AE%B0/1.htm">知识杂记</a><a class="tag" taget="_blank" href="/search/spring/1.htm">spring</a><a class="tag" taget="_blank" href="/search/boot/1.htm">boot</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/spring/1.htm">spring</a>
                        <div>Springboot启动原理一、开始启动一个springboot项目,最简单的就是配置一个springboot启动类,然后运行即可@SpringBootApplicationpublicclassSpringBoot{publicstaticvoidmain(String[]args){SpringApplication.run(SpringBoot.class,args);}}二、@Spring</div>
                    </li>
                    <li><a href="/article/1883009510751137792.htm"
                           title="侯捷 C++ 课程学习笔记:开启 C++ 深度探索之旅" target="_blank">侯捷 C++ 课程学习笔记:开启 C++ 深度探索之旅</a>
                        <span class="text-muted">秃头小饼干</span>
<a class="tag" taget="_blank" href="/search/jvm/1.htm">jvm</a><a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E8%AF%AD%E8%A8%80/1.htm">开发语言</a><a class="tag" taget="_blank" href="/search/c%2B%2B/1.htm">c++</a>
                        <div>在C++的学习道路上,侯捷老师的课程宛如一座明亮的灯塔,为无数学习者照亮前行的方向。经过一段时间对侯捷C++课程的深入学习,我收获颇丰,在此将自己的学习笔记和感悟分享给大家,希望能对正在学习C++或者准备踏入C++领域的朋友们有所帮助。一、课程初印象初次接触侯捷老师的课程,就被其深入浅出的讲解风格所吸引。老师不仅有着深厚的技术功底,更具备出色的教学能力,能够将复杂的C++知识以通俗易懂的方式呈现出</div>
                    </li>
                    <li><a href="/article/1883008245639999488.htm"
                           title="Spring Boot 启动原理" target="_blank">Spring Boot 启动原理</a>
                        <span class="text-muted">Java大联盟</span>
<a class="tag" taget="_blank" href="/search/Spring/1.htm">Spring</a><a class="tag" taget="_blank" href="/search/Cloud/1.htm">Cloud</a><a class="tag" taget="_blank" href="/search/%E6%9E%81%E7%AE%80%E5%85%A5%E9%97%A8/1.htm">极简入门</a>
                        <div>SpringBoot自动配置原理通过上节课的学习,大家已经掌握了SpringBoot框架的基本使用,你会发现使用SpringBoot进行项目开发真的是非常简单,可以极大地提升开发效率。这是因为SpringBoot框架已经预先帮助开发者完成了各种自动配置,使得开发者可以将精力全部集中在业务代码的开发中,而非配置文件。SpringBoot最核心的功能简单概括就是四个字:自动配置,那么SpringBoo</div>
                    </li>
                    <li><a href="/article/1883007740037623808.htm"
                           title="引入正确依赖但还是爆红" target="_blank">引入正确依赖但还是爆红</a>
                        <span class="text-muted">笑发财了1</span>
<a class="tag" taget="_blank" href="/search/spring/1.htm">spring</a><a class="tag" taget="_blank" href="/search/boot/1.htm">boot</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/maven/1.htm">maven</a><a class="tag" taget="_blank" href="/search/spring/1.htm">spring</a><a class="tag" taget="_blank" href="/search/mybatis/1.htm">mybatis</a>
                        <div>springboot项目,maven工程。这个问题是我在成功运行这个项目后出现的,再次打开的时候居然又爆红了。尝试了clean和重编译也没用,于是尝试重新加载,就好了</div>
                    </li>
                    <li><a href="/article/1883003456462057472.htm"
                           title="ROS 实时修改动态参数的方法" target="_blank">ROS 实时修改动态参数的方法</a>
                        <span class="text-muted">jucat</span>
<a class="tag" taget="_blank" href="/search/ROS/1.htm">ROS</a><a class="tag" taget="_blank" href="/search/%E6%9C%BA%E5%99%A8%E4%BA%BA/1.htm">机器人</a><a class="tag" taget="_blank" href="/search/%E8%87%AA%E5%8A%A8%E9%A9%BE%E9%A9%B6/1.htm">自动驾驶</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a>
                        <div>参考HokuyoLaser动态参数设置wikiipa覆盖算法源码背景工作中需要在C++程序运行过程中,根据场景开关costmap2d的障碍物感知图层以及膨胀图层。在yaml启动参数配置中加载障碍物层插件和膨胀层插件,但是关闭它们的更新,大概如下:global_costmap:global_frame:maprobot_base_frame:base_footprint...plugins:-{na</div>
                    </li>
                    <li><a href="/article/1883002196316975104.htm"
                           title="【Python】红旗超市线下缴电费用户数据分析及可视化(pandas+pyecharts)" target="_blank">【Python】红旗超市线下缴电费用户数据分析及可视化(pandas+pyecharts)</a>
                        <span class="text-muted">风度78</span>
<a class="tag" taget="_blank" href="/search/%E7%99%BE%E5%BA%A6/1.htm">百度</a><a class="tag" taget="_blank" href="/search/%E4%BA%BA%E5%B7%A5%E6%99%BA%E8%83%BD/1.htm">人工智能</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/1.htm">机器学习</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90/1.htm">数据分析</a>
                        <div>场景分析:一部分用户习惯在红旗超市线下进行缴电费,电力公司希望了解哪些用户喜欢到线下缴费,具体分布在哪里,才能有针对性地宣传掌上电力app引导用户体验更高效的线上缴费方式,提升用户满意度。需求分析:首先要拿到红旗超市线下缴费清单数据,对所有数据进行隐私化处理,数据预览如图所示:可以看出台区名称为本项目的核心字段,通过台区匹配到经纬度信息,然后利用经纬度信息进行线下缴费热力图展示。同时可以提供分析报</div>
                    </li>
                    <li><a href="/article/1883001566143770624.htm"
                           title="springboot 启动原理" target="_blank">springboot 启动原理</a>
                        <span class="text-muted">chikoucha6215</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/runtime/1.htm">runtime</a><a class="tag" taget="_blank" href="/search/%E6%B5%8B%E8%AF%95/1.htm">测试</a>
                        <div>我们开发任何一个SpringBoot项目,都会用到如下的启动类@SpringBootApplicationpublicclassApplication{publicstaticvoidmain(String[]args){SpringApplication.run(Application.class,args);}}从上面代码可以看出,Annotation定义(@SpringBootApplica</div>
                    </li>
                    <li><a href="/article/1882998287124983808.htm"
                           title="C++实现设计模式---职责链模式 (Chain of Responsibility)" target="_blank">C++实现设计模式---职责链模式 (Chain of Responsibility)</a>
                        <span class="text-muted">计算机小混子</span>
<a class="tag" taget="_blank" href="/search/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/1.htm">设计模式</a><a class="tag" taget="_blank" href="/search/c%2B%2B/1.htm">c++</a><a class="tag" taget="_blank" href="/search/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/1.htm">设计模式</a><a class="tag" taget="_blank" href="/search/%E8%B4%A3%E4%BB%BB%E9%93%BE%E6%A8%A1%E5%BC%8F/1.htm">责任链模式</a>
                        <div>职责链模式(ChainofResponsibility)职责链模式是一种行为型设计模式,它允许多个对象都有机会处理请求,从而避免请求的发送者和接收者之间的耦合。这些对象通过形成一条链,沿着这条链传递请求,直到有对象处理它为止。意图通过将请求的发送者与接收者解耦,动态地决定由哪个对象来处理请求。使多个对象有机会处理请求,而不是由固定的对象处理。使用场景请求的处理者不确定:在运行时,可能需要多个对象来</div>
                    </li>
                    <li><a href="/article/1882997782059479040.htm"
                           title="【SpringBoot】SpringBoot:实现文件上传和下载功能" target="_blank">【SpringBoot】SpringBoot:实现文件上传和下载功能</a>
                        <span class="text-muted">E绵绵</span>
<a class="tag" taget="_blank" href="/search/Everything/1.htm">Everything</a><a class="tag" taget="_blank" href="/search/spring/1.htm">spring</a><a class="tag" taget="_blank" href="/search/boot/1.htm">boot</a><a class="tag" taget="_blank" href="/search/%E5%90%8E%E7%AB%AF/1.htm">后端</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a>
                        <div>文章目录引言项目初始化添加依赖配置文件存储位置实现文件上传功能创建文件上传控制器创建上传页面实现文件下载功能创建文件下载控制器安全性和最佳实践文件大小限制文件类型验证文件名和路径验证文件下载时的安全性测试与部署示例:编写单元测试部署结论引言文件上传和下载是Web应用程序中常见的需求。在现代应用中,用户需要上传各种类型的文件,如图片、文档、视频等,或者下载生成的报告和数据文件。SpringBoot通</div>
                    </li>
                    <li><a href="/article/1882996648972447744.htm"
                           title="IDEA tomcat启动项目" target="_blank">IDEA tomcat启动项目</a>
                        <span class="text-muted">Aa_duidui</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/intellij-idea/1.htm">intellij-idea</a><a class="tag" taget="_blank" href="/search/tomcat/1.htm">tomcat</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a>
                        <div>1.打开File中Settings2.搜索ApplicationServers,添加服务器类型,tomcat,选择本地的tomcat文件位置,点击OK3.搜索Plugins,在里面搜索tomcat,挑上钩4.idea打开多个项目点击idea侧面的Maven,点击加号,找到要添加项目的pom.xml项目是现成的,省略了文章的第5步</div>
                    </li>
                    <li><a href="/article/1882996396706033664.htm"
                           title="基于Python的天气数据可视化平台" target="_blank">基于Python的天气数据可视化平台</a>
                        <span class="text-muted">q.q 1102255374</span>
<a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E4%BF%A1%E6%81%AF%E5%8F%AF%E8%A7%86%E5%8C%96/1.htm">信息可视化</a><a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E8%AF%AD%E8%A8%80/1.htm">开发语言</a>
                        <div>摘要:随着社会多元化的不断发展,天气数据问题不可被简单的理解为是科学问题,更多的是环境问题,可以直接影响到人民的日常生活,甚至对一个国家的政治经济带来影响,由此可见,天气预测是一项非常重要的行业。基于此,我们就需要开发一个可视化的、综合的、方便人们查看的项目。基于Python的天气数据可视化设计与实现,通过使用基于Python的网络爬虫技术,能在短时内提取有价值的信息数据。然后根据数据的形式进行整</div>
                    </li>
                    <li><a href="/article/1882994884038684672.htm"
                           title="【SpringBoot 框架】- SpringBoot 配置文件" target="_blank">【SpringBoot 框架】- SpringBoot 配置文件</a>
                        <span class="text-muted">2401_84408404</span>
<a class="tag" taget="_blank" href="/search/%E7%A8%8B%E5%BA%8F%E5%91%98/1.htm">程序员</a><a class="tag" taget="_blank" href="/search/spring/1.htm">spring</a><a class="tag" taget="_blank" href="/search/boot/1.htm">boot</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/spring/1.htm">spring</a>
                        <div>【SpringBoot框架】-入门——环境搭建、工程热部署、idea快捷创建SpringBoot项目【SpringBoot框架】-SpringBoot原理分析【SpringBoot框架】-SpringBoot配置文件【SpringBoot框架】-SpringBoot整合Mybatis、Junit、Redis目录一、SpringBoot配置文件类型1.application.properties配置</div>
                    </li>
                    <li><a href="/article/1882993244787240960.htm"
                           title="华为OD机试E卷 --连续字母长度--24年OD统一考试(Java & JS & Python & C & C++)" target="_blank">华为OD机试E卷 --连续字母长度--24年OD统一考试(Java & JS & Python & C & C++)</a>
                        <span class="text-muted">飞码创造者</span>
<a class="tag" taget="_blank" href="/search/%E6%9C%80%E6%96%B0%E5%8D%8E%E4%B8%BAOD%E6%9C%BA%E8%AF%95%E9%A2%98%E5%BA%932024/1.htm">最新华为OD机试题库2024</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E5%8D%8E%E4%B8%BAod/1.htm">华为od</a><a class="tag" taget="_blank" href="/search/javascript/1.htm">javascript</a><a class="tag" taget="_blank" href="/search/c%E8%AF%AD%E8%A8%80/1.htm">c语言</a>
                        <div>文章目录题目描述输入描述输出描述用例题目解析JS算法源码Java算法源码python算法源码c算法源码c++算法源码题目描述给定一个字符串,只包含大写字母,求在包含同一字母的子串中,长度第k长的子串的长度,相同字母只取最长的那个子串。输入描述第一行有一个子串(1<长度<=100),只包含大写字母。第二行为k的值输出描述输出连续出现次数第k多的字母的次数。用例输入AAAAHHHBBCDHHHH3输出</div>
                    </li>
                    <li><a href="/article/1882988201686134784.htm"
                           title="Python3 字典:解锁高效数据存储的钥匙" target="_blank">Python3 字典:解锁高效数据存储的钥匙</a>
                        <span class="text-muted">李智 - 重庆</span>
<a class="tag" taget="_blank" href="/search/Python/1.htm">Python</a><a class="tag" taget="_blank" href="/search/%E7%B2%BE%E8%AE%B2%E7%B2%BE%E7%BB%83/1.htm">精讲精练</a><a class="tag" taget="_blank" href="/search/-/1.htm">-</a><a class="tag" taget="_blank" href="/search/%E4%BB%8E%E5%85%A5%E9%97%A8%E5%88%B0%E5%AE%9E%E6%88%98/1.htm">从入门到实战</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E7%BB%8F%E9%AA%8C%E5%88%86%E4%BA%AB/1.htm">经验分享</a><a class="tag" taget="_blank" href="/search/%E7%BC%96%E7%A8%8B%E5%AE%9E%E6%88%98/1.htm">编程实战</a><a class="tag" taget="_blank" href="/search/%E8%B6%A3%E5%91%B3%E7%BC%96%E7%A8%8B/1.htm">趣味编程</a><a class="tag" taget="_blank" href="/search/%E7%BC%96%E7%A8%8B%E6%8A%80%E5%B7%A7/1.htm">编程技巧</a>
                        <div>Python3字典:解锁高效数据存储的钥匙内容简介本系列文章是为Python3学习者精心设计的一套全面、实用的学习指南,旨在帮助读者从基础入门到项目实战,全面提升编程能力。文章结构由5个版块组成,内容层层递进,逻辑清晰。基础速通:n个浓缩提炼的核心知识点,夯实编程基础;经典范例:10个贴近实际的应用场景,深入理解Python3的编程技巧和应用方法;避坑宝典:10个典型错误解析,提供解决方案,帮助读</div>
                    </li>
                    <li><a href="/article/1882983790423371776.htm"
                           title="Windows10环境下使用docker部署Dify" target="_blank">Windows10环境下使用docker部署Dify</a>
                        <span class="text-muted">南南的sky</span>
<a class="tag" taget="_blank" href="/search/%E5%AE%B9%E5%99%A8/1.htm">容器</a><a class="tag" taget="_blank" href="/search/%E8%BF%90%E7%BB%B4/1.htm">运维</a><a class="tag" taget="_blank" href="/search/AIGC/1.htm">AIGC</a>
                        <div>前言最近带教导师让使用dify做一些工程项目,我在此之前没用过dify,也不知道怎么部署,便花了些时间研究了一下,这篇博客的主要目的是记录如何在windows10系统上使用docker部署dify,碰到了哪些问题以及解决方案。什么是DifyDify是一款开源的大语言模型(LLM)应用开发平台。它融合了后端即服务(BackendasService)和LLMOps的理念,使开发者可以快速搭建生产级的生</div>
                    </li>
                    <li><a href="/article/1882983160799621120.htm"
                           title="(c/c++)——C++和python的异常处理" target="_blank">(c/c++)——C++和python的异常处理</a>
                        <span class="text-muted">想要躺平的一枚</span>
<a class="tag" taget="_blank" href="/search/C%2B%2B/1.htm">C++</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/c%E8%AF%AD%E8%A8%80/1.htm">c语言</a><a class="tag" taget="_blank" href="/search/c%2B%2B/1.htm">c++</a>
                        <div>目录一、C++的异常处理二、python的异常处理——自定义异常一、C++的异常处理C++中选择用throw来抛出异常,catch来捕捉异常和处理try{//可能发生异常的语句//throw异常对象}catch(类型1){//发生类型1异常时的处理代码}catch(类型2){//发生类型2异常时的处理代码}catch(...){//不管什么异常,都在这里统一处理。}throw抛出异常对象,异常对象</div>
                    </li>
                    <li><a href="/article/1882981520575098880.htm"
                           title="java版在线评标 竞标 邀标 评审专家 招标公告发布招投标系统源码" target="_blank">java版在线评标 竞标 邀标 评审专家 招标公告发布招投标系统源码</a>
                        <span class="text-muted">m0_72864708</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a>
                        <div>功能描述1、门户管理:所有用户可在门户页面查看所有的公告信息及相关的通知信息。主要板块包含:招标公告、非招标公告、系统通知、政策法规。2、立项管理:企业用户可对需要采购的项目进行立项申请,并提交审批,查看所有的立项信息。主要功能包含:招标立项申请、非招标立项申请、采购立项管理。3、采购项目管理:可对项目采购过程全流程管理,包含功能有:评审人员的选取/抽取、基准价维护、供应商缴费审核、投标过程记录查</div>
                    </li>
                    <li><a href="/article/1882979704579878912.htm"
                           title="springboot+vue项目实战2024第三集修改用户信息" target="_blank">springboot+vue项目实战2024第三集修改用户信息</a>
                        <span class="text-muted"></span>
<a class="tag" taget="_blank" href="/search/javaspringboot/1.htm">javaspringboot</a>
                        <div>1.获取用户信息@GetMapping("/userInfo")//@RequestHeader(name="Authorization")StringtokenpublicResultuserInfo(){//Mapmap=JwtUtil.parseToken(token);Mapmap=ThreadLocalUtil.get();Stringusername=(String)map.get("</div>
                    </li>
                    <li><a href="/article/1882978615868583936.htm"
                           title="【自动化】使用PlayWright+代理IP实现多环境隔离" target="_blank">【自动化】使用PlayWright+代理IP实现多环境隔离</a>
                        <span class="text-muted">青塬科技</span>
<a class="tag" taget="_blank" href="/search/Python/1.htm">Python</a>
                        <div>Playwright是由微软公司2020年初发布的新一代自动化测试工具,相较于目前最常用的Selenium,它仅用一个API即可自动执行Chromium、Firefox、WebKit等主流浏览器自动化操作。对各种开发语言也有非常好的支持。常用的NodeJs、Java、python都有支持,且有丰富的文档参考。Python环境下的安装使用1、安装依赖库pipinstallplaywright2、安装</div>
                    </li>
                    <li><a href="/article/1882978236195991552.htm"
                           title="ESP32-C3入门教程 环境篇③——VS Code IDE快速入门" target="_blank">ESP32-C3入门教程 环境篇③——VS Code IDE快速入门</a>
                        <span class="text-muted">小康师兄</span>
<a class="tag" taget="_blank" href="/search/ESP32-C3%E5%85%A5%E9%97%A8%E6%95%99%E7%A8%8B/1.htm">ESP32-C3入门教程</a><a class="tag" taget="_blank" href="/search/VS/1.htm">VS</a><a class="tag" taget="_blank" href="/search/Code/1.htm">Code</a><a class="tag" taget="_blank" href="/search/ESP32-C3/1.htm">ESP32-C3</a><a class="tag" taget="_blank" href="/search/ESP32/1.htm">ESP32</a><a class="tag" taget="_blank" href="/search/%E5%B5%8C%E5%85%A5%E5%BC%8F/1.htm">嵌入式</a><a class="tag" taget="_blank" href="/search/%E7%89%A9%E8%81%94%E7%BD%91/1.htm">物联网</a>
                        <div>文章目录一、安装VisualStudioCode二、安装扩展三、配置ESP-IDF插件四、创建工程五、配置工程5.1选择目标芯片5.2项目配置方法一方法二六、编译工程6.1方法一6.2方法二七、固件分析八、固件下载8.1方法一8.2方法二8.3方法三九、串口日志9.1方法一9.2方法二十、遇到问题及解决10.1restartVisualStudioCodeandrunthiswizardagain</div>
                    </li>
                    <li><a href="/article/1882975424523333632.htm"
                           title="并发控制-文件锁" target="_blank">并发控制-文件锁</a>
                        <span class="text-muted"></span>
<a class="tag" taget="_blank" href="/search/gophp%E9%AB%98%E5%B9%B6%E5%8F%91/1.htm">gophp高并发</a>
                        <div>在以往的项目中,遇到高并发大流量需求做并发控制的时候一般都使用redis分布式锁或者mysql加锁处理高并发情况。最近遇到一个php项目,没有安装redis,由于某种原因也不考虑使用mysql加锁控制并发,所以采用文件锁的方式控制并发,整理了下代码php版本classFileLock{/**@varstring锁名称唯一性*/privatestring$key;/**@varstring锁文件*/</div>
                    </li>
                    <li><a href="/article/1882975297410756608.htm"
                           title="工程项目管理流程示意图" target="_blank">工程项目管理流程示意图</a>
                        <span class="text-muted"></span>
<a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E5%8F%AF%E8%A7%86%E5%8C%96/1.htm">数据可视化</a>
                        <div>  借助图形天下强大的关系数据可视化技术,该流程图清晰地展示了工程项目从立项到结束的完整流程。从开始的立项、文档评审,到工程量清单、价格咨询,再到招投标、签订合同、开展工程,直至最后的结算和收尾工作,每一环节都紧密相连,通过直观的图形展示,使得复杂的关系数据可视化,便于理解和管理整个项目流程。                  工程项目管理流程示意图  这一流程不仅确保了项目的顺利推进,还有效监控</div>
                    </li>
                    <li><a href="/article/1882972816203116544.htm"
                           title="Alibaba Spring Cloud 十三 Nacos,Gateway,Nginx 部署架构与负载均衡方案" target="_blank">Alibaba Spring Cloud 十三 Nacos,Gateway,Nginx 部署架构与负载均衡方案</a>
                        <span class="text-muted">空灵宫(Ethereal Palace)</span>
<a class="tag" taget="_blank" href="/search/Alibaba/1.htm">Alibaba</a><a class="tag" taget="_blank" href="/search/Spring/1.htm">Spring</a><a class="tag" taget="_blank" href="/search/Cloud/1.htm">Cloud</a><a class="tag" taget="_blank" href="/search/spring/1.htm">spring</a><a class="tag" taget="_blank" href="/search/cloud/1.htm">cloud</a><a class="tag" taget="_blank" href="/search/gateway/1.htm">gateway</a><a class="tag" taget="_blank" href="/search/nginx/1.htm">nginx</a>
                        <div>在微服务体系中,Nacos主要承担“服务注册与发现、配置中心”的职能,Gateway(如SpringCloudGateway)通常负责“路由转发、过滤、安全鉴权、灰度流量控制”等功能,而Nginx则常被用作“边缘反向代理”或“统一流量入口”。在实际项目里,这三者经常组合使用,以实现高扩展、高可用、可观测且灵活的流量调度。一、Nacos+Gateway+Nginx的常见部署架构一般来说,可以把Ngi</div>
                    </li>
                    <li><a href="/article/1882965759341162496.htm"
                           title="航空客户价值的数据挖掘与分析(numpy+pandas+matplotlib+scikit-learn)" target="_blank">航空客户价值的数据挖掘与分析(numpy+pandas+matplotlib+scikit-learn)</a>
                        <span class="text-muted">Want595</span>
<a class="tag" taget="_blank" href="/search/Python%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90/1.htm">Python数据分析</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E6%8C%96%E6%8E%98/1.htm">数据挖掘</a><a class="tag" taget="_blank" href="/search/numpy/1.htm">numpy</a><a class="tag" taget="_blank" href="/search/pandas/1.htm">pandas</a>
                        <div>文章目录航空客户价值的数据挖掘与分析(numpy+pandas+matplotlib+scikit-learn)写在前面背景与挖掘目标1.1需求背景1.2挖掘目标1.3项目概述项目分析方法规划2.1RFM模型2.2LRFMC模型指标2.3分析总体流程图数据抽取探索及预处理3.1数据抽取3.2数据探索分析3.3数据预处理3.3.1数据清洗3.3.2属性规约3.3.3数据变换数据建模&应用4.1模型构</div>
                    </li>
                    <li><a href="/article/1882962862050177024.htm"
                           title="ROS VScode 使用笔记" target="_blank">ROS VScode 使用笔记</a>
                        <span class="text-muted">zhanglianzhao</span>
<a class="tag" taget="_blank" href="/search/%E6%9C%BA%E5%99%A8%E4%BA%BA%E6%8A%80%E6%9C%AF%E5%9F%BA%E7%A1%80/1.htm">机器人技术基础</a><a class="tag" taget="_blank" href="/search/c%2B%2B/1.htm">c++</a><a class="tag" taget="_blank" href="/search/vscode/1.htm">vscode</a>
                        <div>ROSVScode使用笔记编译快捷方式修改功能包下CMakeList.txt136行和149-151行程序如果C++文件返回的日志信息乱码,可以在程序main中开头添加下面内容在写C++程序时如果不能自动提示,需要在.vscode目录下的c_cpp_properties.json文件中的name下一行添加下面代码编译快捷方式Ctrl+Shift+B,选择第二个的小齿轮,将以下代码替换掉原先内容,保</div>
                    </li>
                                <li><a href="/article/35.htm"
                                       title="JVM StackMapTable 属性的作用及理解" target="_blank">JVM StackMapTable 属性的作用及理解</a>
                                    <span class="text-muted">lijingyao8206</span>
<a class="tag" taget="_blank" href="/search/jvm/1.htm">jvm</a><a class="tag" taget="_blank" href="/search/%E5%AD%97%E8%8A%82%E7%A0%81/1.htm">字节码</a><a class="tag" taget="_blank" href="/search/Class%E6%96%87%E4%BB%B6/1.htm">Class文件</a><a class="tag" taget="_blank" href="/search/StackMapTable/1.htm">StackMapTable</a>
                                    <div>  
      在Java 6版本之后JVM引入了栈图(Stack Map Table)概念。为了提高验证过程的效率,在字节码规范中添加了Stack Map Table属性,以下简称栈图,其方法的code属性中存储了局部变量和操作数的类型验证以及字节码的偏移量。也就是一个method需要且仅对应一个Stack Map Table。在Java 7版</div>
                                </li>
                                <li><a href="/article/162.htm"
                                       title="回调函数调用方法" target="_blank">回调函数调用方法</a>
                                    <span class="text-muted">百合不是茶</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a>
                                    <div>最近在看大神写的代码时,.发现其中使用了很多的回调 ,以前只是在学习的时候经常用到 ,现在写个笔记 记录一下 
  
代码很简单: 
    
      MainDemo  :调用方法  得到方法的返回结果 
   
     </div>
                                </li>
                                <li><a href="/article/289.htm"
                                       title="[时间机器]制造时间机器需要一些材料" target="_blank">[时间机器]制造时间机器需要一些材料</a>
                                    <span class="text-muted">comsci</span>
<a class="tag" taget="_blank" href="/search/%E5%88%B6%E9%80%A0/1.htm">制造</a>
                                    <div>      根据我的计算和推测,要完全实现制造一台时间机器,需要某些我们这个世界不存在的物质 
    和材料... 
 
      甚至可以这样说,这种材料和物质,我们在反应堆中也无法获得...... 
 
     </div>
                                </li>
                                <li><a href="/article/416.htm"
                                       title="开口埋怨不如闭口做事" target="_blank">开口埋怨不如闭口做事</a>
                                    <span class="text-muted">邓集海</span>
<a class="tag" taget="_blank" href="/search/%E9%82%93%E9%9B%86%E6%B5%B7+%E5%81%9A%E4%BA%BA+%E5%81%9A%E4%BA%8B+%E5%B7%A5%E4%BD%9C/1.htm">邓集海 做人 做事 工作</a>
                                    <div>“开口埋怨,不如闭口做事。”不是名人名言,而是一个普通父亲对儿子的训导。但是,因为这句训导,这位普通父亲却造就了一个名人儿子。这位普通父亲造就的名人儿子,叫张明正。      张明正出身贫寒,读书时成绩差,常挨老师批评。高中毕业,张明正连普通大学的分数线都没上。高考成绩出来后,平时开口怨这怨那的张明正,不从自身找原因,而是不停地埋怨自己家庭条件不好、埋怨父母没有给他创造良好的学习环境。      </div>
                                </li>
                                <li><a href="/article/543.htm"
                                       title="jQuery插件开发全解析,类级别与对象级别开发" target="_blank">jQuery插件开发全解析,类级别与对象级别开发</a>
                                    <span class="text-muted">IT独行者</span>
<a class="tag" taget="_blank" href="/search/jquery/1.htm">jquery</a><a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91/1.htm">开发</a><a class="tag" taget="_blank" href="/search/%E6%8F%92%E4%BB%B6%E3%80%80/1.htm">插件 </a><a class="tag" taget="_blank" href="/search/%E5%87%BD%E6%95%B0/1.htm">函数</a>
                                    <div>jQuery插件的开发包括两种:   一种是类级别的插件开发,即给 
jQuery添加新的全局函数,相当于给 
jQuery类本身添加方法。 
jQuery的全局函数就是属于 
jQuery命名空间的函数,另一种是对象级别的插件开发,即给 
jQuery对象添加方法。下面就两种函数的开发做详细的说明。  
   
1 
、类级别的插件开发   类级别的插件开发最直接的理解就是给jQuer</div>
                                </li>
                                <li><a href="/article/670.htm"
                                       title="Rome解析Rss" target="_blank">Rome解析Rss</a>
                                    <span class="text-muted">413277409</span>
<a class="tag" taget="_blank" href="/search/Rome%E8%A7%A3%E6%9E%90Rss/1.htm">Rome解析Rss</a>
                                    <div>import java.net.URL;  
import java.util.List;  
  
import org.junit.Test;  
  
import com.sun.syndication.feed.synd.SyndCategory;  
import com.sun.syndication.feed.synd.S</div>
                                </li>
                                <li><a href="/article/797.htm"
                                       title="RSA加密解密" target="_blank">RSA加密解密</a>
                                    <span class="text-muted">无量</span>
<a class="tag" taget="_blank" href="/search/%E5%8A%A0%E5%AF%86/1.htm">加密</a><a class="tag" taget="_blank" href="/search/%E8%A7%A3%E5%AF%86/1.htm">解密</a><a class="tag" taget="_blank" href="/search/rsa/1.htm">rsa</a>
                                    <div>RSA加密解密代码 
 
代码有待整理 
 
 
package com.tongbanjie.commons.util;


import java.security.Key;

import java.security.KeyFactory;

import java.security.KeyPair;

import java.security.KeyPairGenerat</div>
                                </li>
                                <li><a href="/article/924.htm"
                                       title="linux 软件安装遇到的问题" target="_blank">linux 软件安装遇到的问题</a>
                                    <span class="text-muted">aichenglong</span>
<a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/%E9%81%87%E5%88%B0%E7%9A%84%E9%97%AE%E9%A2%98/1.htm">遇到的问题</a><a class="tag" taget="_blank" href="/search/ftp/1.htm">ftp</a>
                                    <div>1 ftp配置中遇到的问题 
   500 OOPS: cannot change directory 
  出现该问题的原因:是SELinux安装机制的问题.只要disable SELinux就可以了 
  修改方法:1 修改/etc/selinux/config 中SELINUX=disabled 
    2 source /etc</div>
                                </li>
                                <li><a href="/article/1051.htm"
                                       title="面试心得" target="_blank">面试心得</a>
                                    <span class="text-muted">alafqq</span>
<a class="tag" taget="_blank" href="/search/%E9%9D%A2%E8%AF%95/1.htm">面试</a>
                                    <div>最近面试了好几家公司。记录下; 
支付宝,面试我的人胖胖的,看着人挺好的;博彦外包的职位,面试失败; 
阿里金融,面试官人也挺和善,只不过我让他吐血了。。。 
由于印象比较深,记录下; 
1,自我介绍 
2,说下八种基本类型;(算上string。楼主才答了3种,哈哈,string其实不是基本类型,是引用类型) 
3,什么是包装类,包装类的优点; 
4,平时看过什么书?NND,什么书都没看过。。照样</div>
                                </li>
                                <li><a href="/article/1178.htm"
                                       title="java的多态性探讨" target="_blank">java的多态性探讨</a>
                                    <span class="text-muted">百合不是茶</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a>
                                    <div>java的多态性是指main方法在调用属性的时候类可以对这一属性做出反应的情况 
//package 1;
class A{

    public void test(){
       System.out.println("A");
  }
}

class D extends A{

    public void test(){
       S</div>
                                </li>
                                <li><a href="/article/1305.htm"
                                       title="网络编程基础篇之JavaScript-学习笔记" target="_blank">网络编程基础篇之JavaScript-学习笔记</a>
                                    <span class="text-muted">bijian1013</span>
<a class="tag" taget="_blank" href="/search/JavaScript/1.htm">JavaScript</a>
                                    <div>1.documentWrite 
<html>
<head>
    <script language="JavaScript">
         document.write("这是电脑网络学校");
         document.close();
    </script>
</h</div>
                                </li>
                                <li><a href="/article/1432.htm"
                                       title="探索JUnit4扩展:深入Rule" target="_blank">探索JUnit4扩展:深入Rule</a>
                                    <span class="text-muted">bijian1013</span>
<a class="tag" taget="_blank" href="/search/JUnit/1.htm">JUnit</a><a class="tag" taget="_blank" href="/search/Rule/1.htm">Rule</a><a class="tag" taget="_blank" href="/search/%E5%8D%95%E5%85%83%E6%B5%8B%E8%AF%95/1.htm">单元测试</a>
                                    <div>        本文将进一步探究Rule的应用,展示如何使用Rule来替代@BeforeClass,@AfterClass,@Before和@After的功能。 
        在上一篇中提到,可以使用Rule替代现有的大部分Runner扩展,而且也不提倡对Runner中的withBefores(),withAfte</div>
                                </li>
                                <li><a href="/article/1559.htm"
                                       title="[CSS]CSS浮动十五条规则" target="_blank">[CSS]CSS浮动十五条规则</a>
                                    <span class="text-muted">bit1129</span>
<a class="tag" taget="_blank" href="/search/css/1.htm">css</a>
                                    <div>这些浮动规则,主要是参考CSS权威指南关于浮动规则的总结,然后添加一些简单的例子以验证和理解这些规则。 
  
1. 所有的页面元素都可以浮动 2. 一个元素浮动后,会成为块级元素,比如<span>,a, strong等都会变成块级元素 3.一个元素左浮动,会向最近的块级父元素的左上角移动,直到浮动元素的左外边界碰到块级父元素的左内边界;如果这个块级父元素已经有浮动元素停靠了</div>
                                </li>
                                <li><a href="/article/1686.htm"
                                       title="【Kafka六】Kafka Producer和Consumer多Broker、多Partition场景" target="_blank">【Kafka六】Kafka Producer和Consumer多Broker、多Partition场景</a>
                                    <span class="text-muted">bit1129</span>
<a class="tag" taget="_blank" href="/search/partition/1.htm">partition</a>
                                    <div>0.Kafka服务器配置 
3个broker 
1个topic,6个partition,副本因子是2 
2个consumer,每个consumer三个线程并发读取 
  1. Producer 
package kafka.examples.multibrokers.producers;

import java.util.Properties;
import java.util.</div>
                                </li>
                                <li><a href="/article/1813.htm"
                                       title="zabbix_agentd.conf配置文件详解" target="_blank">zabbix_agentd.conf配置文件详解</a>
                                    <span class="text-muted">ronin47</span>
<a class="tag" taget="_blank" href="/search/zabbix+%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6/1.htm">zabbix 配置文件</a>
                                    <div>Aliaskey的别名,例如 Alias=ttlsa.userid:vfs.file.regexp[/etc/passwd,^ttlsa:.:([0-9]+),,,,\1], 或者ttlsa的用户ID。你可以使用key:vfs.file.regexp[/etc/passwd,^ttlsa:.: ([0-9]+),,,,\1],也可以使用ttlsa.userid。备注: 别名不能重复,但是可以有多个</div>
                                </li>
                                <li><a href="/article/1940.htm"
                                       title="java--19.用矩阵求Fibonacci数列的第N项" target="_blank">java--19.用矩阵求Fibonacci数列的第N项</a>
                                    <span class="text-muted">bylijinnan</span>
<a class="tag" taget="_blank" href="/search/fibonacci/1.htm">fibonacci</a>
                                    <div>参考了网上的思路,写了个Java版的: 
 
 



public class Fibonacci {

	final  static int[] A={1,1,1,0};
	
	
	public static void main(String[] args) {
		int n=7;
		for(int i=0;i<=n;i++){
			int f=fibonac</div>
                                </li>
                                <li><a href="/article/2067.htm"
                                       title="Netty源码学习-LengthFieldBasedFrameDecoder" target="_blank">Netty源码学习-LengthFieldBasedFrameDecoder</a>
                                    <span class="text-muted">bylijinnan</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/netty/1.htm">netty</a>
                                    <div>先看看LengthFieldBasedFrameDecoder的官方API 
 
http://docs.jboss.org/netty/3.1/api/org/jboss/netty/handler/codec/frame/LengthFieldBasedFrameDecoder.html 
 
API举例说明了LengthFieldBasedFrameDecoder的解析机制,如下: 
 
实</div>
                                </li>
                                <li><a href="/article/2194.htm"
                                       title="AES加密解密" target="_blank">AES加密解密</a>
                                    <span class="text-muted">chicony</span>
<a class="tag" taget="_blank" href="/search/%E5%8A%A0%E5%AF%86%E8%A7%A3%E5%AF%86/1.htm">加密解密</a>
                                    <div>AES加解密算法,使用Base64做转码以及辅助加密: 
package com.wintv.common;

import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;

import sun.misc.BASE64Decod</div>
                                </li>
                                <li><a href="/article/2321.htm"
                                       title="文件编码格式转换" target="_blank">文件编码格式转换</a>
                                    <span class="text-muted">ctrain</span>
<a class="tag" taget="_blank" href="/search/%E7%BC%96%E7%A0%81%E6%A0%BC%E5%BC%8F/1.htm">编码格式</a>
                                    <div>
package com.test;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
</div>
                                </li>
                                <li><a href="/article/2448.htm"
                                       title="mysql 在linux客户端插入数据中文乱码" target="_blank">mysql 在linux客户端插入数据中文乱码</a>
                                    <span class="text-muted">daizj</span>
<a class="tag" taget="_blank" href="/search/mysql/1.htm">mysql</a><a class="tag" taget="_blank" href="/search/%E4%B8%AD%E6%96%87%E4%B9%B1%E7%A0%81/1.htm">中文乱码</a>
                                    <div>1、查看系统客户端,数据库,连接层的编码 
 查看方法: http://daizj.iteye.com/blog/2174993 
进入mysql,通过如下命令查看数据库编码方式: mysql>  show variables like 'character_set_%'; +--------------------------+------</div>
                                </li>
                                <li><a href="/article/2575.htm"
                                       title="好代码是廉价的代码" target="_blank">好代码是廉价的代码</a>
                                    <span class="text-muted">dcj3sjt126com</span>
<a class="tag" taget="_blank" href="/search/%E7%A8%8B%E5%BA%8F%E5%91%98/1.htm">程序员</a><a class="tag" taget="_blank" href="/search/%E8%AF%BB%E4%B9%A6/1.htm">读书</a>
                                    <div>  
长久以来我一直主张:好代码是廉价的代码。 
当我跟做开发的同事说出这话时,他们的第一反应是一种惊愕,然后是将近一个星期的嘲笑,把它当作一个笑话来讲。 当他们走近看我的表情、知道我是认真的时,才收敛一点。 
当最初的惊愕消退后,他们会用一些这样的话来反驳: “好代码不廉价,好代码是采用经过数十年计算机科学研究和积累得出的最佳实践设计模式和方法论建立起来的精心制作的程序代码。” 
我只</div>
                                </li>
                                <li><a href="/article/2702.htm"
                                       title="Android网络请求库——android-async-http" target="_blank">Android网络请求库——android-async-http</a>
                                    <span class="text-muted">dcj3sjt126com</span>
<a class="tag" taget="_blank" href="/search/android/1.htm">android</a>
                                    <div>在iOS开发中有大名鼎鼎的ASIHttpRequest库,用来处理网络请求操作,今天要介绍的是一个在Android上同样强大的网络请求库android-async-http,目前非常火的应用Instagram和Pinterest的Android版就是用的这个网络请求库。这个网络请求库是基于Apache HttpClient库之上的一个异步网络请求处理库,网络处理均基于Android的非UI线程,通</div>
                                </li>
                                <li><a href="/article/2829.htm"
                                       title="ORACLE 复习笔记之SQL语句的优化" target="_blank">ORACLE 复习笔记之SQL语句的优化</a>
                                    <span class="text-muted">eksliang</span>
<a class="tag" taget="_blank" href="/search/SQL%E4%BC%98%E5%8C%96/1.htm">SQL优化</a><a class="tag" taget="_blank" href="/search/Oracle+sql%E8%AF%AD%E5%8F%A5%E4%BC%98%E5%8C%96/1.htm">Oracle sql语句优化</a><a class="tag" taget="_blank" href="/search/SQL%E8%AF%AD%E5%8F%A5%E7%9A%84%E4%BC%98%E5%8C%96/1.htm">SQL语句的优化</a>
                                    <div>转载请出自出处:http://eksliang.iteye.com/blog/2097999 
  SQL语句的优化总结如下 
  
sql语句的优化可以按照如下六个步骤进行: 
 
 合理使用索引 
 避免或者简化排序 
 消除对大表的扫描 
 避免复杂的通配符匹配 
 调整子查询的性能 
 EXISTS和IN运算符 
 
下面我就按照上面这六个步骤分别进行总结: </div>
                                </li>
                                <li><a href="/article/2956.htm"
                                       title="浅析:Android 嵌套滑动机制(NestedScrolling)" target="_blank">浅析:Android 嵌套滑动机制(NestedScrolling)</a>
                                    <span class="text-muted">gg163</span>
<a class="tag" taget="_blank" href="/search/android/1.htm">android</a><a class="tag" taget="_blank" href="/search/%E7%A7%BB%E5%8A%A8%E5%BC%80%E5%8F%91/1.htm">移动开发</a><a class="tag" taget="_blank" href="/search/%E6%BB%91%E5%8A%A8%E6%9C%BA%E5%88%B6/1.htm">滑动机制</a><a class="tag" taget="_blank" href="/search/%E5%B5%8C%E5%A5%97/1.htm">嵌套</a>
                                    <div>谷歌在发布安卓 Lollipop版本之后,为了更好的用户体验,Google为Android的滑动机制提供了NestedScrolling特性 
NestedScrolling的特性可以体现在哪里呢?<!--[if !supportLineBreakNewLine]--><!--[endif]--> 
比如你使用了Toolbar,下面一个ScrollView,向上滚</div>
                                </li>
                                <li><a href="/article/3083.htm"
                                       title="使用hovertree菜单作为后台导航" target="_blank">使用hovertree菜单作为后台导航</a>
                                    <span class="text-muted">hvt</span>
<a class="tag" taget="_blank" href="/search/JavaScript/1.htm">JavaScript</a><a class="tag" taget="_blank" href="/search/jquery/1.htm">jquery</a><a class="tag" taget="_blank" href="/search/.net/1.htm">.net</a><a class="tag" taget="_blank" href="/search/hovertree/1.htm">hovertree</a><a class="tag" taget="_blank" href="/search/asp.net/1.htm">asp.net</a>
                                    <div>  
hovertree是一个jquery菜单插件,官方网址:http://keleyi.com/jq/hovertree/ ,可以登录该网址体验效果。 
0.1.3版本:http://keleyi.com/jq/hovertree/demo/demo.0.1.3.htm 
hovertree插件包含文件: 
http://keleyi.com/jq/hovertree/css</div>
                                </li>
                                <li><a href="/article/3210.htm"
                                       title="SVG 教程 (二)矩形" target="_blank">SVG 教程 (二)矩形</a>
                                    <span class="text-muted">天梯梦</span>
<a class="tag" taget="_blank" href="/search/svg/1.htm">svg</a>
                                    <div>SVG <rect>   SVG Shapes 
SVG有一些预定义的形状元素,可被开发者使用和操作: 
 
 矩形 <rect> 
 圆形 <circle> 
 椭圆 <ellipse> 
 线 <line> 
 折线 <polyline> 
 多边形 <polygon> 
 路径 <path> 
 </div>
                                </li>
                                <li><a href="/article/3337.htm"
                                       title="一个简单的队列" target="_blank">一个简单的队列</a>
                                    <span class="text-muted">luyulong</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/1.htm">数据结构</a><a class="tag" taget="_blank" href="/search/%E9%98%9F%E5%88%97/1.htm">队列</a>
                                    <div>
public class MyQueue {
	private long[] arr;

	private int front;

	private int end;
	// 有效数据的大小
	private int elements;

	public MyQueue() {
		arr = new long[10];
		elements = 0;
		front </div>
                                </li>
                                <li><a href="/article/3464.htm"
                                       title="基础数据结构和算法九:Binary Search Tree" target="_blank">基础数据结构和算法九:Binary Search Tree</a>
                                    <span class="text-muted">sunwinner</span>
<a class="tag" taget="_blank" href="/search/Algorithm/1.htm">Algorithm</a>
                                    <div>  
A binary search tree (BST) is a binary tree where each node has a Comparable key (and an associated value) and satisfies the restriction that the key in any node is larger than the keys in all</div>
                                </li>
                                <li><a href="/article/3591.htm"
                                       title="项目出现的一些问题和体会" target="_blank">项目出现的一些问题和体会</a>
                                    <span class="text-muted">Steven-Walker</span>
<a class="tag" taget="_blank" href="/search/DAO/1.htm">DAO</a><a class="tag" taget="_blank" href="/search/Web/1.htm">Web</a><a class="tag" taget="_blank" href="/search/servlet/1.htm">servlet</a>
                                    <div>     第一篇博客不知道要写点什么,就先来点近阶段的感悟吧。 
    这几天学了servlet和数据库等知识,就参照老方的视频写了一个简单的增删改查的,完成了最简单的一些功能,使用了三层架构。 
dao层完成的是对数据库具体的功能实现,service层调用了dao层的实现方法,具体对servlet提供支持。 
 &</div>
                                </li>
                                <li><a href="/article/3718.htm"
                                       title="高手问答:Java老A带你全面提升Java单兵作战能力!" target="_blank">高手问答:Java老A带你全面提升Java单兵作战能力!</a>
                                    <span class="text-muted">ITeye管理员</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a>
                                    <div>本期特邀《Java特种兵》作者:谢宇,CSDN论坛ID: xieyuooo 针对JAVA问题给予大家解答,欢迎网友积极提问,与专家一起讨论! 
 
 
作者简介: 
 
淘宝网资深Java工程师,CSDN超人气博主,人称“胖哥”。 
 
CSDN博客地址: 
http://blog.csdn.net/xieyuooo 
 
作者在进入大学前是一个不折不扣的计算机白痴,曾经被人笑话过不懂鼠标是什么,</div>
                                </li>
                </ul>
            </div>
        </div>
    </div>

<div>
    <div class="container">
        <div class="indexes">
            <strong>按字母分类:</strong>
            <a href="/tags/A/1.htm" target="_blank">A</a><a href="/tags/B/1.htm" target="_blank">B</a><a href="/tags/C/1.htm" target="_blank">C</a><a
                href="/tags/D/1.htm" target="_blank">D</a><a href="/tags/E/1.htm" target="_blank">E</a><a href="/tags/F/1.htm" target="_blank">F</a><a
                href="/tags/G/1.htm" target="_blank">G</a><a href="/tags/H/1.htm" target="_blank">H</a><a href="/tags/I/1.htm" target="_blank">I</a><a
                href="/tags/J/1.htm" target="_blank">J</a><a href="/tags/K/1.htm" target="_blank">K</a><a href="/tags/L/1.htm" target="_blank">L</a><a
                href="/tags/M/1.htm" target="_blank">M</a><a href="/tags/N/1.htm" target="_blank">N</a><a href="/tags/O/1.htm" target="_blank">O</a><a
                href="/tags/P/1.htm" target="_blank">P</a><a href="/tags/Q/1.htm" target="_blank">Q</a><a href="/tags/R/1.htm" target="_blank">R</a><a
                href="/tags/S/1.htm" target="_blank">S</a><a href="/tags/T/1.htm" target="_blank">T</a><a href="/tags/U/1.htm" target="_blank">U</a><a
                href="/tags/V/1.htm" target="_blank">V</a><a href="/tags/W/1.htm" target="_blank">W</a><a href="/tags/X/1.htm" target="_blank">X</a><a
                href="/tags/Y/1.htm" target="_blank">Y</a><a href="/tags/Z/1.htm" target="_blank">Z</a><a href="/tags/0/1.htm" target="_blank">其他</a>
        </div>
    </div>
</div>
<footer id="footer" class="mb30 mt30">
    <div class="container">
        <div class="footBglm">
            <a target="_blank" href="/">首页</a> -
            <a target="_blank" href="/custom/about.htm">关于我们</a> -
            <a target="_blank" href="/search/Java/1.htm">站内搜索</a> -
            <a target="_blank" href="/sitemap.txt">Sitemap</a> -
            <a target="_blank" href="/custom/delete.htm">侵权投诉</a>
        </div>
        <div class="copyright">版权所有 IT知识库 CopyRight © 2000-2050 E-COM-NET.COM , All Rights Reserved.
<!--            <a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">京ICP备09083238号</a><br>-->
        </div>
    </div>
</footer>
<!-- 代码高亮 -->
<script type="text/javascript" src="/static/syntaxhighlighter/scripts/shCore.js"></script>
<script type="text/javascript" src="/static/syntaxhighlighter/scripts/shLegacy.js"></script>
<script type="text/javascript" src="/static/syntaxhighlighter/scripts/shAutoloader.js"></script>
<link type="text/css" rel="stylesheet" href="/static/syntaxhighlighter/styles/shCoreDefault.css"/>
<script type="text/javascript" src="/static/syntaxhighlighter/src/my_start_1.js"></script>





</body>

</html>