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