PageRenderTime 49ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/release-0.0.0-rc0/hive/external/ql/src/java/org/apache/hadoop/hive/ql/plan/ReduceSinkDesc.java

#
Java | 214 lines | 124 code | 33 blank | 57 comment | 0 complexity | 50ba0a37b7913e9ab271e0ab0207ac08 MD5 | raw file
Possible License(s): Apache-2.0, BSD-3-Clause, JSON, CPL-1.0
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. package org.apache.hadoop.hive.ql.plan;
  19. import java.io.Serializable;
  20. import java.util.List;
  21. /**
  22. * ReduceSinkDesc.
  23. *
  24. */
  25. @Explain(displayName = "Reduce Output Operator")
  26. public class ReduceSinkDesc implements Serializable {
  27. private static final long serialVersionUID = 1L;
  28. /**
  29. * Key columns are passed to reducer in the "key".
  30. */
  31. private java.util.ArrayList<ExprNodeDesc> keyCols;
  32. private java.util.ArrayList<java.lang.String> outputKeyColumnNames;
  33. private List<List<Integer>> distinctColumnIndices;
  34. /**
  35. * Value columns are passed to reducer in the "value".
  36. */
  37. private java.util.ArrayList<ExprNodeDesc> valueCols;
  38. private java.util.ArrayList<java.lang.String> outputValueColumnNames;
  39. /**
  40. * Describe how to serialize the key.
  41. */
  42. private TableDesc keySerializeInfo;
  43. /**
  44. * Describe how to serialize the value.
  45. */
  46. private TableDesc valueSerializeInfo;
  47. /**
  48. * The tag for this reducesink descriptor.
  49. */
  50. private int tag;
  51. /**
  52. * Number of distribution keys.
  53. */
  54. private int numDistributionKeys;
  55. /**
  56. * The partition columns (CLUSTER BY or DISTRIBUTE BY in Hive language).
  57. * Partition columns decide the reducer that the current row goes to.
  58. * Partition columns are not passed to reducer.
  59. */
  60. private java.util.ArrayList<ExprNodeDesc> partitionCols;
  61. private int numReducers;
  62. public ReduceSinkDesc() {
  63. }
  64. public ReduceSinkDesc(java.util.ArrayList<ExprNodeDesc> keyCols,
  65. int numDistributionKeys,
  66. java.util.ArrayList<ExprNodeDesc> valueCols,
  67. java.util.ArrayList<java.lang.String> outputKeyColumnNames,
  68. List<List<Integer>> distinctColumnIndices,
  69. java.util.ArrayList<java.lang.String> outputValueColumnNames, int tag,
  70. java.util.ArrayList<ExprNodeDesc> partitionCols, int numReducers,
  71. final TableDesc keySerializeInfo, final TableDesc valueSerializeInfo) {
  72. this.keyCols = keyCols;
  73. this.numDistributionKeys = numDistributionKeys;
  74. this.valueCols = valueCols;
  75. this.outputKeyColumnNames = outputKeyColumnNames;
  76. this.outputValueColumnNames = outputValueColumnNames;
  77. this.tag = tag;
  78. this.numReducers = numReducers;
  79. this.partitionCols = partitionCols;
  80. this.keySerializeInfo = keySerializeInfo;
  81. this.valueSerializeInfo = valueSerializeInfo;
  82. this.distinctColumnIndices = distinctColumnIndices;
  83. }
  84. public java.util.ArrayList<java.lang.String> getOutputKeyColumnNames() {
  85. return outputKeyColumnNames;
  86. }
  87. public void setOutputKeyColumnNames(
  88. java.util.ArrayList<java.lang.String> outputKeyColumnNames) {
  89. this.outputKeyColumnNames = outputKeyColumnNames;
  90. }
  91. public java.util.ArrayList<java.lang.String> getOutputValueColumnNames() {
  92. return outputValueColumnNames;
  93. }
  94. public void setOutputValueColumnNames(
  95. java.util.ArrayList<java.lang.String> outputValueColumnNames) {
  96. this.outputValueColumnNames = outputValueColumnNames;
  97. }
  98. @Explain(displayName = "key expressions")
  99. public java.util.ArrayList<ExprNodeDesc> getKeyCols() {
  100. return keyCols;
  101. }
  102. public void setKeyCols(final java.util.ArrayList<ExprNodeDesc> keyCols) {
  103. this.keyCols = keyCols;
  104. }
  105. public int getNumDistributionKeys() {
  106. return this.numDistributionKeys;
  107. }
  108. public void setNumDistributionKeys(int numKeys) {
  109. this.numDistributionKeys = numKeys;
  110. }
  111. @Explain(displayName = "value expressions")
  112. public java.util.ArrayList<ExprNodeDesc> getValueCols() {
  113. return valueCols;
  114. }
  115. public void setValueCols(final java.util.ArrayList<ExprNodeDesc> valueCols) {
  116. this.valueCols = valueCols;
  117. }
  118. @Explain(displayName = "Map-reduce partition columns")
  119. public java.util.ArrayList<ExprNodeDesc> getPartitionCols() {
  120. return partitionCols;
  121. }
  122. public void setPartitionCols(
  123. final java.util.ArrayList<ExprNodeDesc> partitionCols) {
  124. this.partitionCols = partitionCols;
  125. }
  126. @Explain(displayName = "tag")
  127. public int getTag() {
  128. return tag;
  129. }
  130. public void setTag(int tag) {
  131. this.tag = tag;
  132. }
  133. /**
  134. * Returns the number of reducers for the map-reduce job. -1 means to decide
  135. * the number of reducers at runtime. This enables Hive to estimate the number
  136. * of reducers based on the map-reduce input data size, which is only
  137. * available right before we start the map-reduce job.
  138. */
  139. public int getNumReducers() {
  140. return numReducers;
  141. }
  142. public void setNumReducers(int numReducers) {
  143. this.numReducers = numReducers;
  144. }
  145. public TableDesc getKeySerializeInfo() {
  146. return keySerializeInfo;
  147. }
  148. public void setKeySerializeInfo(TableDesc keySerializeInfo) {
  149. this.keySerializeInfo = keySerializeInfo;
  150. }
  151. public TableDesc getValueSerializeInfo() {
  152. return valueSerializeInfo;
  153. }
  154. public void setValueSerializeInfo(TableDesc valueSerializeInfo) {
  155. this.valueSerializeInfo = valueSerializeInfo;
  156. }
  157. /**
  158. * Returns the sort order of the key columns.
  159. *
  160. * @return null, which means ascending order for all key columns, or a String
  161. * of the same length as key columns, that consists of only "+"
  162. * (ascending order) and "-" (descending order).
  163. */
  164. @Explain(displayName = "sort order")
  165. public String getOrder() {
  166. return keySerializeInfo.getProperties().getProperty(
  167. org.apache.hadoop.hive.serde.Constants.SERIALIZATION_SORT_ORDER);
  168. }
  169. public void setOrder(String orderStr) {
  170. keySerializeInfo.getProperties().setProperty(
  171. org.apache.hadoop.hive.serde.Constants.SERIALIZATION_SORT_ORDER,
  172. orderStr);
  173. }
  174. public List<List<Integer>> getDistinctColumnIndices() {
  175. return distinctColumnIndices;
  176. }
  177. public void setDistinctColumnIndices(
  178. List<List<Integer>> distinctColumnIndices) {
  179. this.distinctColumnIndices = distinctColumnIndices;
  180. }
  181. }