PageRenderTime 22ms CodeModel.GetById 17ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/release-0.1-rc2/hive/external/ql/src/java/org/apache/hadoop/hive/ql/plan/AddPartitionDesc.java

#
Java | 140 lines | 54 code | 16 blank | 70 comment | 0 complexity | 3879c8293c8ed9c6689940386e9f6d48 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 */
 18package org.apache.hadoop.hive.ql.plan;
 19
 20import java.io.Serializable;
 21import java.util.HashMap;
 22import java.util.LinkedHashMap;
 23import java.util.Map;
 24
 25/**
 26 * Contains the information needed to add a partition.
 27 */
 28public class AddPartitionDesc extends DDLDesc implements Serializable {
 29
 30  private static final long serialVersionUID = 1L;
 31  
 32  String tableName;
 33  String dbName;
 34  String location;
 35  boolean ifNotExists;
 36  LinkedHashMap<String, String> partSpec;
 37
 38  /**
 39   * For serialization only.
 40   */
 41  public AddPartitionDesc() {
 42  }
 43
 44  /**
 45   * @param dbName
 46   *          database to add to.
 47   * @param tableName
 48   *          table to add to.
 49   * @param partSpec
 50   *          partition specification.
 51   * @param location
 52   *          partition location, relative to table location.
 53   * @param ifNotExists 
 54   *          if true, the partition is only added if it doesn't exist
 55   */
 56  public AddPartitionDesc(String dbName, String tableName,
 57      Map<String, String> partSpec, String location, boolean ifNotExists) {
 58    super();
 59    this.dbName = dbName;
 60    this.tableName = tableName;
 61    this.partSpec = new LinkedHashMap<String,String>(partSpec);
 62    this.location = location;
 63    this.ifNotExists = ifNotExists;
 64  }
 65
 66  /**
 67   * @return database name
 68   */
 69  public String getDbName() {
 70    return dbName;
 71  }
 72
 73  /**
 74   * @param dbName
 75   *          database name
 76   */
 77  public void setDbName(String dbName) {
 78    this.dbName = dbName;
 79  }
 80
 81  /**
 82   * @return the table we're going to add the partitions to.
 83   */
 84  public String getTableName() {
 85    return tableName;
 86  }
 87
 88  /**
 89   * @param tableName
 90   *          the table we're going to add the partitions to.
 91   */
 92  public void setTableName(String tableName) {
 93    this.tableName = tableName;
 94  }
 95
 96  /**
 97   * @return location of partition in relation to table
 98   */
 99  public String getLocation() {
100    return location;
101  }
102
103  /**
104   * @param location
105   *          location of partition in relation to table
106   */
107  public void setLocation(String location) {
108    this.location = location;
109  }
110
111  /**
112   * @return partition specification.
113   */
114  public LinkedHashMap<String, String> getPartSpec() {
115    return partSpec;
116  }
117
118  /**
119   * @param partSpec
120   *          partition specification
121   */
122  public void setPartSpec(LinkedHashMap<String, String> partSpec) {
123    this.partSpec = partSpec;
124  }
125
126  /**
127   * @return if the partition should only be added if it doesn't exist already
128   */
129  public boolean getIfNotExists() {
130    return this.ifNotExists;
131  }
132
133  /**
134   * @param ifNotExists 
135   *          if the part should be added only if it doesn't exist
136   */
137  public void setIfNotExists(boolean ifNotExists) {
138    this.ifNotExists = ifNotExists;
139  }
140}