• ranker_worker.go


    package engine

    import (
        "github.com/huichen/wukong/types"
    )

    type rankerAddDocRequest struct {
        docId  uint64
        fields interface{}
    }

    type rankerRankRequest struct {
        docs                []types.IndexedDocument
        options             types.RankOptions
        rankerReturnChannel chan rankerReturnRequest
        countDocsOnly       bool
    }

    type rankerReturnRequest struct {
        docs    types.ScoredDocuments
        numDocs int
    }

    type rankerRemoveDocRequest struct {
        docId uint64
    }

    func (engine *Engine) rankerAddDocWorker(shard int) {
        for {
            request := <-engine.rankerAddDocChannels[shard]
            engine.rankers[shard].AddDoc(request.docId, request.fields)
        }
    }

    func (engine *Engine) rankerRankWorker(shard int) {
        for {
            request := <-engine.rankerRankChannels[shard]
            if request.options.MaxOutputs != 0 {
                request.options.MaxOutputs += request.options.OutputOffset
            }
            request.options.OutputOffset = 0
            outputDocs, numDocs := engine.rankers[shard].Rank(request.docs, request.options, request.countDocsOnly)
            request.rankerReturnChannel <- rankerReturnRequest{docs: outputDocs, numDocs: numDocs}
        }
    }

    func (engine *Engine) rankerRemoveDocWorker(shard int) {
        for {
            request := <-engine.rankerRemoveDocChannels[shard]
            engine.rankers[shard].RemoveDoc(request.docId)
        }
    }

  • 相关阅读:
    windows 2003系统安装
    Metasploit msfvenom
    cve_2019_0708_bluekeep漏洞
    ms12-020漏洞
    使用ajaxFileUpload实现异步上传图片
    Beautifulsoup学习笔记
    Python设计模式——设计原则
    Python设计模式——工厂方法模式(FactoryMethod)
    Python设计模式——代理模式(Proxy)
    Python设计模式——装饰模式(Decorator)
  • 原文地址:https://www.cnblogs.com/zhangboyu/p/7461676.html
Copyright © 2020-2023  润新知