diff --git common/pom.xml common/pom.xml index 76d0fe7..bd6a817 100644 --- common/pom.xml +++ common/pom.xml @@ -97,7 +97,7 @@ - + hadoop-2 @@ -114,43 +114,6 @@ - - - dist - - - - ../conf/ - - hive-default.xml.template - - - - - - org.apache.maven.plugins - maven-antrun-plugin - - - generate-template - package - - - - - - - - - run - - - - - - - diff --git common/src/java/org/apache/hadoop/hive/common/JavaUtils.java common/src/java/org/apache/hadoop/hive/common/JavaUtils.java index 9aa917c..753aa74 100644 --- common/src/java/org/apache/hadoop/hive/common/JavaUtils.java +++ common/src/java/org/apache/hadoop/hive/common/JavaUtils.java @@ -54,6 +54,15 @@ } } + public static T newInstance(String className, Class clazz) { + try { + return clazz.cast(getClassLoader().loadClass(className).newInstance()); + } catch (Exception e) { + LOG.info("Failed to instanciate " + className, e); + return null; + } + } + /** * Standard way of getting classloader in Hive code (outside of Hadoop). * diff --git common/src/java/org/apache/hadoop/hive/conf/HiveConf.java common/src/java/org/apache/hadoop/hive/conf/HiveConf.java index c49a0f2..aadc535 100644 --- common/src/java/org/apache/hadoop/hive/conf/HiveConf.java +++ common/src/java/org/apache/hadoop/hive/conf/HiveConf.java @@ -41,6 +41,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hive.common.JavaUtils; import org.apache.hadoop.hive.common.classification.InterfaceAudience.LimitedPrivate; import org.apache.hadoop.hive.conf.Validator.PatternSet; import org.apache.hadoop.hive.conf.Validator.RangeValidator; @@ -709,9 +710,11 @@ "when using UDTF's to prevent the task getting killed because of inactivity. Users should be cautious \n" + "because this may prevent TaskTracker from killing tasks with infinite loops."), - HIVEDEFAULTFILEFORMAT("hive.default.fileformat", "TextFile", new StringSet("TextFile", "SequenceFile", "RCfile", "ORC"), + HIVEDEFAULTFILEFORMAT("hive.default.fileformat", "TextFile", + JavaUtils.newInstance("org.apache.hadoop.hive.ql.io.StorageFormatFactory", Validator.class), "Default file format for CREATE TABLE statement. Users can explicitly override it by CREATE TABLE ... STORED AS [FORMAT]"), - HIVEQUERYRESULTFILEFORMAT("hive.query.result.fileformat", "TextFile", new StringSet("TextFile", "SequenceFile", "RCfile"), + HIVEQUERYRESULTFILEFORMAT("hive.query.result.fileformat", "TextFile", + JavaUtils.newInstance("org.apache.hadoop.hive.ql.io.StorageFormatFactory", Validator.class), "Default file format for storing result of the query."), HIVECHECKFILEFORMAT("hive.fileformat.check", true, "Whether to check file format or not when loading data files"), diff --git ql/pom.xml ql/pom.xml index c373431..54d89c6 100644 --- ql/pom.xml +++ ql/pom.xml @@ -675,6 +675,27 @@ + + org.apache.maven.plugins + maven-antrun-plugin + + + generate-template + package + + + + + + + + + run + + + + diff --git ql/src/java/org/apache/hadoop/hive/ql/io/StorageFormatFactory.java ql/src/java/org/apache/hadoop/hive/ql/io/StorageFormatFactory.java index e0bf153..cd2362d 100644 --- ql/src/java/org/apache/hadoop/hive/ql/io/StorageFormatFactory.java +++ ql/src/java/org/apache/hadoop/hive/ql/io/StorageFormatFactory.java @@ -28,8 +28,9 @@ import org.apache.commons.logging.LogFactory; import com.google.common.collect.ImmutableMap; +import org.apache.hadoop.hive.conf.Validator; -public class StorageFormatFactory { +public class StorageFormatFactory implements Validator { private static final Log LOG = LogFactory.getLog(StorageFormatFactory.class); private final Map storageFormats; @@ -55,4 +56,17 @@ public StorageFormatFactory() { name = name.trim().toUpperCase(); return storageFormats.get(name); } + + @Override + public String validate(String value) { + if (value == null || get(value.toUpperCase()) == null) { + return "Invalid value.. expects one of " + storageFormats.keySet(); + } + return null; + } + + @Override + public String toDescription() { + return "Expects one of " + storageFormats.keySet(); + } }