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


import lombok.Data;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;


/**
 * Merge 规则配置
 */
@Data
public class MergeRule {
    public String queueName;

    public Set<Integer> enableExpIdSet = null;
    public Set<Integer> disableExpIdSet = null;

    public double recallPercentage = 0.1; // 召回百分比, 默认占 10%
    public int minMergeNum = 0; // 合并保护规则: 最小合并条数
    public int maxMergeNum = 100; // 合并保护规则: 最大合并条数

    private Map<String, String> properties;

    public MergeRule() {
        this.properties = new HashMap<String, String>();
    }

    public boolean isDisabled(final int expId) {
        if (enableExpIdSet != null && !enableExpIdSet.contains(expId)) {
            return true;
        }
        if (disableExpIdSet != null && disableExpIdSet.contains(expId)) {
            return true;
        }
        return false;
    }

    public void putProperty(String key, String value) {
        this.properties.put(key, value);
    }

}
