package com.tzld.piaoquan.recommend.server.service.score4recall;

import com.tzld.piaoquan.recommend.feature.domain.video.base.UserFeature;
import com.tzld.piaoquan.recommend.server.common.base.RankItem;
import com.tzld.piaoquan.recommend.server.service.score.AbstractScorer;
import com.tzld.piaoquan.recommend.server.service.score.ScoreParam;
import lombok.extern.slf4j.Slf4j;
import com.tzld.piaoquan.recommend.server.service.score.ScorerPipeline;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.*;


@Slf4j
public class ScorerPipeline4Recall {
    public static final int corePoolSize = 128;
    public static final int SCORE_TIME_OUT = 400;
    public static final Logger LOGGER = LoggerFactory.getLogger(ScorerPipeline4Recall.class);
    public static final ExecutorService executorService = Executors.newFixedThreadPool(corePoolSize);

    public List<AbstractScorer4Recall> scorers;

    public ScorerPipeline4Recall(List<AbstractScorer4Recall> scorers) {
        this.scorers = scorers;
    }

    //todo zhangbo 定义一个接口，对scores做循环，执行recall的功能，返回一个多个list。
    public List<List<Pair<Long, Double>>> recall(Map<String, String> params) {
        List<List<Pair<Long, Double>>> result = new ArrayList<>();
        for (AbstractScorer4Recall scorer : scorers){
            result.add(scorer.recall(params));
        }
        return result;
    }
}
