FAQ
Author: kevinwilfong
Date: Tue Nov 20 09:03:26 2012
New Revision: 1411592

URL: http://svn.apache.org/viewvc?rev=1411592&view=rev
Log:
Remove extra files accidentally committed with HIVE-3679. (kevinwilfong)

Removed:
hive/trunk/common/src/java/org/apache/hadoop/hive/conf/LoopingByteArrayInputStream.java
Modified:
hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java

Modified: hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
URL: http://svn.apache.org/viewvc/hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java?rev=1411592&r1=1411591&r2=1411592&view=diff
==============================================================================
--- hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java (original)
+++ hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java Tue Nov 20 09:03:26 2012
@@ -18,10 +18,9 @@

package org.apache.hadoop.hive.conf;

-import java.io.ByteArrayOutputStream;
import java.io.File;
+import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.io.PrintStream;
import java.net.URL;
import java.util.HashMap;
@@ -53,6 +52,7 @@ public class HiveConf extends Configurat
protected String auxJars;
private static final Log l4j = LogFactory.getLog(HiveConf.class);
private static URL hiveSiteURL = null;
+ private static URL confVarURL = null;

private static final Map<String, ConfVars> vars = new HashMap<String, ConfVars>();

@@ -789,34 +789,35 @@ public class HiveConf extends Configurat
}

/**
- * Writes the default ConfVars out to a byte array and returns an input
- * stream wrapping that byte array.
- *
+ * Writes the default ConfVars out to a temporary File and returns
+ * a URL pointing to the temporary file.
* We need this in order to initialize the ConfVar properties
- * in the underling Configuration object using the addResource(InputStream)
+ * in the underling Configuration object using the addResource(URL)
* method.
*
- * It is important to use a LoopingByteArrayInputStream because it turns out
- * addResource(InputStream) is broken since Configuration tries to read the
- * entire contents of the same InputStream repeatedly without resetting it.
- * LoopingByteArrayInputStream has special logic to handle this.
+ * Using Configuration.addResource(InputStream) would be a preferable
+ * approach, but it turns out that method is broken since Configuration
+ * tries to read the entire contents of the same InputStream repeatedly.
*/
- private static synchronized InputStream getConfVarInputStream() {
- byte[] confVarByteArray;
- try {
- Configuration conf = new Configuration();
-
- applyDefaultNonNullConfVars(conf);
-
- ByteArrayOutputStream confVarBaos = new ByteArrayOutputStream();
- conf.writeXml(confVarBaos);
- confVarByteArray = confVarBaos.toByteArray();
- } catch (Exception e) {
- // We're pretty screwed if we can't load the default conf vars
- throw new RuntimeException("Failed to initialize default Hive configuration variables!", e);
+ private static synchronized URL getConfVarURL() {
+ if (confVarURL == null) {
+ try {
+ Configuration conf = new Configuration();
+ File confVarFile = File.createTempFile("hive-default-", ".xml");
+ confVarFile.deleteOnExit();
+
+ applyDefaultNonNullConfVars(conf);
+
+ FileOutputStream fout = new FileOutputStream(confVarFile);
+ conf.writeXml(fout);
+ fout.close();
+ confVarURL = confVarFile.toURI().toURL();
+ } catch (Exception e) {
+ // We're pretty screwed if we can't load the default conf vars
+ throw new RuntimeException("Failed to initialize default Hive configuration variables!", e);
+ }
}
-
- return new LoopingByteArrayInputStream(confVarByteArray);
+ return confVarURL;
}

public static int getIntVar(Configuration conf, ConfVars var) {
@@ -981,7 +982,7 @@ public class HiveConf extends Configurat
origProp = getAllProperties();

// Overlay the ConfVars. Note that this ignores ConfVars with null values
- addResource(getConfVarInputStream());
+ addResource(getConfVarURL());

// Overlay hive-site.xml if it exists
if (hiveSiteURL != null) {

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 1 | next ›
Discussion Overview
groupcommits @
categorieshive, hadoop
postedNov 20, '12 at 9:03a
activeNov 20, '12 at 9:03a
posts1
users1
websitehive.apache.org

1 user in discussion

Kevinwilfong: 1 post

People

Translate

site design / logo © 2021 Grokbase