diff --git ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/cost/HiveCostUtil.java ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/cost/HiveCostUtil.java deleted file mode 100644 index 47ecd47..0000000 --- ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/cost/HiveCostUtil.java +++ /dev/null @@ -1,177 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.hadoop.hive.ql.optimizer.calcite.cost; - -import org.apache.calcite.plan.RelOptCost; -import org.apache.calcite.util.ImmutableBitSet; -import org.apache.calcite.util.Pair; -import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveRelNode; -import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveTableScan; - -import com.google.common.collect.ImmutableList; - -// Use this once we have Join Algorithm selection -public class HiveCostUtil { - - private static final double CPU_COST = 1.0; - private static final double NET_COST = 150.0 * CPU_COST; - private static final double LOCAL_WRITE_COST = 4.0 * NET_COST; - private static final double LOCAL_READ_COST = 4.0 * NET_COST; - private static final double HDFS_WRITE_COST = 10.0 * LOCAL_WRITE_COST; - private static final double HDFS_READ_COST = 1.5 * LOCAL_READ_COST; - - public static RelOptCost computCardinalityBasedCost(HiveRelNode hr) { - return new HiveCost(hr.getRows(), 0, 0); - } - - public static HiveCost computeCost(HiveTableScan t) { - double cardinality = t.getRows(); - return new HiveCost(cardinality, 0, HDFS_WRITE_COST * cardinality * 0); - } - - public static double computeSortMergeCPUCost( - ImmutableList cardinalities, - ImmutableBitSet sorted) { - // Sort-merge join - double cpuCost = 0.0; - for (int i=0; i> relationInfos) { - // Sort-merge join - double ioCost = 0.0; - for (Pair relationInfo : relationInfos) { - ioCost += computeSortIOCost(relationInfo); - } - return ioCost; - } - - public static double computeSortIOCost(Pair relationInfo) { - // Sort-merge join - double ioCost = 0.0; - double cardinality = relationInfo.left; - double averageTupleSize = relationInfo.right; - // Write cost - ioCost += cardinality * averageTupleSize * LOCAL_WRITE_COST; - // Read cost - ioCost += cardinality * averageTupleSize * LOCAL_READ_COST; - // Net transfer cost - ioCost += cardinality * averageTupleSize * NET_COST; - return ioCost; - } - - public static double computeMapJoinCPUCost( - ImmutableList cardinalities, - ImmutableBitSet streaming) { - // Hash-join - double cpuCost = 0.0; - for (int i=0; i> relationInfos, - ImmutableBitSet streaming, int parallelism) { - // Hash-join - double ioCost = 0.0; - for (int i=0; i cardinalities, - ImmutableBitSet streaming) { - // Hash-join - double cpuCost = 0.0; - for (int i=0; i> relationInfos, - ImmutableBitSet streaming, int parallelism) { - // Hash-join - double ioCost = 0.0; - for (int i=0; i cardinalities) { - // Hash-join - double cpuCost = 0.0; - for (int i=0; i> relationInfos, - ImmutableBitSet streaming, int parallelism) { - // Hash-join - double ioCost = 0.0; - for (int i=0; i