diff --git a/hcatalog/core/src/main/java/org/apache/hive/hcatalog/mapreduce/SpecialCases.java b/hcatalog/core/src/main/java/org/apache/hive/hcatalog/mapreduce/SpecialCases.java index 11a8ebb..0c1fa23 100644 --- a/hcatalog/core/src/main/java/org/apache/hive/hcatalog/mapreduce/SpecialCases.java +++ b/hcatalog/core/src/main/java/org/apache/hive/hcatalog/mapreduce/SpecialCases.java @@ -48,16 +48,6 @@ static final private Log LOG = LogFactory.getLog(SpecialCases.class); - // Orc-specific parameter definitions - private final static List orcTablePropsToCopy = Arrays.asList( - OrcFile.STRIPE_SIZE, - OrcFile.COMPRESSION, - OrcFile.COMPRESSION_BLOCK_SIZE, - OrcFile.ROW_INDEX_STRIDE, - OrcFile.ENABLE_INDEXES, - OrcFile.BLOCK_PADDING - ); - /** * Method to do any file-format specific special casing while * instantiating a storage handler to write. We set any parameters @@ -82,7 +72,8 @@ public static void addSpecialCasesParametersToOutputJobProperties( // them to job properties, so that it will be available in jobconf at runtime // See HIVE-5504 for details Map tableProps = jobInfo.getTableInfo().getTable().getParameters(); - for (String propName : orcTablePropsToCopy){ + for (OrcFile.OrcTableProperties property : OrcFile.OrcTableProperties.values()){ + String propName = property.getPropName(); if (tableProps.containsKey(propName)){ jobProperties.put(propName,tableProps.get(propName)); } diff --git a/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcFile.java b/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcFile.java index a56fe2f..6b6b508 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcFile.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcFile.java @@ -96,13 +96,40 @@ public int getMinor() { } } - // the table properties that control ORC files - public static final String COMPRESSION = "orc.compress"; - public static final String COMPRESSION_BLOCK_SIZE = "orc.compress.size"; - public static final String STRIPE_SIZE = "orc.stripe.size"; - public static final String ROW_INDEX_STRIDE = "orc.row.index.stride"; - public static final String ENABLE_INDEXES = "orc.create.index"; - public static final String BLOCK_PADDING = "orc.block.padding"; + + // Note : these string definitions for table properties are deprecated, + // and retained only for backward compatibility, please do not add to + // them, add to OrcTableProperties below instead + @Deprecated public static final String COMPRESSION = "orc.compress"; + @Deprecated public static final String COMPRESSION_BLOCK_SIZE = "orc.compress.size"; + @Deprecated public static final String STRIPE_SIZE = "orc.stripe.size"; + @Deprecated public static final String ROW_INDEX_STRIDE = "orc.row.index.stride"; + @Deprecated public static final String ENABLE_INDEXES = "orc.create.index"; + @Deprecated public static final String BLOCK_PADDING = "orc.block.padding"; + + /** + * Enum container for all orc table properties. + * If introducing a new orc-specific table property, + * add it here. + */ + public static enum OrcTableProperties { + COMPRESSION("orc.compress"), + COMPRESSION_BLOCK_SIZE("orc.compress.size"), + STRIPE_SIZE("orc.stripe.size"), + ROW_INDEX_STRIDE("orc.row.index.stride"), + ENABLE_INDEXES("orc.create.index"), + BLOCK_PADDING("orc.block.padding"); + + private final String propName; + + OrcTableProperties(String propName) { + this.propName = propName; + } + + public String getPropName(){ + return this.propName; + } + } // unused private OrcFile() {} @@ -263,7 +290,7 @@ public static WriterOptions writerOptions(Configuration conf) { * Create an ORC file writer. This is the public interface for creating * writers going forward and new options will only be added to this method. * @param path filename to write to - * @param options the options + * @param opts the options * @return a new ORC file writer * @throws IOException */ diff --git a/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcOutputFormat.java b/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcOutputFormat.java index f245608..b3e983f 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcOutputFormat.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcOutputFormat.java @@ -125,29 +125,35 @@ private String getSettingFromPropsFallingBackToConf(String key, Properties props private OrcFile.WriterOptions getOptions(JobConf conf, Properties props) { OrcFile.WriterOptions options = OrcFile.writerOptions(conf); String propVal ; - if ((propVal = getSettingFromPropsFallingBackToConf(OrcFile.STRIPE_SIZE,props,conf)) != null){ + if ((propVal = getSettingFromPropsFallingBackToConf( + OrcFile.OrcTableProperties.STRIPE_SIZE.getPropName(),props,conf)) != null){ options.stripeSize(Long.parseLong(propVal)); } - if ((propVal = getSettingFromPropsFallingBackToConf(OrcFile.COMPRESSION,props,conf)) != null){ + if ((propVal = getSettingFromPropsFallingBackToConf( + OrcFile.OrcTableProperties.COMPRESSION.getPropName(),props,conf)) != null){ options.compress(CompressionKind.valueOf(propVal)); } - if ((propVal = getSettingFromPropsFallingBackToConf(OrcFile.COMPRESSION_BLOCK_SIZE,props,conf)) != null){ + if ((propVal = getSettingFromPropsFallingBackToConf( + OrcFile.OrcTableProperties.COMPRESSION_BLOCK_SIZE.getPropName(),props,conf)) != null){ options.bufferSize(Integer.parseInt(propVal)); } - if ((propVal = getSettingFromPropsFallingBackToConf(OrcFile.ROW_INDEX_STRIDE,props,conf)) != null){ + if ((propVal = getSettingFromPropsFallingBackToConf( + OrcFile.OrcTableProperties.ROW_INDEX_STRIDE.getPropName(),props,conf)) != null){ options.rowIndexStride(Integer.parseInt(propVal)); } - if ((propVal = getSettingFromPropsFallingBackToConf(OrcFile.ENABLE_INDEXES,props,conf)) != null){ + if ((propVal = getSettingFromPropsFallingBackToConf( + OrcFile.OrcTableProperties.ENABLE_INDEXES.getPropName(),props,conf)) != null){ if ("false".equalsIgnoreCase(propVal)) { options.rowIndexStride(0); } } - if ((propVal = getSettingFromPropsFallingBackToConf(OrcFile.BLOCK_PADDING,props,conf)) != null){ + if ((propVal = getSettingFromPropsFallingBackToConf( + OrcFile.OrcTableProperties.BLOCK_PADDING.getPropName(),props,conf)) != null){ options.blockPadding(Boolean.parseBoolean(propVal)); }