You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by th...@apache.org on 2014/03/12 13:49:59 UTC

svn commit: r1576719 - in /hive/branches/branch-0.13: hcatalog/core/src/main/java/org/apache/hive/hcatalog/mapreduce/ ql/src/java/org/apache/hadoop/hive/ql/io/orc/

Author: thejas
Date: Wed Mar 12 12:49:59 2014
New Revision: 1576719

URL: http://svn.apache.org/r1576719
Log:
HIVE-6507 : OrcFile table property names are specified as strings (Sushanth Sowmyan via Thejas Nair)

Modified:
    hive/branches/branch-0.13/hcatalog/core/src/main/java/org/apache/hive/hcatalog/mapreduce/SpecialCases.java
    hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcFile.java
    hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcOutputFormat.java

Modified: hive/branches/branch-0.13/hcatalog/core/src/main/java/org/apache/hive/hcatalog/mapreduce/SpecialCases.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.13/hcatalog/core/src/main/java/org/apache/hive/hcatalog/mapreduce/SpecialCases.java?rev=1576719&r1=1576718&r2=1576719&view=diff
==============================================================================
--- hive/branches/branch-0.13/hcatalog/core/src/main/java/org/apache/hive/hcatalog/mapreduce/SpecialCases.java (original)
+++ hive/branches/branch-0.13/hcatalog/core/src/main/java/org/apache/hive/hcatalog/mapreduce/SpecialCases.java Wed Mar 12 12:49:59 2014
@@ -48,16 +48,6 @@ public class SpecialCases {
 
   static final private Log LOG = LogFactory.getLog(SpecialCases.class);
 
-  // Orc-specific parameter definitions
-  private final static List<String> 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 class SpecialCases {
       // them to job properties, so that it will be available in jobconf at runtime
       // See HIVE-5504 for details
       Map<String, String> 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));
         }

Modified: hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcFile.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcFile.java?rev=1576719&r1=1576718&r2=1576719&view=diff
==============================================================================
--- hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcFile.java (original)
+++ hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcFile.java Wed Mar 12 12:49:59 2014
@@ -96,13 +96,40 @@ public final class OrcFile {
     }
   }
 
-  // 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 final class OrcFile {
    * 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
    */

Modified: hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcOutputFormat.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcOutputFormat.java?rev=1576719&r1=1576718&r2=1576719&view=diff
==============================================================================
--- hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcOutputFormat.java (original)
+++ hive/branches/branch-0.13/ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcOutputFormat.java Wed Mar 12 12:49:59 2014
@@ -125,29 +125,35 @@ public class OrcOutputFormat extends Fil
   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));
     }