• 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)
        }
    }

  • 相关阅读:
    Spring 发生 has not been refreshed yet 异常
    rsyslog config
    grok
    阿里云态势
    Unity的asm笔记
    Unity2020或Unity2019安装后无法启动
    rider代码折叠
    使用rider调试lua
    MacType更好的字体渲染
    Unity字体和画面花屏处理
  • 原文地址:https://www.cnblogs.com/zhangboyu/p/7461676.html
Copyright © 2020-2023  润新知