@@ -0,0 +1,3518 @@
+/*%0A * Licensed to the Apache Software Foundation (ASF) under one or more%0A * contributor license agreements.  See the NOTICE file distributed with%0A * this work for additional information regarding copyright ownership.%0A * The ASF licenses this file to You under the Apache License, Version 2.0%0A * (the %22License%22); you may not use this file except in compliance with%0A * the License.  You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage org.apache.shardingsphere.core.rewrite.builder;%0A%0Aimport lombok.Getter;%0Aimport lombok.RequiredArgsConstructor;%0Aimport org.apache.shardingsphere.core.optimize.statement.InsertOptimizedStatement;%0Aimport org.apache.shardingsphere.core.optimize.statement.sharding.dml.insert.InsertOptimizeResultUnit;%0Aimport org.apache.shardingsphere.core.route.type.RoutingUnit;%0Aimport org.apache.shardingsphere.core.rule.DataNode;%0A%0Aimport java.util.Arrays;%0Aimport java.util.LinkedList;%0Aimport java.util.List;%0A%0A/**%0A * Insert parameter builder.%0A *%0A * @author panjuan%0A */%0A@RequiredArgsConstructor%0A@Getter%0Apublic final class InsertParameterBuilder %7B%0A    %0A    private final List%3CObject%3E originalParameters;%0A    %0A    private final List%3CInsertParameterUnit%3E insertParameterUnits = new LinkedList%3C%3E();%0A    %0A    /**%0A     * Set insert parameter units.%0A     * %0A     * @param optimizedStatement optimized statement%0A     */%0A    public void setInsertParameterUnits(final InsertOptimizedStatement optimizedStatement) %7B%0A        insertParameterUnits.addAll(createInsertParameterUnits(optimizedStatement));%0A    %7D%0A    %0A    private List%3CInsertParameterUnit%3E createInsertParameterUnits(final InsertOptimizedStatement optimizedStatement) %7B%0A        List%3CInsertParameterUnit%3E result = new LinkedList%3C%3E();%0A        if (null == optimizedStatement) %7B%0A            return result;%0A        %7D%0A        for (InsertOptimizeResultUnit each : optimizedStatement.getUnits()) %7B%0A            result.add(new InsertParameterUnit(Arrays.asList(each.getParameters()), each.getDataNodes()));%0A        %7D%0A        return result;%0A    %7D%0A    %0A    /**%0A     * Get parameters.%0A     *%0A     * @return parameters%0A     */%0A    public List%3CObject%3E getParameters() %7B%0A        List%3CObject%3E result = new LinkedList%3C%3E();%0A        for (InsertParameterUnit each : insertParameterUnits) %7B%0A            result.addAll(each.getParameters());%0A        %7D%0A        return result;%0A    %7D%0A    %0A    /**%0A     * Get parameters.%0A     * %0A     * @param routingUnit routing unit%0A     * @return parameters%0A     */%0A    public List%3CObject%3E getParameters(final RoutingUnit routingUnit) %7B%0A        List%3CObject%3E result = new LinkedList%3C%3E();%0A        for (InsertParameterUnit each : insertParameterUnits) %7B%0A            if (isAppendInsertParameter(each, routingUnit)) %7B%0A                result.addAll(each.getParameters());%0A            %7D%0A        %7D%0A        return result;%0A    %7D%0A    %0A    private boolean isAppendInsertParameter(final InsertParameterUnit unit, final RoutingUnit routingUnit) %7B%0A        for (DataNode each : unit.getDataNodes()) %7B%0A            if (routingUnit.getTableUnit(each.getDataSourceName(), each.getTableName()).isPresent()) %7B%0A                return true;%0A            %7D%0A        %7D%0A        return false;%0A    %7D%0A%7D%0A

ADD InsertParameterBuilder.java