PageRenderTime 23ms CodeModel.GetById 12ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Java | 206 lines | 121 code | 30 blank | 55 comment | 2 complexity | c9710be9dbd2e7f02557fa7206b77dc3 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.ArrayList;
 23import java.util.HashMap;
 24import java.util.Iterator;
 25import java.util.LinkedHashMap;
 26import java.util.List;
 27import java.util.Map;
 28import java.util.Set;
 29import java.util.Map.Entry;
 30
 31/**
 32 * Map Join operator Descriptor implementation.
 33 *
 34 */
 35@Explain(displayName = "Map Join Operator")
 36public class MapJoinDesc extends JoinDesc implements Serializable {
 37  private static final long serialVersionUID = 1L;
 38
 39  private Map<Byte, List<ExprNodeDesc>> keys;
 40  private TableDesc keyTblDesc;
 41  private List<TableDesc> valueTblDescs;
 42  private List<TableDesc> valueFilteredTblDescs;
 43
 44  private int posBigTable;
 45
 46  private Map<Byte, List<Integer>> retainList;
 47
 48  private transient String bigTableAlias;
 49
 50  private LinkedHashMap<String, LinkedHashMap<String, ArrayList<String>>> aliasBucketFileNameMapping;
 51  private LinkedHashMap<String, Integer> bucketFileNameMapping;
 52
 53  public MapJoinDesc() {
 54    bucketFileNameMapping = new LinkedHashMap<String, Integer>();
 55  }
 56
 57  public MapJoinDesc(MapJoinDesc clone) {
 58    super(clone);
 59    this.keys = clone.keys;
 60    this.keyTblDesc = clone.keyTblDesc;
 61    this.valueTblDescs = clone.valueTblDescs;
 62    this.posBigTable = clone.posBigTable;
 63    this.retainList = clone.retainList;
 64    this.bigTableAlias = clone.bigTableAlias;
 65    this.aliasBucketFileNameMapping = clone.aliasBucketFileNameMapping;
 66    this.bucketFileNameMapping = clone.bucketFileNameMapping;
 67  }
 68
 69  public MapJoinDesc(final Map<Byte, List<ExprNodeDesc>> keys,
 70      final TableDesc keyTblDesc, final Map<Byte, List<ExprNodeDesc>> values,
 71      final List<TableDesc> valueTblDescs,final List<TableDesc> valueFilteredTblDescs,  List<String> outputColumnNames,
 72      final int posBigTable, final JoinCondDesc[] conds,
 73      final Map<Byte, List<ExprNodeDesc>> filters, boolean noOuterJoin) {
 74    super(values, outputColumnNames, noOuterJoin, conds, filters);
 75    this.keys = keys;
 76    this.keyTblDesc = keyTblDesc;
 77    this.valueTblDescs = valueTblDescs;
 78    this.valueFilteredTblDescs = valueFilteredTblDescs;
 79    this.posBigTable = posBigTable;
 80    this.bucketFileNameMapping = new LinkedHashMap<String, Integer>();
 81    initRetainExprList();
 82  }
 83
 84  private void initRetainExprList() {
 85    retainList = new HashMap<Byte, List<Integer>>();
 86    Set<Entry<Byte, List<ExprNodeDesc>>> set = super.getExprs().entrySet();
 87    Iterator<Entry<Byte, List<ExprNodeDesc>>> setIter = set.iterator();
 88    while (setIter.hasNext()) {
 89      Entry<Byte, List<ExprNodeDesc>> current = setIter.next();
 90      List<Integer> list = new ArrayList<Integer>();
 91      for (int i = 0; i < current.getValue().size(); i++) {
 92        list.add(i);
 93      }
 94      retainList.put(current.getKey(), list);
 95    }
 96  }
 97
 98  public Map<Byte, List<Integer>> getRetainList() {
 99    return retainList;
100  }
101
102  public void setRetainList(Map<Byte, List<Integer>> retainList) {
103    this.retainList = retainList;
104  }
105
106  /**
107   * @return the keys
108   */
109  @Explain(displayName = "keys")
110  public Map<Byte, List<ExprNodeDesc>> getKeys() {
111    return keys;
112  }
113
114  /**
115   * @param keys
116   *          the keys to set
117   */
118  public void setKeys(Map<Byte, List<ExprNodeDesc>> keys) {
119    this.keys = keys;
120  }
121
122  /**
123   * @return the position of the big table not in memory
124   */
125  @Explain(displayName = "Position of Big Table")
126  public int getPosBigTable() {
127    return posBigTable;
128  }
129
130  /**
131   * @param posBigTable
132   *          the position of the big table not in memory
133   */
134  public void setPosBigTable(int posBigTable) {
135    this.posBigTable = posBigTable;
136  }
137
138  /**
139   * @return the keyTblDesc
140   */
141  public TableDesc getKeyTblDesc() {
142    return keyTblDesc;
143  }
144
145  /**
146   * @param keyTblDesc
147   *          the keyTblDesc to set
148   */
149  public void setKeyTblDesc(TableDesc keyTblDesc) {
150    this.keyTblDesc = keyTblDesc;
151  }
152
153  public List<TableDesc> getValueFilteredTblDescs() {
154    return valueFilteredTblDescs;
155  }
156
157  public void setValueFilteredTblDescs(List<TableDesc> valueFilteredTblDescs) {
158    this.valueFilteredTblDescs = valueFilteredTblDescs;
159  }
160
161  /**
162   * @return the valueTblDescs
163   */
164  public List<TableDesc> getValueTblDescs() {
165    return valueTblDescs;
166  }
167
168  /**
169   * @param valueTblDescs
170   *          the valueTblDescs to set
171   */
172  public void setValueTblDescs(List<TableDesc> valueTblDescs) {
173    this.valueTblDescs = valueTblDescs;
174  }
175
176  /**
177   * @return bigTableAlias
178   */
179  public String getBigTableAlias() {
180    return bigTableAlias;
181  }
182
183  /**
184   * @param bigTableAlias
185   */
186  public void setBigTableAlias(String bigTableAlias) {
187    this.bigTableAlias = bigTableAlias;
188  }
189
190  public LinkedHashMap<String, LinkedHashMap<String, ArrayList<String>>> getAliasBucketFileNameMapping() {
191    return aliasBucketFileNameMapping;
192  }
193
194  public void setAliasBucketFileNameMapping(
195      LinkedHashMap<String, LinkedHashMap<String, ArrayList<String>>> aliasBucketFileNameMapping) {
196    this.aliasBucketFileNameMapping = aliasBucketFileNameMapping;
197  }
198
199  public LinkedHashMap<String, Integer> getBucketFileNameMapping() {
200    return bucketFileNameMapping;
201  }
202
203  public void setBucketFileNameMapping(LinkedHashMap<String, Integer> bucketFileNameMapping) {
204    this.bucketFileNameMapping = bucketFileNameMapping;
205  }
206}