test_class.file: baymax-core/src/test/java/com/tongbanjie/baymax/router/strategy/PartitionTableTest.java
test_class.identifier: PartitionTableTest
test_case.body: @Test
      public void testExecute_0() throws Exception {
          PartitionTable table = new TableBuilder()
                  .appenTable("trade_order", "trade_order_{0}", "value % 4")
                  .appendNodeMapping("p0:0,1")
                  .appendNodeMapping("p1:2,3")
                  .appendColumn("user_id", null)
                  .toTable();
  
          CalculateUnit unit = new CalculateUnit();
          unit.addCondition(ConditionUnit.buildConditionUnit("trade_order", "user_id", new String[]{"1","2"}, ConditionUnitOperator.IN));
  
          List<TargetTableEntity> target = table.execute(unit);
          System.out.println(target);
          Assert.assertEquals("p0", target.get(0).getTargetDB());
          Assert.assertEquals("trade_order_1", target.get(0).getTargetTable());
  
          Assert.assertEquals("p1", target.get(1).getTargetDB());
          Assert.assertEquals("trade_order_2", target.get(1).getTargetTable());
      }
test_case.class_method_signature: PartitionTableTest.testExecute_0()
test_case.full_signature: @Test public void testExecute_0()
test_case.identifier: testExecute_0
test_case.invocations: toTable appendColumn appendNodeMapping appendNodeMapping appenTable addCondition buildConditionUnit execute println assertEquals getTargetDB get assertEquals getTargetTable get assertEquals getTargetDB get assertEquals getTargetTable get
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testExecute_0()
focal_class.file: baymax-core/src/main/java/com/tongbanjie/baymax/router/strategy/PartitionTable.java
focal_class.identifier: PartitionTable
focal_class.class_method_signature: PartitionTable.execute(CalculateUnit calculateUnit)
focal_class.full_signature: public List<TargetTableEntity> execute(CalculateUnit calculateUnit)
focal_class.identifier: execute
focal_class.modifiers: public
focal_class.parameters: (CalculateUnit calculateUnit)
focal_class.return: List<TargetTableEntity>
focal_class.signature: List<TargetTableEntity> execute(CalculateUnit calculateUnit)
focal_class.class_method_signature: PartitionTable.executeRule(List<TargetTableEntity> targetList, PartitionFunction function, PartitionColumn column, Object value, Set<ConditionUnit> conditionUnits)
focal_class.full_signature: protected void executeRule(List<TargetTableEntity> targetList, PartitionFunction function, PartitionColumn column, Object value, Set<ConditionUnit> conditionUnits)
focal_class.identifier: executeRule
focal_class.modifiers: protected
focal_class.parameters: (List<TargetTableEntity> targetList, PartitionFunction function, PartitionColumn column, Object value, Set<ConditionUnit> conditionUnits)
focal_class.return: void
focal_class.signature: void executeRule(List<TargetTableEntity> targetList, PartitionFunction function, PartitionColumn column, Object value, Set<ConditionUnit> conditionUnits)
focal_class.class_method_signature: PartitionTable.executeRule(PartitionFunction function, PartitionColumn column, Object value, Set<ConditionUnit> conditionUnits)
focal_class.full_signature: protected TargetTableEntity executeRule(PartitionFunction function, PartitionColumn column, Object value, Set<ConditionUnit> conditionUnits)
focal_class.identifier: executeRule
focal_class.modifiers: protected
focal_class.parameters: (PartitionFunction function, PartitionColumn column, Object value, Set<ConditionUnit> conditionUnits)
focal_class.return: TargetTableEntity
focal_class.signature: TargetTableEntity executeRule(PartitionFunction function, PartitionColumn column, Object value, Set<ConditionUnit> conditionUnits)
focal_class.class_method_signature: PartitionTable.getAllTableNames()
focal_class.full_signature: public List<TargetTableEntity> getAllTableNames()
focal_class.identifier: getAllTableNames
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: List<TargetTableEntity>
focal_class.signature: List<TargetTableEntity> getAllTableNames()
focal_class.class_method_signature: PartitionTable.findColumnFromConditions(Set<ConditionUnit/*column value*/> conditionUnits, String columnName)
focal_class.full_signature: protected ConditionUnit findColumnFromConditions(Set<ConditionUnit/*column value*/> conditionUnits, String columnName)
focal_class.identifier: findColumnFromConditions
focal_class.modifiers: protected
focal_class.parameters: (Set<ConditionUnit/*column value*/> conditionUnits, String columnName)
focal_class.return: ConditionUnit
focal_class.signature: ConditionUnit findColumnFromConditions(Set<ConditionUnit/*column value*/> conditionUnits, String columnName)
focal_class.class_method_signature: PartitionTable.toString()
focal_class.full_signature: @Override public String toString()
focal_class.identifier: toString
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String toString()
focal_class.superclass: extends PartitionTableMetaData
focal_method.body: public List<TargetTableEntity> execute(CalculateUnit calculateUnit) {
          // and 相连的条件
          Set<ConditionUnit/*column value*/> conditionUnits = calculateUnit.getTablesAndConditions().get(getLogicTableName());
  
          if (conditionUnits == null || conditionUnits.size() == 0){
              return null;
          }
  
          // 检查conditon
  
          List<TargetTableEntity> targetList = new ArrayList<TargetTableEntity>(1);
  
          for (PartitionColumn column : columns){
              ConditionUnit matchingConditon = findColumnFromConditions(conditionUnits, column.getName());
              // 寻找到了分区列
              if (matchingConditon != null){
                  if (matchingConditon.getOperator() == ConditionUnitOperator.EQUAL){
                      // values
                      executeRule(targetList, rule.getFunction(), column, matchingConditon.getValues().get(0), conditionUnits);
                  }else if (matchingConditon.getOperator() == ConditionUnitOperator.IN){
                      for (Object obj : matchingConditon.getValues()){
                          executeRule(targetList, rule.getFunction(), column, obj, conditionUnits);
                      }
                  }
              }
              // 以第一个有结果的PartitionColumn为准,因为Baymax3.0规定，对于有多个分区列的，路由结果必须相同.
              if (targetList.size() != 0){
                  break;
              }
          }
          return targetList;
      }
focal_method.class_method_signature: PartitionTable.execute(CalculateUnit calculateUnit)
focal_method.full_signature: public List<TargetTableEntity> execute(CalculateUnit calculateUnit)
focal_method.identifier: execute
focal_method.invocations: get getTablesAndConditions getLogicTableName size findColumnFromConditions getName getOperator executeRule getFunction get getValues getOperator getValues executeRule getFunction size
focal_method.modifiers: public
focal_method.parameters: (CalculateUnit calculateUnit)
focal_method.return: List<TargetTableEntity>
focal_method.signature: List<TargetTableEntity> execute(CalculateUnit calculateUnit)