package com.tzld.piaoquan.recommend.server.framework.merger;


import com.tzld.piaoquan.recommend.server.common.base.RankItem;
import com.tzld.piaoquan.recommend.server.framework.common.User;
import com.tzld.piaoquan.recommend.server.framework.candidiate.Candidate;
import com.tzld.piaoquan.recommend.server.gen.recommend.RecommendRequest;
import org.apache.commons.lang3.tuple.Pair;

import java.util.*;


public class SimpleMergeQueue extends StrategyQueue {
    public SimpleMergeQueue(StrategyQueueInfo strategyQueueInfo, StrategyQueueConfig strategyQueueConfig) {
        super(strategyQueueInfo, strategyQueueConfig);
    }

    @Override
    public int doMerge(final Map<String, Pair<MergeRule, List<RankItem>>> rankerItemsListMap, final int recNum, final User user, final RecommendRequest requestData, final int requestIndex, final int expId) {
        return MergeUtils.simpleMergeWithProtection(items, rankerItemsListMap, recNum, expId);
    }

    @Override
    public int candidate(Map<String, Candidate> candidateMap, final int recallNum, final User user, final RecommendRequest requestData, final int requestIndex, final int expId) {
        return simpleCandidateByPercentage(candidateMap, recallNum, user, requestData, requestIndex, expId);
    }

    @Override
    public String toString() {
        return "SimpleMergeQueue{" +
                "rankerItemsList=" + rankerItemsList +
                ", children=" + children +
                ", items=" + items +
                '}';
    }
}
