PageRenderTime 40ms CodeModel.GetById 20ms app.highlight 15ms RepoModel.GetById 2ms app.codeStats 0ms

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

#
Java | 178 lines | 116 code | 26 blank | 36 comment | 1 complexity | 31920126b1b595259447ae3cb99685e7 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
 21/**
 22 * GroupByDesc.
 23 *
 24 */
 25@Explain(displayName = "Group By Operator")
 26public class GroupByDesc implements java.io.Serializable {
 27  /**
 28   * Group-by Mode: COMPLETE: complete 1-phase aggregation: iterate, terminate
 29   * PARTIAL1: partial aggregation - first phase: iterate, terminatePartial
 30   * PARTIAL2: partial aggregation - second phase: merge, terminatePartial
 31   * PARTIALS: For non-distinct the same as PARTIAL2, for distinct the same as
 32   *           PARTIAL1
 33   * FINAL: partial aggregation - final phase: merge, terminate
 34   * HASH: For non-distinct the same as PARTIAL1 but use hash-table-based aggregation
 35   * MERGEPARTIAL: FINAL for non-distinct aggregations, COMPLETE for distinct
 36   * aggregations.
 37   */
 38  private static final long serialVersionUID = 1L;
 39
 40  /**
 41   * Mode.
 42   *
 43   */
 44  public static enum Mode {
 45    COMPLETE, PARTIAL1, PARTIAL2, PARTIALS, FINAL, HASH, MERGEPARTIAL
 46  };
 47
 48  private Mode mode;
 49  private boolean groupKeyNotReductionKey;
 50  private boolean bucketGroup;
 51
 52  private java.util.ArrayList<ExprNodeDesc> keys;
 53  private java.util.ArrayList<org.apache.hadoop.hive.ql.plan.AggregationDesc> aggregators;
 54  private java.util.ArrayList<java.lang.String> outputColumnNames;
 55  private float groupByMemoryUsage;
 56  private float memoryThreshold;
 57
 58  public GroupByDesc() {
 59  }
 60
 61  public GroupByDesc(
 62      final Mode mode,
 63      final java.util.ArrayList<java.lang.String> outputColumnNames,
 64      final java.util.ArrayList<ExprNodeDesc> keys,
 65      final java.util.ArrayList<org.apache.hadoop.hive.ql.plan.AggregationDesc> aggregators,
 66      final boolean groupKeyNotReductionKey,float groupByMemoryUsage, float memoryThreshold) {
 67    this(mode, outputColumnNames, keys, aggregators, groupKeyNotReductionKey,
 68        false, groupByMemoryUsage, memoryThreshold);
 69  }
 70
 71  public GroupByDesc(
 72      final Mode mode,
 73      final java.util.ArrayList<java.lang.String> outputColumnNames,
 74      final java.util.ArrayList<ExprNodeDesc> keys,
 75      final java.util.ArrayList<org.apache.hadoop.hive.ql.plan.AggregationDesc> aggregators,
 76      final boolean groupKeyNotReductionKey, final boolean bucketGroup,float groupByMemoryUsage, float memoryThreshold) {
 77    this.mode = mode;
 78    this.outputColumnNames = outputColumnNames;
 79    this.keys = keys;
 80    this.aggregators = aggregators;
 81    this.groupKeyNotReductionKey = groupKeyNotReductionKey;
 82    this.bucketGroup = bucketGroup;
 83    this.groupByMemoryUsage = groupByMemoryUsage;
 84    this.memoryThreshold = memoryThreshold;
 85  }
 86
 87  public Mode getMode() {
 88    return mode;
 89  }
 90
 91  @Explain(displayName = "mode")
 92  public String getModeString() {
 93    switch (mode) {
 94    case COMPLETE:
 95      return "complete";
 96    case PARTIAL1:
 97      return "partial1";
 98    case PARTIAL2:
 99      return "partial2";
100    case PARTIALS:
101      return "partials";
102    case HASH:
103      return "hash";
104    case FINAL:
105      return "final";
106    case MERGEPARTIAL:
107      return "mergepartial";
108    }
109
110    return "unknown";
111  }
112
113  public void setMode(final Mode mode) {
114    this.mode = mode;
115  }
116
117  @Explain(displayName = "keys")
118  public java.util.ArrayList<ExprNodeDesc> getKeys() {
119    return keys;
120  }
121
122  public void setKeys(final java.util.ArrayList<ExprNodeDesc> keys) {
123    this.keys = keys;
124  }
125
126  @Explain(displayName = "outputColumnNames")
127  public java.util.ArrayList<java.lang.String> getOutputColumnNames() {
128    return outputColumnNames;
129  }
130
131  public void setOutputColumnNames(
132      java.util.ArrayList<java.lang.String> outputColumnNames) {
133    this.outputColumnNames = outputColumnNames;
134  }
135
136  public float getGroupByMemoryUsage() {
137    return groupByMemoryUsage;
138  }
139
140  public void setGroupByMemoryUsage(float groupByMemoryUsage) {
141    this.groupByMemoryUsage = groupByMemoryUsage;
142  }
143
144  public float getMemoryThreshold() {
145    return memoryThreshold;
146  }
147
148  public void setMemoryThreshold(float memoryThreshold) {
149    this.memoryThreshold = memoryThreshold;
150  }
151
152  @Explain(displayName = "aggregations")
153  public java.util.ArrayList<org.apache.hadoop.hive.ql.plan.AggregationDesc> getAggregators() {
154    return aggregators;
155  }
156
157  public void setAggregators(
158      final java.util.ArrayList<org.apache.hadoop.hive.ql.plan.AggregationDesc> aggregators) {
159    this.aggregators = aggregators;
160  }
161
162  public boolean getGroupKeyNotReductionKey() {
163    return groupKeyNotReductionKey;
164  }
165
166  public void setGroupKeyNotReductionKey(final boolean groupKeyNotReductionKey) {
167    this.groupKeyNotReductionKey = groupKeyNotReductionKey;
168  }
169
170  @Explain(displayName = "bucketGroup")
171  public boolean getBucketGroup() {
172    return bucketGroup;
173  }
174
175  public void setBucketGroup(boolean dataSorted) {
176    bucketGroup = dataSorted;
177  }
178}