zoukankan      html  css  js  c++  java
  • 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)
        }
    }

  • 相关阅读:
    vue动态绑定class的几种方式
    寒假阅读笔记之《人月神话》
    人月神话阅读笔记1
    寒假阅读笔记之《构建之法》2
    寒假阅读笔记之《构建之法》
    家庭记账本APP(7)
    家庭记账本APP(6)
    家庭记账本APP(5)
    家庭记账本APP(4)
    家庭记账本APP(3)
  • 原文地址:https://www.cnblogs.com/zhangboyu/p/7461676.html
Copyright © 2011-2022 走看看