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