Package com.taobao.tddl.interact.rule

Examples of com.taobao.tddl.interact.rule.Samples$SamplesCtx


  abstract protected String replace(RuleColumn ruleColumn);

  public Map<T, Samples> calculate(Map<String, Comparative> sqlArgs, Object ctx, Object outerCtx) {
    Map<String, Set<Object>> enumerates = getEnumerates(sqlArgs, ctx);
    Map<T, Samples> res = new HashMap<T, Samples>(1);
    for (Map<String, Object> sample : new Samples(enumerates)) { //�����ѿ�������
      T value = this.eval(sample, outerCtx);
      if (value == null) {
        throw new IllegalArgumentException("rule eval resulte is null! rule:" + this.expression);
      }
      Samples evalSamples = res.get(value);
      if (evalSamples == null) {
        evalSamples = new Samples(sample.keySet());
        res.put(value, evalSamples);
      }
      evalSamples.addSample(sample);
    }
    return res;
  }
View Full Code Here


  }

  public Set<T> calculateNoTrace(Map<String, Comparative> sqlArgs, Object ctx, Object outerCtx) {
    Map<String, Set<Object>> enumerates = getEnumerates(sqlArgs, ctx);
    Set<T> res = new HashSet<T>(1);
    for (Map<String, Object> sample : new Samples(enumerates)) { //�����ѿ�������
      T value = this.eval(sample, outerCtx);
      if (value == null) {
        throw new IllegalArgumentException("rule eval resulte is null! rule:" + this.expression);
      }
      res.add(value);
View Full Code Here

  private Map<String, Set<Object>> getEnumerates(Map<String, Comparative> sqlArgs, Object ctx) {
    Set<AdvancedParameter> thisParam = cast(this.parameterSet);
    Map<String, Set<Object>> enumerates;
    SamplesCtx samplesCtx = (SamplesCtx) ctx;
    if (samplesCtx != null) {
      Samples commonSamples = samplesCtx.samples;
      if (samplesCtx.dealType == SamplesCtx.replace) {
        Set<AdvancedParameter> withoutCommon = new HashSet<AdvancedParameter>(thisParam.size());
        for (AdvancedParameter p : thisParam) {
          if (!commonSamples.getSubColumSet().contains(p.key)) {
            withoutCommon.add(p);
          }
        }
        enumerates = RuleUtils.getSamplingField(sqlArgs, withoutCommon);
        for (String name : commonSamples.getSubColumSet()) {
          enumerates.put(name, commonSamples.getColumnEnumerates(name)); //������ֻʹ����һ��������㣬ֵ����ķ���խ������
        }
      } else if (samplesCtx.dealType == SamplesCtx.merge) {
        enumerates = RuleUtils.getSamplingField(sqlArgs, thisParam);
        for (String diffType : commonSamples.getSubColumSet()) {
          enumerates.get(diffType).addAll(commonSamples.getColumnEnumerates(diffType));
        }
      } else {
        throw new IllegalStateException("Should not happen! SamplesCtx.dealType has a new Enum?");
      }
    } else {
View Full Code Here

TOP

Related Classes of com.taobao.tddl.interact.rule.Samples$SamplesCtx

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.