PageRenderTime 48ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
Java | 250 lines | 147 code | 37 blank | 66 comment | 2 complexity | f1bfcf84fc17b35b2a5894b75665f2bf 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. import java.io.Serializable;
  20. import java.util.ArrayList;
  21. import org.apache.hadoop.fs.Path;
  22. /**
  23. * FileSinkDesc.
  24. *
  25. */
  26. @Explain(displayName = "File Output Operator")
  27. public class FileSinkDesc implements Serializable {
  28. private static final long serialVersionUID = 1L;
  29. private String dirName;
  30. // normally statsKeyPref will be the same as dirName, but the latter
  31. // could be changed in local execution optimization
  32. private String statsKeyPref;
  33. private TableDesc tableInfo;
  34. private boolean compressed;
  35. private int destTableId;
  36. private String compressCodec;
  37. private String compressType;
  38. private boolean multiFileSpray;
  39. private int totalFiles;
  40. private ArrayList<ExprNodeDesc> partitionCols;
  41. private int numFiles;
  42. private DynamicPartitionCtx dpCtx;
  43. private String staticSpec; // static partition spec ends with a '/'
  44. private boolean gatherStats;
  45. public FileSinkDesc() {
  46. }
  47. public FileSinkDesc(final String dirName, final TableDesc tableInfo,
  48. final boolean compressed, final int destTableId, final boolean multiFileSpray,
  49. final int numFiles, final int totalFiles, final ArrayList<ExprNodeDesc> partitionCols,
  50. final DynamicPartitionCtx dpCtx) {
  51. this.dirName = dirName;
  52. this.tableInfo = tableInfo;
  53. this.compressed = compressed;
  54. this.destTableId = destTableId;
  55. this.multiFileSpray = multiFileSpray;
  56. this.numFiles = numFiles;
  57. this.totalFiles = totalFiles;
  58. this.partitionCols = partitionCols;
  59. this.dpCtx = dpCtx;
  60. }
  61. public FileSinkDesc(final String dirName, final TableDesc tableInfo,
  62. final boolean compressed) {
  63. this.dirName = dirName;
  64. this.tableInfo = tableInfo;
  65. this.compressed = compressed;
  66. destTableId = 0;
  67. this.multiFileSpray = false;
  68. this.numFiles = 1;
  69. this.totalFiles = 1;
  70. this.partitionCols = null;
  71. }
  72. @Explain(displayName = "directory", normalExplain = false)
  73. public String getDirName() {
  74. return dirName;
  75. }
  76. public void setDirName(final String dirName) {
  77. this.dirName = dirName;
  78. }
  79. @Explain(displayName = "table")
  80. public TableDesc getTableInfo() {
  81. return tableInfo;
  82. }
  83. public void setTableInfo(final TableDesc tableInfo) {
  84. this.tableInfo = tableInfo;
  85. }
  86. @Explain(displayName = "compressed")
  87. public boolean getCompressed() {
  88. return compressed;
  89. }
  90. public void setCompressed(boolean compressed) {
  91. this.compressed = compressed;
  92. }
  93. @Explain(displayName = "GlobalTableId")
  94. public int getDestTableId() {
  95. return destTableId;
  96. }
  97. public void setDestTableId(int destTableId) {
  98. this.destTableId = destTableId;
  99. }
  100. public String getCompressCodec() {
  101. return compressCodec;
  102. }
  103. public void setCompressCodec(String intermediateCompressorCodec) {
  104. compressCodec = intermediateCompressorCodec;
  105. }
  106. public String getCompressType() {
  107. return compressType;
  108. }
  109. public void setCompressType(String intermediateCompressType) {
  110. compressType = intermediateCompressType;
  111. }
  112. /**
  113. * @return the multiFileSpray
  114. */
  115. @Explain(displayName = "MultiFileSpray", normalExplain = false)
  116. public boolean isMultiFileSpray() {
  117. return multiFileSpray;
  118. }
  119. /**
  120. * @param multiFileSpray the multiFileSpray to set
  121. */
  122. public void setMultiFileSpray(boolean multiFileSpray) {
  123. this.multiFileSpray = multiFileSpray;
  124. }
  125. /**
  126. * @return the totalFiles
  127. */
  128. @Explain(displayName = "TotalFiles", normalExplain = false)
  129. public int getTotalFiles() {
  130. return totalFiles;
  131. }
  132. /**
  133. * @param totalFiles the totalFiles to set
  134. */
  135. public void setTotalFiles(int totalFiles) {
  136. this.totalFiles = totalFiles;
  137. }
  138. /**
  139. * @return the partitionCols
  140. */
  141. public ArrayList<ExprNodeDesc> getPartitionCols() {
  142. return partitionCols;
  143. }
  144. /**
  145. * @param partitionCols the partitionCols to set
  146. */
  147. public void setPartitionCols(ArrayList<ExprNodeDesc> partitionCols) {
  148. this.partitionCols = partitionCols;
  149. }
  150. /**
  151. * @return the numFiles
  152. */
  153. @Explain(displayName = "NumFilesPerFileSink", normalExplain = false)
  154. public int getNumFiles() {
  155. return numFiles;
  156. }
  157. /**
  158. * @param numFiles the numFiles to set
  159. */
  160. public void setNumFiles(int numFiles) {
  161. this.numFiles = numFiles;
  162. }
  163. public void setDynPartCtx(DynamicPartitionCtx dpc) {
  164. this.dpCtx = dpc;
  165. }
  166. public DynamicPartitionCtx getDynPartCtx() {
  167. return this.dpCtx;
  168. }
  169. public void setStaticSpec(String staticSpec) {
  170. this.staticSpec = staticSpec;
  171. }
  172. @Explain(displayName = "Static Partition Specification", normalExplain = false)
  173. public String getStaticSpec() {
  174. return staticSpec;
  175. }
  176. public void setGatherStats(boolean gatherStats) {
  177. this.gatherStats = gatherStats;
  178. }
  179. @Explain(displayName = "GatherStats", normalExplain = false)
  180. public boolean isGatherStats() {
  181. return gatherStats;
  182. }
  183. /**
  184. * Construct the key prefix used as (intermediate) statistics publishing
  185. * and aggregation. During stats publishing phase, this key prefix will be
  186. * appended with the optional dynamic partition spec and the task ID. The
  187. * whole key uniquely identifies the output of a task for this job. In the
  188. * stats aggregation phase, all rows with the same prefix plus dynamic partition
  189. * specs (obtained at run-time after MR job finishes) will be serving as the
  190. * prefix: all rows with the same prefix (output of all tasks for this job)
  191. * will be aggregated.
  192. * @return key prefix used for stats publishing and aggregation.
  193. */
  194. @Explain(displayName = "Stats Publishing Key Prefix", normalExplain = false)
  195. public String getStatsAggPrefix() {
  196. // dirName uniquely identifies destination directory of a FileSinkOperator.
  197. // If more than one FileSinkOperator write to the same partition, this dirName
  198. // should be different.
  199. return statsKeyPref;
  200. }
  201. /**
  202. * Set the stats aggregation key. If the input string is not terminated by Path.SEPARATOR
  203. * aggregation key will add one to make it as a directory name.
  204. * @param k input directory name.
  205. */
  206. public void setStatsAggPrefix(String k) {
  207. if (k.endsWith(Path.SEPARATOR)) {
  208. statsKeyPref = k;
  209. } else {
  210. statsKeyPref = k + Path.SEPARATOR;
  211. }
  212. }
  213. }