PageRenderTime 42ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/release-0.1-rc2/hive/external/ql/src/java/org/apache/hadoop/hive/ql/optimizer/unionproc/UnionProcContext.java

#
Java | 124 lines | 68 code | 23 blank | 33 comment | 1 complexity | c61219c2d95abc0010472307c2726f22 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.optimizer.unionproc;
  19. import java.util.HashMap;
  20. import java.util.Map;
  21. import org.apache.hadoop.hive.ql.exec.UnionOperator;
  22. import org.apache.hadoop.hive.ql.lib.NodeProcessorCtx;
  23. /**
  24. * UnionProcContext.
  25. *
  26. */
  27. public class UnionProcContext implements NodeProcessorCtx {
  28. /**
  29. * UnionParseContext.
  30. *
  31. */
  32. public static class UnionParseContext {
  33. private final transient boolean[] mapOnlySubq;
  34. private final transient boolean[] rootTask;
  35. private final transient boolean[] mapJoinSubq;
  36. private transient int numInputs;
  37. private transient boolean mapJoinQuery;
  38. public UnionParseContext(int numInputs) {
  39. this.numInputs = numInputs;
  40. mapOnlySubq = new boolean[numInputs];
  41. rootTask = new boolean[numInputs];
  42. mapJoinSubq = new boolean[numInputs];
  43. }
  44. public boolean getMapOnlySubq(int pos) {
  45. return mapOnlySubq[pos];
  46. }
  47. public void setMapOnlySubq(int pos, boolean mapOnlySubq) {
  48. this.mapOnlySubq[pos] = mapOnlySubq;
  49. }
  50. public boolean getMapJoinSubq(int pos) {
  51. return mapJoinSubq[pos];
  52. }
  53. public void setMapJoinSubq(int pos, boolean mapJoinSubq) {
  54. this.mapJoinSubq[pos] = mapJoinSubq;
  55. if (mapJoinSubq) {
  56. mapJoinQuery = true;
  57. }
  58. }
  59. public boolean getMapJoinQuery() {
  60. return mapJoinQuery;
  61. }
  62. public boolean getRootTask(int pos) {
  63. return rootTask[pos];
  64. }
  65. public void setRootTask(int pos, boolean rootTask) {
  66. this.rootTask[pos] = rootTask;
  67. }
  68. public int getNumInputs() {
  69. return numInputs;
  70. }
  71. public void setNumInputs(int numInputs) {
  72. this.numInputs = numInputs;
  73. }
  74. }
  75. // the subqueries are map-only jobs
  76. private boolean mapOnlySubq;
  77. /**
  78. * @return the mapOnlySubq
  79. */
  80. public boolean isMapOnlySubq() {
  81. return mapOnlySubq;
  82. }
  83. /**
  84. * @param mapOnlySubq
  85. * the mapOnlySubq to set
  86. */
  87. public void setMapOnlySubq(boolean mapOnlySubq) {
  88. this.mapOnlySubq = mapOnlySubq;
  89. }
  90. private final Map<UnionOperator, UnionParseContext> uCtxMap;
  91. public UnionProcContext() {
  92. uCtxMap = new HashMap<UnionOperator, UnionParseContext>();
  93. mapOnlySubq = true;
  94. }
  95. public void setUnionParseContext(UnionOperator u, UnionParseContext uCtx) {
  96. uCtxMap.put(u, uCtx);
  97. }
  98. public UnionParseContext getUnionParseContext(UnionOperator u) {
  99. return uCtxMap.get(u);
  100. }
  101. }