Package com.taobao.tddl.interact.sqljep

Examples of com.taobao.tddl.interact.sqljep.Comparative


  private static <T> Rule<T> findMatchedRule(Map<String, Comparative> allRuleColumnArgs, List<Rule<T>> rules,
      Map<String, Comparative> matchArgs, ComparativeMapChoicer choicer, List<Object> args) {
    for (Rule<T> r : rules) {
      matchArgs.clear();
      for (RuleColumn ruleColumn : r.getRuleColumns().values()) {
        Comparative comparative = getComparative(ruleColumn.key, allRuleColumnArgs, choicer, args);
        if (comparative == null) {
          break;
        }
        matchArgs.put(ruleColumn.key, comparative);
      }
      if (matchArgs.size() == r.getRuleColumns().size()) {
        return r; //��ȫƥ��
      }
    }

    for (Rule<T> r : rules) {
      matchArgs.clear();
      int mandatoryColumnCount = 0;
      for (RuleColumn ruleColumn : r.getRuleColumns().values()) {
        if (!ruleColumn.needAppear) {
          continue;
        }
        mandatoryColumnCount++;
        Comparative comparative = getComparative(ruleColumn.key, allRuleColumnArgs, choicer, args);
        if (comparative == null) {
          break;
        }
        matchArgs.put(ruleColumn.key, comparative);
      }

      if (mandatoryColumnCount != 0 && matchArgs.size() == mandatoryColumnCount) {
        return r; //��ѡ��ƥ��
      }
    }

    //���û�б�ѡ�еĹ����磺rule=..#a?#..#b?#.. ����ֻ��a����b����sql����
    arule: for (Rule<T> r : rules) {
      matchArgs.clear();
      for (RuleColumn ruleColumn : r.getRuleColumns().values()) {
        if (ruleColumn.needAppear)
          continue arule; //�����ǰ�����б�ѡ�ֱ������,��Ϊ�ߵ������ѡ���Ѿ���ƥ����
        Comparative comparative = getComparative(ruleColumn.key, allRuleColumnArgs, choicer, args);
        if (comparative != null) {
          matchArgs.put(ruleColumn.key, allRuleColumnArgs.get(ruleColumn.key));
        }
      }
      if (matchArgs.size() != 0) {
View Full Code Here


    return null;
  }

  private static Comparative getComparative(String colName, Map<String, Comparative> allRuleColumnArgs,
      ComparativeMapChoicer comparativeMapChoicer, List<Object> args) {
    Comparative comparative = allRuleColumnArgs.get(colName); //�ȴӻ����л�ȡ
    if (comparative == null) {
      comparative = comparativeMapChoicer.getColumnComparative(args, colName);
      if (comparative != null) {
        allRuleColumnArgs.put(colName, comparative); //���뻺��
      }
View Full Code Here

        for(Map.Entry<String,String> entry:oriMap.entrySet()){
            String[] pieces=entry.getValue().trim().split(SLOT_PIECE_SPLIT);
            for(String piece:pieces){
              String[] range=piece.trim().split(RANGE_SUFFIX_SPLIT);
              if(range.length==2){
                Comparative start=new Comparative(Comparative.GreaterThanOrEqual,Integer.valueOf(range[0]));
                Comparative end=new Comparative(Comparative.LessThanOrEqual,Integer.valueOf(range[1]));
                int cumulativeTimes=Integer.valueOf(range[1])-Integer.valueOf(range[0]);
                Set<Object> result=new HashSet<Object>();
                enumerator.mergeFeildOfDefinitionInCloseInterval(start,end,result,cumulativeTimes,1);
                for(Object v:result){
                  slotMap.put(String.valueOf(v),entry.getKey());
View Full Code Here

    // ���������о�ûʲôʵ�ʵ����壬�������ٴ���
    if (andList.size() == 2) {
      Comparable<?> arg1 = andList.get(0);
      Comparable<?> arg2 = andList.get(1);

      Comparative compArg1 = valid2varableInAndIsNotComparativeBaseList(arg1);

      Comparative compArg2 = valid2varableInAndIsNotComparativeBaseList(arg2);
//
//      if(compArg1 == null){
//        throw new IllegalArgumentException("and ��������һ��Ϊnull");
//      }
//      if(compArg2 == null){
//        throw new IllegalArgumentException("and ��������һ��Ϊnull");
//      }
      int compResult = 0;
      try {
        compArg1.setValue(toPrimaryValue(compArg1.getValue()));
        compArg2.setValue(toPrimaryValue(compArg2.getValue()));
        compResult = compArg1.getValue().compareTo(compArg2.getValue());
      } catch (NullPointerException e) {
        throw new RuntimeException("and��������һ��ֵΪnull",e);
      }
     
View Full Code Here

      throw new IllegalArgumentException("��һ��and������ֻ֧��������Χ��ֵ��ͬ�����ֱ���֧��3��");
    }

    if (arg instanceof Comparative) {
      Comparative comp = ((Comparative) arg);
      int comparison = comp.getComparison();

      if (comparison == 0) {

        // 0��ʱ����ζ�������COmparativeBaseList��Comparative�Ǹ�����İ�װ����
        return valid2varableInAndIsNotComparativeBaseList(comp
            .getValue());
      } else {

        // ���������������ֵ������
        return comp;
View Full Code Here

  }

  private void processComparativeOne(Comparable<?> condition,
      Set<Object> retValue,Integer cumulativeTimes,Comparable<?> atomIncrValue,boolean needMergeValueInCloseInterval) {
    Comparative comp = (Comparative) condition;
    int comparison = comp.getComparison();
    switch (comparison) {
    case 0:

      // Ϊ0 ��ʱ���ʾ����İ�װ����
      process(comp.getValue(), retValue,cumulativeTimes,atomIncrValue,needMergeValueInCloseInterval);
      break;
    case Comparative.Equivalent:

      // ���ڹ�ϵ��ֱ�ӷ���collection
      retValue.add(toPrimaryValue(comp.getValue()));
      break;
    case Comparative.GreaterThan:
    case Comparative.GreaterThanOrEqual:
    case Comparative.LessThan:
    case Comparative.LessThanOrEqual:
View Full Code Here

  protected Comparative changeGreater2GreaterOrEq(Comparative from) {
    if (from.getComparison() == Comparative.GreaterThan) {

      Number fromComparable = cast2Number(from.getValue());

      return new Comparative(Comparative.GreaterThanOrEqual,
          (Comparable) plus(fromComparable, LIMIT_UNIT_OF_LONG));
    } else {
      return from;
    }
  }
View Full Code Here

  protected Comparative changeLess2LessOrEq(Comparative to) {
    if (to.getComparison() == Comparative.LessThan) {

      Number toComparable = cast2Number(to.getValue());

      return new Comparative(Comparative.LessThanOrEqual, (Comparable) plus(toComparable, -LIMIT_UNIT_OF_LONG));
    } else {

      return to;
    }
  }
View Full Code Here

  @Override
  protected Comparative changeGreater2GreaterOrEq(Comparative from) {
    if (from.getComparison() == Comparative.GreaterThan) {
      Date gtDate = (Date) from.getValue();
      long gtOrEqDate = gtDate.getTime() + LIMIT_UNIT_OF_DATE;
      return new Comparative(Comparative.GreaterThanOrEqual, new Date(
          gtOrEqDate));

    }
    return from;
  }
View Full Code Here

  @Override
  protected Comparative changeLess2LessOrEq(Comparative to) {
    if (to.getComparison() == Comparative.LessThan) {
      Date less = (Date) to.getValue();
      long lessOrEqDate = less.getTime() - LIMIT_UNIT_OF_DATE;
      return new Comparative(Comparative.LessThanOrEqual, new Date(
          lessOrEqDate));
    }
    return to;
  }
View Full Code Here

TOP

Related Classes of com.taobao.tddl.interact.sqljep.Comparative

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.