PageRenderTime 12ms CodeModel.GetById 1ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 1ms

/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
  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
 19package org.apache.hadoop.hive.ql.plan;
 20
 21import java.io.Serializable;
 22import java.util.List;
 23
 24/**
 25 * ReduceSinkDesc.
 26 *
 27 */
 28@Explain(displayName = "Reduce Output Operator")
 29public class ReduceSinkDesc implements Serializable {
 30  private static final long serialVersionUID = 1L;
 31  /**
 32   * Key columns are passed to reducer in the "key".
 33   */
 34  private java.util.ArrayList<ExprNodeDesc> keyCols;
 35  private java.util.ArrayList<java.lang.String> outputKeyColumnNames;
 36  private List<List<Integer>> distinctColumnIndices;
 37  /**
 38   * Value columns are passed to reducer in the "value".
 39   */
 40  private java.util.ArrayList<ExprNodeDesc> valueCols;
 41  private java.util.ArrayList<java.lang.String> outputValueColumnNames;
 42  /**
 43   * Describe how to serialize the key.
 44   */
 45  private TableDesc keySerializeInfo;
 46  /**
 47   * Describe how to serialize the value.
 48   */
 49  private TableDesc valueSerializeInfo;
 50
 51  /**
 52   * The tag for this reducesink descriptor.
 53   */
 54  private int tag;
 55
 56  /**
 57   * Number of distribution keys.
 58   */
 59  private int numDistributionKeys;
 60
 61  /**
 62   * The partition columns (CLUSTER BY or DISTRIBUTE BY in Hive language).
 63   * Partition columns decide the reducer that the current row goes to.
 64   * Partition columns are not passed to reducer.
 65   */
 66  private java.util.ArrayList<ExprNodeDesc> partitionCols;
 67
 68  private int numReducers;
 69
 70  public ReduceSinkDesc() {
 71  }
 72
 73  public ReduceSinkDesc(java.util.ArrayList<ExprNodeDesc> keyCols,
 74      int numDistributionKeys,
 75      java.util.ArrayList<ExprNodeDesc> valueCols,
 76      java.util.ArrayList<java.lang.String> outputKeyColumnNames,
 77      List<List<Integer>> distinctColumnIndices,
 78      java.util.ArrayList<java.lang.String> outputValueColumnNames, int tag,
 79      java.util.ArrayList<ExprNodeDesc> partitionCols, int numReducers,
 80      final TableDesc keySerializeInfo, final TableDesc valueSerializeInfo) {
 81    this.keyCols = keyCols;
 82    this.numDistributionKeys = numDistributionKeys;
 83    this.valueCols = valueCols;
 84    this.outputKeyColumnNames = outputKeyColumnNames;
 85    this.outputValueColumnNames = outputValueColumnNames;
 86    this.tag = tag;
 87    this.numReducers = numReducers;
 88    this.partitionCols = partitionCols;
 89    this.keySerializeInfo = keySerializeInfo;
 90    this.valueSerializeInfo = valueSerializeInfo;
 91    this.distinctColumnIndices = distinctColumnIndices;
 92  }
 93
 94  public java.util.ArrayList<java.lang.String> getOutputKeyColumnNames() {
 95    return outputKeyColumnNames;
 96  }
 97
 98  public void setOutputKeyColumnNames(
 99      java.util.ArrayList<java.lang.String> outputKeyColumnNames) {
100    this.outputKeyColumnNames = outputKeyColumnNames;
101  }
102
103  public java.util.ArrayList<java.lang.String> getOutputValueColumnNames() {
104    return outputValueColumnNames;
105  }
106
107  public void setOutputValueColumnNames(
108      java.util.ArrayList<java.lang.String> outputValueColumnNames) {
109    this.outputValueColumnNames = outputValueColumnNames;
110  }
111
112  @Explain(displayName = "key expressions")
113  public java.util.ArrayList<ExprNodeDesc> getKeyCols() {
114    return keyCols;
115  }
116
117  public void setKeyCols(final java.util.ArrayList<ExprNodeDesc> keyCols) {
118    this.keyCols = keyCols;
119  }
120
121  public int getNumDistributionKeys() {
122    return this.numDistributionKeys;
123  }
124
125  public void setNumDistributionKeys(int numKeys) {
126    this.numDistributionKeys = numKeys;
127  }
128
129  @Explain(displayName = "value expressions")
130  public java.util.ArrayList<ExprNodeDesc> getValueCols() {
131    return valueCols;
132  }
133
134  public void setValueCols(final java.util.ArrayList<ExprNodeDesc> valueCols) {
135    this.valueCols = valueCols;
136  }
137
138  @Explain(displayName = "Map-reduce partition columns")
139  public java.util.ArrayList<ExprNodeDesc> getPartitionCols() {
140    return partitionCols;
141  }
142
143  public void setPartitionCols(
144      final java.util.ArrayList<ExprNodeDesc> partitionCols) {
145    this.partitionCols = partitionCols;
146  }
147
148  @Explain(displayName = "tag")
149  public int getTag() {
150    return tag;
151  }
152
153  public void setTag(int tag) {
154    this.tag = tag;
155  }
156
157  /**
158   * Returns the number of reducers for the map-reduce job. -1 means to decide
159   * the number of reducers at runtime. This enables Hive to estimate the number
160   * of reducers based on the map-reduce input data size, which is only
161   * available right before we start the map-reduce job.
162   */
163  public int getNumReducers() {
164    return numReducers;
165  }
166
167  public void setNumReducers(int numReducers) {
168    this.numReducers = numReducers;
169  }
170
171  public TableDesc getKeySerializeInfo() {
172    return keySerializeInfo;
173  }
174
175  public void setKeySerializeInfo(TableDesc keySerializeInfo) {
176    this.keySerializeInfo = keySerializeInfo;
177  }
178
179  public TableDesc getValueSerializeInfo() {
180    return valueSerializeInfo;
181  }
182
183  public void setValueSerializeInfo(TableDesc valueSerializeInfo) {
184    this.valueSerializeInfo = valueSerializeInfo;
185  }
186
187  /**
188   * Returns the sort order of the key columns.
189   * 
190   * @return null, which means ascending order for all key columns, or a String
191   *         of the same length as key columns, that consists of only "+"
192   *         (ascending order) and "-" (descending order).
193   */
194  @Explain(displayName = "sort order")
195  public String getOrder() {
196    return keySerializeInfo.getProperties().getProperty(
197        org.apache.hadoop.hive.serde.Constants.SERIALIZATION_SORT_ORDER);
198  }
199  
200  public void setOrder(String orderStr) {
201    keySerializeInfo.getProperties().setProperty(
202        org.apache.hadoop.hive.serde.Constants.SERIALIZATION_SORT_ORDER,
203        orderStr);
204  }
205
206  public List<List<Integer>> getDistinctColumnIndices() {
207    return distinctColumnIndices;
208  }
209
210  public void setDistinctColumnIndices(
211      List<List<Integer>> distinctColumnIndices) {
212    this.distinctColumnIndices = distinctColumnIndices;
213  }
214}