Forráskód Böngészése

HADOOP-3601. Add a new contrib module for Hive, which is a sql-like
query processing tool that uses map/reduce. (Ashish Thusoo via omalley)


git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@691438 13f79535-47bb-0310-9956-ffa450edef68

Owen O'Malley 17 éve
szülő
commit
d8bd7688f8
100 módosított fájl, 14505 hozzáadás és 0 törlés
  1. 3 0
      CHANGES.txt
  2. 285 0
      src/contrib/hive/README
  3. 37 0
      src/contrib/hive/ant/build.xml
  4. 261 0
      src/contrib/hive/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java
  5. 24 0
      src/contrib/hive/ant/src/org/apache/hadoop/hive/ant/antlib.xml
  6. 96 0
      src/contrib/hive/bin/hive
  7. 66 0
      src/contrib/hive/bin/hive-config.sh
  8. 238 0
      src/contrib/hive/build-common.xml
  9. 160 0
      src/contrib/hive/build.xml
  10. 34 0
      src/contrib/hive/cli/build.xml
  11. 5 0
      src/contrib/hive/cli/lib/README
  12. 32 0
      src/contrib/hive/cli/lib/jline-0.9.94.LICENSE
  13. BIN
      src/contrib/hive/cli/lib/jline-0.9.94.jar
  14. 202 0
      src/contrib/hive/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java
  15. 48 0
      src/contrib/hive/cli/src/java/org/apache/hadoop/hive/cli/CliSessionState.java
  16. 64 0
      src/contrib/hive/cli/src/java/org/apache/hadoop/hive/cli/MetadataProcessor.java
  17. 222 0
      src/contrib/hive/cli/src/java/org/apache/hadoop/hive/cli/OptionsProcessor.java
  18. 101 0
      src/contrib/hive/cli/src/java/org/apache/hadoop/hive/cli/SetProcessor.java
  19. 34 0
      src/contrib/hive/common/build.xml
  20. 246 0
      src/contrib/hive/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
  21. 24 0
      src/contrib/hive/conf/configuration.xsl
  22. 87 0
      src/contrib/hive/conf/hive-default.xml
  23. 61 0
      src/contrib/hive/conf/hive-log4j.properties
  24. 15 0
      src/contrib/hive/conf/jpox.properties
  25. 123 0
      src/contrib/hive/data/conf/hive-default.xml
  26. 1 0
      src/contrib/hive/data/conf/hive-log4j.properties
  27. BIN
      src/contrib/hive/data/files/complex.seq
  28. BIN
      src/contrib/hive/data/files/kv1.seq
  29. 500 0
      src/contrib/hive/data/files/kv1.string-sorted.txt
  30. 500 0
      src/contrib/hive/data/files/kv1.txt
  31. 500 0
      src/contrib/hive/data/files/kv1.val.sorted.txt
  32. 1000 0
      src/contrib/hive/data/files/kv1kv2.cogroup.txt
  33. 500 0
      src/contrib/hive/data/files/kv2.txt
  34. 25 0
      src/contrib/hive/data/files/kv3.txt
  35. 84 0
      src/contrib/hive/data/files/lt100.sorted.txt
  36. 84 0
      src/contrib/hive/data/files/lt100.txt
  37. 14 0
      src/contrib/hive/lib/README
  38. 29 0
      src/contrib/hive/lib/asm-3.1.LICENSE
  39. BIN
      src/contrib/hive/lib/asm-3.1.jar
  40. 201 0
      src/contrib/hive/lib/commons-collections-3.2.1.LICENSE
  41. BIN
      src/contrib/hive/lib/commons-collections-3.2.1.jar
  42. 201 0
      src/contrib/hive/lib/commons-lang-2.4.LICENSE
  43. BIN
      src/contrib/hive/lib/commons-lang-2.4.jar
  44. 201 0
      src/contrib/hive/lib/derby.LICENSE
  45. BIN
      src/contrib/hive/lib/derby.jar
  46. 201 0
      src/contrib/hive/lib/jdo2-api-2.1.LICENSE
  47. BIN
      src/contrib/hive/lib/jdo2-api-2.1.jar
  48. 174 0
      src/contrib/hive/lib/jpox-core-1.2.2.LICENSE
  49. BIN
      src/contrib/hive/lib/jpox-core-1.2.2.jar
  50. 174 0
      src/contrib/hive/lib/jpox-enhancer-1.2.2.LICENSE
  51. BIN
      src/contrib/hive/lib/jpox-enhancer-1.2.2.jar
  52. 174 0
      src/contrib/hive/lib/jpox-rdbms-1.2.2.LICENSE
  53. BIN
      src/contrib/hive/lib/jpox-rdbms-1.2.2.jar
  54. 19 0
      src/contrib/hive/lib/libfb303.LICENSE
  55. BIN
      src/contrib/hive/lib/libfb303.jar
  56. 19 0
      src/contrib/hive/lib/libthrift.LICENSE
  57. BIN
      src/contrib/hive/lib/libthrift.jar
  58. BIN
      src/contrib/hive/lib/velocity-1.5.jar
  59. 201 0
      src/contrib/hive/lib/velocity.LICENSE
  60. 93 0
      src/contrib/hive/metastore/build.xml
  61. 6 0
      src/contrib/hive/metastore/derby.log
  62. 291 0
      src/contrib/hive/metastore/if/hive_metastore.thrift
  63. 151 0
      src/contrib/hive/metastore/include/thrift/TLogging.h
  64. 41 0
      src/contrib/hive/metastore/include/thrift/TProcessor.h
  65. 84 0
      src/contrib/hive/metastore/include/thrift/TReflectionLocal.h
  66. 162 0
      src/contrib/hive/metastore/include/thrift/Thrift.h
  67. 47 0
      src/contrib/hive/metastore/include/thrift/concurrency/Exception.h
  68. 72 0
      src/contrib/hive/metastore/include/thrift/concurrency/Monitor.h
  69. 94 0
      src/contrib/hive/metastore/include/thrift/concurrency/Mutex.h
  70. 118 0
      src/contrib/hive/metastore/include/thrift/concurrency/PosixThreadFactory.h
  71. 112 0
      src/contrib/hive/metastore/include/thrift/concurrency/Thread.h
  72. 157 0
      src/contrib/hive/metastore/include/thrift/concurrency/ThreadManager.h
  73. 108 0
      src/contrib/hive/metastore/include/thrift/concurrency/TimerManager.h
  74. 91 0
      src/contrib/hive/metastore/include/thrift/concurrency/Util.h
  75. 260 0
      src/contrib/hive/metastore/include/thrift/config.h
  76. 96 0
      src/contrib/hive/metastore/include/thrift/fb303/FacebookBase.h
  77. 1583 0
      src/contrib/hive/metastore/include/thrift/fb303/FacebookService.h
  78. 202 0
      src/contrib/hive/metastore/include/thrift/fb303/ServiceTracker.h
  79. 23 0
      src/contrib/hive/metastore/include/thrift/fb303/fb303_constants.h
  80. 30 0
      src/contrib/hive/metastore/include/thrift/fb303/fb303_types.h
  81. 108 0
      src/contrib/hive/metastore/include/thrift/fb303/if/fb303.thrift
  82. 71 0
      src/contrib/hive/metastore/include/thrift/if/reflection_limited.thrift
  83. 64 0
      src/contrib/hive/metastore/include/thrift/processor/PeekProcessor.h
  84. 252 0
      src/contrib/hive/metastore/include/thrift/processor/StatsProcessor.h
  85. 239 0
      src/contrib/hive/metastore/include/thrift/protocol/TBinaryProtocol.h
  86. 194 0
      src/contrib/hive/metastore/include/thrift/protocol/TDebugProtocol.h
  87. 238 0
      src/contrib/hive/metastore/include/thrift/protocol/TDenseProtocol.h
  88. 147 0
      src/contrib/hive/metastore/include/thrift/protocol/TOneWayProtocol.h
  89. 353 0
      src/contrib/hive/metastore/include/thrift/protocol/TProtocol.h
  90. 93 0
      src/contrib/hive/metastore/include/thrift/protocol/TProtocolException.h
  91. 285 0
      src/contrib/hive/metastore/include/thrift/reflection_limited_types.h
  92. 331 0
      src/contrib/hive/metastore/include/thrift/server/TNonblockingServer.h
  93. 193 0
      src/contrib/hive/metastore/include/thrift/server/TServer.h
  94. 58 0
      src/contrib/hive/metastore/include/thrift/server/TSimpleServer.h
  95. 66 0
      src/contrib/hive/metastore/include/thrift/server/TThreadPoolServer.h
  96. 55 0
      src/contrib/hive/metastore/include/thrift/server/TThreadedServer.h
  97. 429 0
      src/contrib/hive/metastore/include/thrift/transport/TFileTransport.h
  98. 99 0
      src/contrib/hive/metastore/include/thrift/transport/THttpClient.h
  99. 59 0
      src/contrib/hive/metastore/include/thrift/transport/TServerSocket.h
  100. 80 0
      src/contrib/hive/metastore/include/thrift/transport/TServerTransport.h

+ 3 - 0
CHANGES.txt

@@ -117,6 +117,9 @@ Trunk (unreleased changes)
     HADOOP-3939. Add an option to DistCp to delete files at the destination
     not present at the source. (Tsz Wo (Nicholas) Sze via cdouglas)
 
+    HADOOP-3601. Add a new contrib module for Hive, which is a sql-like
+    query processing tool that uses map/reduce. (Ashish Thusoo via omalley)
+
   IMPROVEMENTS
 
     HADOOP-3908. Fuse-dfs: better error message if llibhdfs.so doesn't exist.

+ 285 - 0
src/contrib/hive/README

@@ -0,0 +1,285 @@
+How to Hive
+-----------
+
+DISCLAIMER: This is a prototype version of Hive and is NOT production 
+quality. This is provided mainly as a way of illustrating the capabilities 
+of Hive and is provided as-is. However - we are working hard to make 
+Hive a production quality system. Hive has only been tested on unix(linux) 
+and mac systems using Java 1.6 for now - although it may very well work 
+on other similar platforms. It does not work on Cygwin right now. Most of 
+our testing has been on Hadoop 0.17 - so we would advise running it against 
+this version of hadoop - even though it may compile/work against other versions
+
+
+Downloading and building
+------------------------
+
+You can either build hive jar files for your environment:
+- apply patch
+- cd hadoop/src/contrib/hive
+- src/contrib/hive> ant -Dtarget.dir=<your-install-dir> package
+
+Or you can use the pre-packaged jars that is available at the following location
+and untar it: 
+http://mirror.facebook.com/facebook/hive/hadoop-0.17/dist.tar.gz
+
+$ wget http://mirror.facebook.com/facebook/hive/hadoop-0.17/dist.tar.gz
+$ tar zxvf dist.tar.gz
+$ cd dist
+$ ls
+README  bin conf  lib 
+
+bin/ (all the shell scripts)
+lib/ (required jar files)
+conf/ (configuration files)
+
+In the rest of the README, we use dist and <install-dir> interchangeably.
+
+Running Hive
+------------
+
+Hive uses hadoop  that means:
+- you must have hadoop in your path OR
+- export HADOOP=<hadoop-install-dir>/bin/hadoop
+
+To use hive command line interface (cli) from the shell:
+$ bin/hive
+
+Using Hive
+----------
+
+Configuration management overview
+---------------------------------
+
+- hive configuration is stored in <install-dir>/conf/hive-default.xml 
+  and log4j in hive-log4j.properties
+- hive configuration is an overlay on top of hadoop - meaning the 
+  hadoop configuration variables are inherited by default.
+- hive configuration can be manipulated by:
+  o editing hive-default.xml and defining any desired variables 
+    (including hadoop variables) in it
+  o from the cli using the set command (see below) 
+  o by invoking hive using the syntax:
+     * bin/hive -hiveconf x1=y1 -hiveconf x2=y2
+    this sets the variables x1 and x2 to y1 and y2
+
+
+Error Logs
+----------
+Hive uses log4j for logging. By default logs are not emitted to the 
+console by the cli. They are stored in the file:
+- /tmp/{user.name}/hive.log
+
+If the user wishes - the logs can be emitted to the console by adding 
+the arguments shown below:
+- bin/hive -hiveconf hive.root.logger=INFO,console
+
+Note that setting hive.root.logger via the 'set' command does not 
+change logging properties since they are determined at initialization time.
+
+Error logs are very useful to debug problems. Please send them with 
+any bugs (of which there are many!) to athusoo@facebok.com.
+
+
+DDL Operations
+--------------
+
+Creating Hive tables and browsing through them
+
+hive> CREATE TABLE pokes (foo INT, bar STRING);  
+
+Creates a table called pokes with two columns, first being an 
+integer and other a string columns
+
+hive> CREATE TABLE invites (foo INT, bar STRING) PARTITIONED BY (ds STRING);  
+
+Creates a table called invites with two columns and a partition column 
+called ds. The partition column is a virtual column  it is not part 
+of the data itself  but is derived from the partition that a 
+particular dataset is loaded into.
+
+
+By default tables are assumed to be of text input format and the 
+delimiters are assumed to be ^A(ctrl-a). We will be soon publish additional 
+commands/recipes to add binary (sequencefiles) data and configurable 
+delimiters etc.
+
+hive> SHOW TABLES;
+
+lists all the tables
+
+hive> SHOW TABLES '.*s';
+
+lists all the table that end with 's'. The pattern matching follows Java regular 
+expressions. Check out this link for documentation 
+http://java.sun.com/javase/6/docs/api/java/util/regex/Pattern.html
+
+hive> DESCRIBE invites;
+
+shows the list of columns
+
+Altering tables. Table name can be changed and additional columns can be dropped
+
+hive> ALTER TABLE pokes ADD COLUMNS (new_col INT);
+hive> ALTER TABLE invites ADD COLUMNS (new_col2 INT COMMENT 'a comment');
+hive> ALTER TABLE events RENAME TO 3koobecaf;
+
+Dropping tables
+hive> DROP TABLE pokes;
+
+
+Metadata Store
+--------------
+
+Metadata is in an embedded Derby database whose location is determined by the 
+hive configuration variable named javax.jdo.option.ConnectionURL. By default 
+(see conf/hive-default.xml) - this location is ./metastore_db
+
+Right now - in the default configuration, this metadata can only be seen by 
+one user at a time. 
+
+Metastore can be stored in any database that is supported by JPOX. The 
+location and the type of the RDBMS can be controlled by the two variables 
+'javax.jdo.option.ConnectionURL' and 'javax.jdo.option.ConnectionDriverName'. 
+Refer to JDO (or JPOX) documentation for more details on supported databases. 
+The database schema is defined in JDO metadata annotations file package.jdo 
+at src/contrib/hive/metastore/src/model.
+
+In the future - the metastore itself can be a standalone server.
+
+
+DML Operations
+--------------
+
+Loading data from flat files into Hive
+
+hive> LOAD DATA LOCAL INPATH './examples/files/kv1.txt' OVERWRITE INTO TABLE pokes; 
+
+Loads a file that contains two columns separated by ctrl-a into pokes table. 
+'local' signifies that the input file is on the local system. If 'local' 
+is omitted then it looks for the file in HDFS.
+
+The keyword 'overwrite' signifies that existing data in the table is deleted. 
+If the 'overwrite' keyword is omitted - then data files are appended to existing data sets.
+
+NOTES:
+- NO verification of data against the schema
+- if the file is in hdfs it is moved into hive controlled file system namespace. 
+  The root of the hive directory is specified by the option hive.metastore.warehouse.dir 
+  in hive-default.xml. We would advise that this directory be pre-existing before 
+  trying to create tables via Hive.
+
+hive> LOAD DATA LOCAL INPATH './examples/files/kv2.txt' OVERWRITE INTO TABLE invites PARTITION (ds='2008-08-15');
+hive> LOAD DATA LOCAL INPATH './examples/files/kv3.txt' OVERWRITE INTO TABLE invites PARTITION (ds='2008-08-08');
+
+The two LOAD statements above load data into two different partitions of the table
+invites. Table invites must be created as partitioned by the key ds for this to succeed.
+
+Loading/Extracting data using Queries
+-------------------------------------
+
+Runtime configuration
+---------------------
+
+- Hives queries are executed using map-reduce queries and as such the behavior 
+  of such queries can be controlled by the hadoop configuration variables
+
+- The cli can be used to set any hadoop (or hive) configuration variable. For example:
+   o hive> SET mapred.job.tracker=myhost.mycompany.com:50030
+   o hive> SET - v 
+  The latter shows all the current settings. Without the v option only the 
+  variables that differ from the base hadoop configuration are displayed
+- In particular the number of reducers should be set to a reasonable number 
+  to get good performance (the default is 1!)
+
+
+EXAMPLE QUERIES
+---------------
+
+Some example queries are shown below. They are available in examples/queries.
+More are available in the hive contrib sources src/test/queries/positive
+
+SELECTS and FILTERS
+-------------------
+
+hive> SELECT a.foo FROM invites a;
+
+select column 'foo' from all rows of invites table. The results are not
+stored anywhere, but are displayed on the console.
+
+Note that in all the examples that follow, INSERT (into a hive table, local 
+directory or HDFS directory) is optional. 
+
+hive> INSERT OVERWRITE DIRECTORY '/tmp/hdfs_out' SELECT a.* FROM invites a;
+
+select all rows from invites table into an HDFS  directory. The result data 
+is in files (depending on the number of mappers) in that directory.
+NOTE: partition columns if any are selected by the use of *. They can also 
+be specified in the projection clauses.
+
+hive> INSERT OVERWRITE LOCAL DIRECTORY '/tmp/local_out' SELECT a.* FROM pokes a;
+
+Select all rows from pokes table into a local directory
+
+hive> INSERT OVERWRITE TABLE events SELECT a.* FROM profiles a;
+hive> INSERT OVERWRITE TABLE events SELECT a.* FROM profiles a WHERE a.key < 100; 
+hive> INSERT OVERWRITE LOCAL DIRECTORY '/tmp/reg_3' SELECT a.* FROM events a;
+hive> INSERT OVERWRITE DIRECTORY '/tmp/reg_4' select a.invites, a.pokes FROM profiles a;
+hive> INSERT OVERWRITE DIRECTORY '/tmp/reg_5' SELECT COUNT(1) FROM invites a;
+hive> INSERT OVERWRITE DIRECTORY '/tmp/reg_5' SELECT a.foo, a.bar FROM invites a;
+hive> INSERT OVERWRITE LOCAL DIRECTORY '/tmp/sum' SELECT SUM(a.pc) FROM pc1 a;
+
+Sum of a column. avg, min, max can also be used
+
+NOTE: there are some flaws with the type system that cause doubles to be 
+returned with integer types would be expected. We expect to fix these in the coming week.
+
+GROUP BY
+--------
+
+hive> FROM invites a INSERT OVERWRITE TABLE events SELECT a.bar, count(1) WHERE a.foo > 0 GROUP BY a.bar;
+hive> INSERT OVERWRITE TABLE events SELECT a.bar, count(1) FROM invites a WHERE a.foo > 0 GROUP BY a.bar;
+
+NOTE: Currently Hive always uses two stage map-reduce for groupby operation. This is 
+to handle skews in input data. We will be optimizing this in the coming weeks.
+
+JOIN
+----
+
+hive> FROM pokes t1 JOIN invites t2 ON (t1.bar = t2.bar) INSERT OVERWRITE TABLE events SELECT t1.bar, t1.foo, t2.foo
+
+MULTITABLE INSERT
+-----------------
+FROM src
+INSERT OVERWRITE TABLE dest1 SELECT src.* WHERE src.key < 100
+INSERT OVERWRITE TABLE dest2 SELECT src.key, src.value WHERE src.key >= 100 and src.key < 200
+INSERT OVERWRITE TABLE dest3 PARTITION(ds='2008-04-08', hr='12') SELECT src.key WHERE src.key >= 200 and src.key < 300
+INSERT OVERWRITE LOCAL DIRECTORY '/tmp/dest4.out' SELECT src.value WHERE src.key >= 300
+
+STREAMING
+---------
+hive> FROM invites a INSERT OVERWRITE TABLE events SELECT TRANSFORM(a.foo, a.bar) AS (oof, rab) USING '/bin/cat' WHERE a.ds > '2008-08-09';
+
+This streams the data in the map phase through the script /bin/cat (like hadoop streaming). 
+Similarly - streaming can be used on the reduce side (please see the Hive Tutorial or examples)
+
+KNOWN BUGS/ISSUES
+-----------------
+* hive cli may hang for a couple of minutes because of a bug in getting metadata
+  from the derby database. let it run and you'll be fine!
+* hive cli does not support multi-line queries.
+* hive cli creates derby.log in the directory from which it has been invoked.
+* DESCRIBE table currently only shows columns in a table. Other metadata like
+  partitions, buckets etc are not shown.
+* LOAD FILE or INSERT INTO TABLE do not validate schemas of the destination tables.
+* COUNT(*) does not work for now. Use COUNT(1) instead.
+* String literals are indicated by single quotes(double quotes are not supported). 
+  So 'is a valid string' while "is not a valid string" in the query language. Hive
+  does support escaping quotes and semi-colon similar to MySQL.
+* Multiple GROUP BYs are not supported in the multi-table table INSERT queries.
+* ORDER BY not supported.
+* Only string and thrift types (http://developers.facebook.com/thrift) have been tested.
+
+
+FUTURE FEATURES
+---------------

+ 37 - 0
src/contrib/hive/ant/build.xml

@@ -0,0 +1,37 @@
+<?xml version="1.0"?>
+
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+
+
+<!--
+Before you can run these subtargets directly, you need
+to call at top-level: ant deploy-contrib compile-core-test
+-->
+<project name="anttasks" default="jar">
+
+  <property name="src.dir"  location="${basedir}/src"/>
+  <import file="../build-common.xml"/>
+
+  <target name="jar" depends="compile">
+    <copy file="${src.dir}/org/apache/hadoop/hive/ant/antlib.xml"
+          todir="${build.dir}/classes/org/apache/hadoop/hive/ant"/>
+    <jar destfile="${build.dir}/hive_anttasks.jar">
+      <fileset dir="${build.dir}/classes"/>
+    </jar>
+  </target>
+</project>

+ 261 - 0
src/contrib/hive/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java

@@ -0,0 +1,261 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ant;
+
+import java.io.*;
+import java.util.StringTokenizer;
+
+import org.apache.tools.ant.AntClassLoader;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.Project;
+
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.exception.MethodInvocationException;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.apache.velocity.runtime.RuntimeConstants;
+
+public class QTestGenTask extends Task {
+
+  public class QFileFilter implements FileFilter {
+  
+    public boolean accept(File fpath) {
+      if (fpath.isDirectory() ||
+          !fpath.getName().endsWith(".q")) {
+        return false;
+      }
+      return true;
+    }
+    
+  }
+
+  protected String templatePath;
+
+  protected String outputDirectory;
+ 
+  protected String queryDirectory;
+ 
+  protected String queryFile;
+ 
+  protected String resultsDirectory;
+
+  protected String template;
+
+  protected String className;
+
+  protected String logFile;
+
+  public void setLogFile(String logFile) {
+    this.logFile = logFile;
+  }
+
+  public String getLogFile() {
+    return logFile;
+  }
+
+  public void setClassName(String className) {
+    this.className = className;
+  }
+
+  public String getClassName() {
+    return className;
+  }
+
+  public void setTemplate(String template) {
+    this.template = template;
+  }
+
+  public String getTemplate() {
+    return template;
+  }
+
+  public void setTemplatePath(String templatePath) throws Exception {
+    StringBuffer resolvedPath = new StringBuffer();
+    StringTokenizer st = new StringTokenizer(templatePath, ",");
+    while (st.hasMoreTokens()) {
+      // resolve relative path from basedir and leave
+      // absolute path untouched.
+      File fullPath = project.resolveFile(st.nextToken());
+      resolvedPath.append(fullPath.getCanonicalPath());
+      if (st.hasMoreTokens()) {
+        resolvedPath.append(",");
+      }
+    }
+    this.templatePath = resolvedPath.toString();
+    System.out.println("Template Path:" + this.templatePath);
+  }
+
+  public String getTemplatePath() {
+    return templatePath;
+  }
+
+  public void setOutputDirectory(File outputDirectory) {
+    try {
+      this.outputDirectory = outputDirectory.getCanonicalPath();
+    }
+    catch (IOException ioe) {
+      throw new BuildException(ioe);
+    }
+  }
+
+  public String getOutputDirectory() {
+    return outputDirectory;
+  }
+
+  public void setResultsDirectory(String resultsDirectory) {
+    this.resultsDirectory = resultsDirectory;
+  }
+
+  public String getResultsDirectory() {
+    return this.resultsDirectory;
+  }
+
+  public void setQueryDirectory(String queryDirectory) {
+    this.queryDirectory = queryDirectory;
+  }
+
+  public String getQueryDirectory() {
+    return this.queryDirectory;
+  }
+
+  public void setQueryFile(String queryFile) {
+    this.queryFile = queryFile;
+  }
+
+  public String getQueryFile() {
+    return this.queryFile;
+  }
+
+  /**
+   * Invoke {@link org.apache.hadoop.fs.FsShell#doMain FsShell.doMain} after a
+   * few cursory checks of the configuration.
+   */
+  public void execute() throws BuildException {
+
+    if (templatePath == null) {
+      throw new BuildException("No templatePath attribute specified");
+    }
+
+    if (template == null) {
+      throw new BuildException("No template attribute specified");
+    }
+
+    if (outputDirectory == null) {
+      throw new BuildException("No outputDirectory specified");
+    }
+
+    if (queryDirectory == null && queryFile == null ) {
+      throw new BuildException("No queryDirectory or queryFile specified");
+    }
+
+    if (resultsDirectory == null) {
+      throw new BuildException("No resultsDirectory specified");
+    }
+
+    if (className == null) {
+      throw new BuildException("No className specified");
+    }
+
+    File [] qFiles = null;
+    File outDir = null;
+    File resultsDir = null;
+    
+    try {
+      File inpDir = null;
+      if (queryDirectory != null) {
+        inpDir = new File(queryDirectory);
+      }
+
+      if (queryFile != null && !queryFile.equals("")) {
+        qFiles = new File[1];
+        qFiles[0] = inpDir != null ? new File(inpDir, queryFile) : new File(queryFile);
+      }
+      else {
+        qFiles = inpDir.listFiles(new QFileFilter());
+      }
+
+      // Make sure the output directory exists, if it doesn't
+      // then create it.
+      outDir = new File(outputDirectory);
+      if (!outDir.exists()) {
+        outDir.mkdirs();
+      }
+      
+      resultsDir = new File(resultsDirectory);
+      if (!resultsDir.exists()) {
+        throw new BuildException("Results Directory " + resultsDir.getCanonicalPath() + " does not exist");
+      }
+    }
+    catch (Exception e) {
+      throw new BuildException(e);
+    }
+    
+    VelocityEngine ve = new VelocityEngine();
+
+    try {
+      ve.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, templatePath);
+      if (logFile != null) {
+        File lf = new File(logFile);
+        if (lf.exists()) {
+          if (!lf.delete()) {
+            throw new Exception("Could not delete log file " + lf.getCanonicalPath());
+          }
+        }
+
+        ve.setProperty(RuntimeConstants.RUNTIME_LOG, logFile);
+      }
+
+      ve.init();
+      Template t = ve.getTemplate(template);
+
+      // For each of the qFiles generate the test
+      VelocityContext ctx = new VelocityContext();
+      ctx.put("className", className);
+      ctx.put("qfiles", qFiles);
+      ctx.put("resultsDir", resultsDir);
+
+      File outFile = new File(outDir, className + ".java");
+      FileWriter writer = new FileWriter(outFile);
+      t.merge(ctx, writer);
+      writer.close();
+
+      System.out.println("Generated " + outFile.getCanonicalPath() + " from template " + template);
+    }
+    catch(BuildException e) {
+      throw e;
+    }
+    catch(MethodInvocationException e) {
+      throw new BuildException("Exception thrown by '" + e.getReferenceName() + "." +
+                               e.getMethodName() +"'",
+                               e.getWrappedThrowable());
+    }
+    catch(ParseErrorException e) {
+      throw new BuildException("Velocity syntax error", e);
+    }
+    catch(ResourceNotFoundException e) {
+      throw new BuildException("Resource not found", e);
+    }
+    catch(Exception e) {
+      throw new BuildException("Generation failed", e);
+    }
+  }
+}

+ 24 - 0
src/contrib/hive/ant/src/org/apache/hadoop/hive/ant/antlib.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+
+
+<antlib>
+  <taskdef name="qtestgen"
+           classname="org.apache.hadoop.hive.ant.QTestGenTask" />
+</antlib>

+ 96 - 0
src/contrib/hive/bin/hive

@@ -0,0 +1,96 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+bin=`dirname "$0"`
+bin=`cd "$bin"; pwd`
+
+. "$bin"/hive-config.sh
+
+CLASSPATH="${HIVE_CONF_DIR}"
+
+HIVE_LIB=${HIVE_HOME}/lib
+
+# needed for execution
+if [ ! -f "${HIVE_LIB}/hive_exec.jar" ]; then
+  echo "Missing Hive Execution Jar: ${HIVE_LIB}/hive_exec.jar"
+  exit 1;
+fi
+
+if [ ! -f "${HIVE_LIB}/hive_metastore.jar" ]; then
+  echo "Missing Hive MetaStore Jar"
+  exit 2;
+fi
+
+# cli specific code
+if [ ! -f "${HIVE_LIB}/hive_cli.jar" ]; then
+  echo "Missing Hive CLI Jar"
+  exit 3;
+fi
+
+for f in ${HIVE_LIB}/*.jar; do
+  CLASSPATH=${CLASSPATH}:$f;
+done
+
+# add the auxillary jars such as serdes
+if [ -d "${HIVE_AUX_JARS_PATH}" ]; then
+  for f in ${HIVE_AUX_JARS_PATH}/*.jar; do
+    AUX_CLASSPATH=${AUX_CLASSPATH}:$f;
+    if [ "${AUX_PARAM}" == "" ]; then
+        AUX_PARAM=$f
+    else
+        AUX_PARAM=${AUX_PARAM},$f;
+    fi
+  done
+else
+  AUX_CLASSPATH=${HIVE_AUX_JARS_PATH}
+  AUX_PARAM=${HIVE_AUX_JARS_PATH}
+fi
+CLASSPATH=${CLASSPATH}:${AUX_CLASSPATH}
+
+
+# pass classpath to hadoop
+export HADOOP_CLASSPATH=${CLASSPATH}
+
+# point to the first available hadoop instance
+HADOOP_IN_PATH=`which hadoop 2>/dev/null`
+HADOOP=${HADOOP:-$HADOOP_IN_PATH}
+if [ "$HADOOP" == "" ]; then
+  echo "Cannot find hadoop installation: 'hadoop' must be in your path or specified via \$HADOOP";
+  exit 4;
+fi
+
+if [ ! -f ${HADOOP} ]; then
+  echo "Cannot find hadoop installation: \"$HADOOP\" does not exist";
+  exit 4;
+fi
+
+# override default value of hadoop.bin.path to point to what we are running off
+# if the user specified a -D override - this will be further overriden
+export HADOOP_OPTS="$HADOOP_OPTS -Dhadoop.bin.path=$HADOOP"
+
+CLASS=org.apache.hadoop.hive.cli.CliDriver
+
+if [ "${AUX_PARAM}" != "" ]; then
+  HADOOP_OPTS="-Dhive.aux.jars.path=${AUX_PARAM}"
+  AUX_JARS_CMD_LINE="-libjars ${AUX_PARAM}"
+fi
+#echo "CLASSPATH="$CLASSPATH
+#echo "AUX_LIB_PATH"=$AUX_PARAM
+#echo "HADOOP_OPTS="$HADOOP_OPTS
+# note: $@ only works in "$@"
+exec $HADOOP jar $AUX_JARS_CMD_LINE ${HIVE_LIB}/hive_cli.jar $CLASS "$@"
+

+ 66 - 0
src/contrib/hive/bin/hive-config.sh

@@ -0,0 +1,66 @@
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# processes --config option from command line
+#
+
+this="$0"
+while [ -h "$this" ]; do
+  ls=`ls -ld "$this"`
+  link=`expr "$ls" : '.*-> \(.*\)$'`
+  if expr "$link" : '.*/.*' > /dev/null; then
+    this="$link"
+  else
+    this=`dirname "$this"`/"$link"
+  fi
+done
+
+# convert relative path to absolute path
+bin=`dirname "$this"`
+script=`basename "$this"`
+bin=`cd "$bin"; pwd`
+this="$bin/$script"
+
+# the root of the Hadoop installation
+export HIVE_HOME=`dirname "$this"`/..
+
+#check to see if the conf dir is given as an optional argument
+while [ $# -gt 0 ]; do    # Until you run out of parameters . . .
+  case "$1" in
+    --config)
+        shift
+        confdir=$1
+        shift
+        HIVE_CONF_DIR=$confdir
+        ;;
+    --auxpath)
+        shift
+        HIVE_AUX_JARS_PATH=$1
+        shift
+        ;;
+    *)
+        break;
+        ;;
+  esac
+done
+
+
+# Allow alternate conf dir location.
+HIVE_CONF_DIR="${HIVE_CONF_DIR:-$HIVE_HOME/conf}"
+
+export HIVE_CONF_DIR=$HIVE_CONF_DIR
+export HIVE_AUX_JARS_PATH=$HIVE_AUX_JARS_PATH

+ 238 - 0
src/contrib/hive/build-common.xml

@@ -0,0 +1,238 @@
+<?xml version="1.0"?>
+
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+
+
+<project name="hivecommon" default="jar">
+
+  <property name="name" value="${ant.project.name}"/>
+
+  <property name="hadoop.root" location="${basedir}/../../../.."/>
+  <property name="hadoop.bin.dir" location="${hadoop.root}/bin"/>
+  <property name="hadoop.conf.dir" value="${hadoop.root}/conf"/>
+  <property name="hive.root" location="${basedir}/.."/>
+  <property name="hive.conf.dir" value="${hive.root}/conf"/>
+  <property name="dist.dir" location="${hive.root}"/>
+
+  <property name="src.dir.hive" location="${hadoop.root}/src/contrib/hive"/>
+  <property name="build.dir.hive" location="${hadoop.root}/build/contrib/hive"/>
+  <property name="build.dir" location="${build.dir.hive}/${name}"/>
+  <property name="build.classes" location="${build.dir}/classes"/>
+  <property name="build.encoding" value="ISO-8859-1"/>
+  <property name="deploy.dir" location="${build.dir.hive}"/>
+
+  <property name="javac.debug" value="on"/>
+  <property name="javac.version" value="1.5"/>
+  <property name="javac.optimize" value="on"/>
+  <property name="javac.deprecation" value="off"/>
+  <property name="javac.args" value=""/>
+  <property name="javac.args.warnings" value=""/> <!-- -Xlint:unchecked"/ -->
+
+  <!-- configuration needed for tests -->
+  <property name="test.src.dir" value="${basedir}/src/test"/>
+  <property name="test.src.data.dir" value="${src.dir.hive}/data"/>
+  <property name="test.build.dir" value="${build.dir}/test"/>
+  <property name="test.log.dir" value="${test.build.dir}/logs"/>
+  <property name="test.data.dir" value="${test.build.dir}/data"/>
+  <property name="test.build.src" value="${test.build.dir}/src"/>
+  <property name="test.build.classes" value="${test.build.dir}/classes"/>
+  <property name="test.build.javadoc" value="${test.build.dir}/docs/api"/>
+  <property name="test.include" value="Test*"/>
+  <property name="test.classpath.id" value="test.classpath"/>
+  <property name="test.output" value="true"/>
+  <property name="test.timeout" value="900000"/>
+  <property name="test.junit.output.format" value="plain"/>
+
+  <path id="test.classpath">
+    <pathelement location="${test.build.classes}" />
+    <pathelement location="" />
+    <pathelement location="${hadoop.conf.dir}"/>
+    <pathelement location="${test.data.dir}/conf"/>
+    <pathelement location="${hive.conf.dir}"/>
+    <path refid="classpath"/>
+  </path>
+
+  <!-- I am not sure whether we need this target any more since that package does what is needed -->
+  <target name="deploy" depends="jar">
+    <echo message="hive: ${name}"/>
+    <mkdir dir="${deploy.dir}"/>
+    <copy file="${build.dir}/hive_${name}.jar"
+          todir="${deploy.dir}"/>
+  </target>
+
+  <!-- the normal classpath -->
+  <path id="common-classpath">
+    <pathelement location="${hadoop.root}/build/classes"/>
+    <fileset dir="${hadoop.root}/lib">
+      <include name="**/*.jar" />
+    </fileset>
+    <fileset dir="${build.dir.hive}">
+      <include name="**/hive_*.jar"/>
+    </fileset>
+    <fileset dir="${src.dir.hive}/lib">
+      <include name="**/*.jar"/>
+    </fileset>
+  </path>
+
+  <path id="classpath">
+    <pathelement location="${hadoop.root}/build/contrib/hive/common/classes"/>
+    <pathelement location="${hadoop.root}/build/contrib/hive/serde/classes"/>
+    <pathelement location="${hadoop.root}/build/contrib/hive/metastore/classes"/>
+    <pathelement location="${hadoop.root}/build/contrib/hive/ql/classes"/>
+    <pathelement location="${hadoop.root}/build/contrib/hive/cli/classes"/>
+    <fileset dir="${basedir}" includes="lib/*.jar"/>
+    <path refid="common-classpath"/>
+  </path>
+
+  <target name="init">
+    <mkdir dir="${hadoop.root}/build/contrib/hive"/>
+    <mkdir dir="${build.dir}"/>
+    <mkdir dir="${build.classes}"/>
+    <mkdir dir="${build.dir.hive}/jexl/classes"/>
+    <mkdir dir="${test.build.dir}"/>
+    <mkdir dir="${test.build.src}"/>
+    <mkdir dir="${test.build.classes}"/>
+  </target>
+
+  <target name="test-init">
+    <mkdir dir="${test.data.dir}"/>
+    <copy todir="${test.data.dir}">
+      <fileset dir="${test.src.data.dir}">
+        <exclude name="**/.svn"/>
+      </fileset>
+    </copy>
+  </target>
+
+  <target name="compile" depends="init">
+    <echo message="Compiling: ${name}"/>
+    <javac
+     encoding="${build.encoding}"
+     srcdir="${src.dir}"
+     includes="**/*.java"
+     destdir="${build.classes}"
+     debug="${javac.debug}"
+     deprecation="${javac.deprecation}">
+      <compilerarg line="${javac.args} ${javac.args.warnings}" />
+      <classpath refid="classpath"/>
+    </javac>
+  </target>
+
+  <target name="jar" depends="compile">
+    <echo message="Jar: ${name}"/>
+    <jar
+      jarfile="${build.dir}/hive_${name}.jar"
+      basedir="${build.classes}"
+    />
+  </target>
+
+  <!-- target to compile tests -->
+  <target name="compile-test" depends="compile">
+    <javac
+     encoding="${build.encoding}"
+     srcdir="${test.src.dir}"
+     includes="org/apache/hadoop/**/*.java"
+     destdir="${test.build.classes}"
+     debug="${javac.debug}"
+     optimize="${javac.optimize}"
+     target="${javac.version}"
+     source="${javac.version}"
+     deprecation="${javac.deprecation}">
+      <compilerarg line="${javac.args} ${javac.args.warnings}" />
+      <classpath refid="test.classpath"/>
+    </javac>
+    <javac
+     encoding="${build.encoding}"
+     srcdir="${test.build.src}"
+     includes="org/apache/hadoop/**/*.java"
+     destdir="${test.build.classes}"
+     debug="${javac.debug}"
+     optimize="${javac.optimize}"
+     target="${javac.version}"
+     source="${javac.version}"
+     deprecation="${javac.deprecation}">
+      <compilerarg line="${javac.args} ${javac.args.warnings}" />
+      <classpath refid="test.classpath"/>
+    </javac>
+  </target>
+
+  <target name="test-conditions">
+    <condition property="qfile" value="">
+      <not>
+        <isset property="qfile"/>
+      </not>
+    </condition>
+    <condition property="overwrite" value="false">
+      <not>
+        <isset property="overwrite"/>
+      </not>
+    </condition>
+  </target>
+
+  <!-- target to deploy anttasks -->
+
+  <target name="compile-ant-tasks" depends="init">
+    <subant target="compile">
+      <fileset dir=".." includes="ant/build.xml"/>
+    </subant>
+  </target>
+
+  <target name="deploy-ant-tasks" depends="compile-ant-tasks">
+    <subant target="deploy">
+      <fileset dir=".." includes="ant/build.xml"/>
+    </subant>
+  </target>
+
+  <target name="gen-test"/>
+
+  <!-- target to run the tests -->
+  <target name="test" depends="test-conditions,gen-test,compile-test,test-init">
+    <delete dir="${test.log.dir}"/>
+    <mkdir dir="${test.log.dir}"/>
+    <junit showoutput="${test.output}" printsummary="yes" haltonfailure="no"
+           fork="yes" maxmemory="256m" dir="${basedir}" timeout="${test.timeout}"
+      errorProperty="tests.failed" failureProperty="tests.failed" filtertrace="off" >
+      <!--
+      <jvmarg value="-Xdebug"/>
+      <jvmarg value="-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y"/> -->
+      <sysproperty key="test.output.overwrite" value="${overwrite}"/>
+      <sysproperty key="log4j.configuration" value="file://${test.data.dir}/conf/hive-log4j.properties"/>
+      <classpath refid="${test.classpath.id}"/>
+      <formatter type="${test.junit.output.format}" />
+      <batchtest todir="${test.build.dir}" unless="testcase">
+        <fileset dir="${test.build.classes}"
+                 includes="**/${test.include}.class"
+                 excludes="**/${test.exclude}.class" />
+      </batchtest>
+      <batchtest todir="${test.build.dir}" if="testcase">
+        <fileset dir="${test.build.classes}" includes="**/${testcase}.class"/>
+      </batchtest>
+    </junit>
+    <fail if="tests.failed">Tests failed!</fail>
+  </target>
+
+  <target name="clean-test">
+    <delete dir="${test.build.dir}"/>
+    <delete dir="${build.dir.hive}/test"/>
+  </target>
+
+  <target name="clean">
+    <echo message="Cleaning: ${name}"/>
+    <delete dir="${build.dir}"/>
+  </target>
+
+</project>

+ 160 - 0
src/contrib/hive/build.xml

@@ -0,0 +1,160 @@
+<?xml version="1.0"?>
+
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+
+
+<project name="hive" default="deploy" >
+
+  <import file="../build-contrib.xml"/>
+
+  <property name="hadoop.root" location="${basedir}/../../.."/>
+  <property name="hive.root" location="${basedir}"/>
+  <property name="build.dir.hive" location="${hadoop.root}/build/contrib/hive"/>
+  <property name="target.dir" location="${build.dir.hive}/dist"/>
+  <property name="target.lib.dir" location="${target.dir}/lib"/>
+  <property name="target.conf.dir" location="${target.dir}/conf"/>
+  <property name="target.bin.dir" location="${target.dir}/bin"/>
+  <property name="target.example.dir" location="${target.dir}/examples"/>
+  <property name="ql.test.query.dir" location="${basedir}/ql/src/test/queries"/>
+  <property name="test.data.dir" location="${basedir}/data"/>
+
+  <!-- ====================================================== -->
+  <!-- Initialize for running junit tests                     -->
+  <!-- ====================================================== -->
+
+  <target name="init">
+    <subant target="init">
+      <fileset dir="." includes="*/build.xml"/>
+    </subant>
+  </target>
+
+  <target name="test-init">
+    <subant target="test-init">
+      <fileset dir="." includes="*/build.xml"/>
+    </subant>
+  </target>
+
+
+  <!-- ====================================================== -->
+  <!-- Compile all the contrib jars.                          -->
+  <!-- ====================================================== -->
+
+  <target name="compile">
+    <subant target="compile">
+      <fileset dir="." includes="common/build.xml"/>
+    </subant>
+    <subant target="compile">
+      <fileset dir="." includes="serde/build.xml"/>
+    </subant>
+    <subant target="compile">
+      <fileset dir="." includes="metastore/build.xml"/>
+    </subant>
+    <subant target="compile">
+      <fileset dir="." includes="ql/build.xml"/>
+    </subant>
+    <subant target="compile">
+      <fileset dir="." includes="cli/build.xml"/>
+    </subant>
+  </target>
+
+  <!-- ====================================================== -->
+  <!-- Build & deploy all the contrib jars.                   -->
+  <!-- ====================================================== -->
+
+  <target name="deploy">
+    <subant target="deploy">
+      <fileset dir="." includes="common/build.xml"/>
+    </subant>
+    <subant target="deploy">
+      <fileset dir="." includes="serde/build.xml"/>
+    </subant>
+    <subant target="deploy">
+      <fileset dir="." includes="metastore/build.xml"/>
+    </subant>
+    <subant target="deploy">
+      <fileset dir="." includes="ql/build.xml"/>
+    </subant>
+    <subant target="deploy">
+      <fileset dir="." includes="cli/build.xml"/>
+    </subant>
+  </target>
+
+  <!-- ====================================================== -->
+  <!-- Test all the contribs.                               -->
+  <!-- ====================================================== -->
+  <target name="test" depends="clean-test">
+    <subant target="test">
+      <fileset dir="." includes="*/build.xml" excludes="ant/build.xml"/>
+    </subant>
+  </target>
+
+  <target name="clean-test">
+    <subant target="clean-test">
+      <fileset dir="." includes="*/build.xml" excludes="ant/build.xml"/>
+    </subant>
+    <delete dir="${build.dir.hive}/test"/>
+  </target>
+
+  <!-- ====================================================== -->
+  <!-- Clean all the contribs.                              -->
+  <!-- ====================================================== -->
+  <target name="clean">
+    <subant target="clean">
+      <fileset dir="." includes="*/build.xml"/>
+    </subant>
+    <delete dir="${target.dir}"/>
+    <delete dir="${build.dir.hive}"/>
+  </target>
+
+  <target name="package" depends="deploy">
+    <echo message="Deploying Hive jars to ${target.dir}"/>
+    <mkdir dir="${target.dir}"/>
+    <mkdir dir="${target.lib.dir}"/>
+    <mkdir dir="${target.conf.dir}"/>
+    <mkdir dir="${target.bin.dir}"/>
+    <mkdir dir="${target.example.dir}"/>
+    <mkdir dir="${target.example.dir}/files"/>
+    <mkdir dir="${target.example.dir}/queries"/>
+    <exec executable="cp" failonerror="true">
+      <arg line="-p '${hive.root}/bin/hive' '${target.bin.dir}'"/>
+    </exec>
+    <copy file="${hive.root}/bin/hive-config.sh" todir="${target.bin.dir}"/>
+    <copy file="${basedir}/conf/hive-default.xml" todir="${target.conf.dir}"/>
+    <copy file="${basedir}/conf/hive-log4j.properties" todir="${target.conf.dir}"/>
+    <copy file="${basedir}/conf/jpox.properties" todir="${target.conf.dir}"/>
+    <copy todir="${target.lib.dir}" preservelastmodified="true" flatten="true">
+      <fileset dir="${hive.root}" includes="*/*.jar, */*/*.jar" excludes="**/antlr-2*,**/antlr-3*"/>
+      <fileset file="${build.dir.hive}/cli/hive_cli.jar"/>
+      <fileset file="${build.dir.hive}/common/hive_common.jar"/>
+      <fileset file="${build.dir.hive}/ql/hive_exec.jar"/>
+      <fileset file="${build.dir.hive}/metastore/hive_metastore.jar"/>
+    </copy>
+    <copy todir="${target.example.dir}/files" preservelastmodified="true" flatten="true">
+      <fileset dir="${test.data.dir}/files" includes="*.*"/>
+    </copy>
+    <copy file="${basedir}/README" todir="${target.dir}"/>
+    <copy todir="${target.example.dir}/queries" preservelastmodified="true" flatten="true">
+      <fileset dir="${ql.test.query.dir}/positive" includes="*.q"/>
+    </copy>
+    <mkdir dir="${dist.dir}/contrib/hive"/>
+    <copy todir="${dist.dir}/contrib/hive">
+      <fileset dir="${target.dir}"/>
+    </copy>
+  </target>
+
+</project>

+ 34 - 0
src/contrib/hive/cli/build.xml

@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+
+
+<!-- 
+Before you can run these subtargets directly, you need 
+to call at top-level: ant deploy-contrib compile-core-test
+-->
+<project name="cli" default="jar">
+
+  <property name="src.dir"  location="${basedir}/src/java"/>
+  <import file="../build-common.xml"/>
+
+  <target name="test">
+    <echo message="Nothing to do!"/>
+  </target>
+
+</project>

+ 5 - 0
src/contrib/hive/cli/lib/README

@@ -0,0 +1,5 @@
+Folowing is the list of external jars contained in this directory and the sources from where they were obtained:
+---------------------------------------------------------------------------------------------------------------
+
+*  jline-0.9.94.jar - http://jline.sourceforge.net/
+

+ 32 - 0
src/contrib/hive/cli/lib/jline-0.9.94.LICENSE

@@ -0,0 +1,32 @@
+Copyright (c) 2002-2006, Marc Prud'hommeaux <mwp1@cornell.edu>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or
+without modification, are permitted provided that the following
+conditions are met:
+
+Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+
+Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with
+the distribution.
+
+Neither the name of JLine nor the names of its contributors
+may be used to endorse or promote products derived from this
+software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
+BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.

BIN
src/contrib/hive/cli/lib/jline-0.9.94.jar


+ 202 - 0
src/contrib/hive/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java

@@ -0,0 +1,202 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.cli;
+
+import jline.*;
+
+import java.io.*;
+import java.util.*;
+
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.ql.exec.Utilities;
+import org.apache.hadoop.hive.ql.exec.Utilities.StreamPrinter;
+import org.apache.hadoop.hive.ql.session.SessionState;
+import org.apache.hadoop.hive.ql.Driver;
+
+public class CliDriver {
+
+  public final static String prompt = "hive";
+
+  public static SetProcessor sp;
+  public static Driver qp;
+
+  public CliDriver(CliSessionState ss) {
+    SessionState.start(ss);
+    sp = new SetProcessor();
+    qp = new Driver();
+  }
+  
+  public static int processCmd(String cmd) {
+    String[] tokens = cmd.split("\\s+");
+    String cmd_1 = cmd.substring(tokens[0].length());
+    int ret = 0;
+    
+    if(tokens[0].equals("set")) {
+      ret = sp.run(cmd_1);
+    } else if (cmd.equals("quit") || cmd.equals("exit")) {
+      // if we have come this far - either the previous commands
+      // are all successful or this is command line. in either case
+      // this counts as a successful run
+      System.exit(0);
+    } else if (cmd.startsWith("!")) {
+      SessionState ss = SessionState.get();
+      String shell_cmd = cmd.substring(1);
+      if (shell_cmd.endsWith(";")) {
+        shell_cmd = shell_cmd.substring(0, shell_cmd.length()-1);
+      }
+
+      //shell_cmd = "/bin/bash -c \'" + shell_cmd + "\'";
+      try {
+        Process executor = Runtime.getRuntime().exec(shell_cmd);
+        StreamPrinter outPrinter = new StreamPrinter(executor.getInputStream(), null, ss.out);
+        StreamPrinter errPrinter = new StreamPrinter(executor.getErrorStream(), null, ss.err);
+        
+        outPrinter.start();
+        errPrinter.start();
+      
+        int exitVal = executor.waitFor();
+        if (exitVal != 0) {
+          ss.err.write((new String("Command failed with exit code = " + exitVal)).getBytes());
+        }
+      }
+      catch (Exception e) {
+        e.printStackTrace();
+      }
+
+    } else {
+      ret = qp.run(cmd);
+      Vector<Vector<String>> res = new Vector<Vector<String>>();
+      while (qp.getResults(res))
+      {
+        SessionState ss = SessionState.get();
+        OutputStream out = ss.out;
+        try 
+        {
+
+          for (Vector<String> row:res)
+          {
+            for (String col:row)
+            {
+              out.write(col == null ? Utilities.nullStringOutput.getBytes() : col.getBytes());
+              out.write(Utilities.tabCode);
+            } 
+            out.write(Utilities.newLineCode);
+          }
+          res.clear();
+
+        } catch (IOException e) {
+          e.printStackTrace();
+        }
+      }
+    }
+    return ret;
+  }
+
+  public static int processLine(String line) {
+    int ret = 0;
+    for(String oneCmd: line.split(";")) {
+      oneCmd = oneCmd.trim();
+      if(oneCmd.equals(""))
+        continue;
+      
+      ret = processCmd(oneCmd);
+      if(ret != 0) {
+        // ignore anything after the first failed command
+        return ret;
+      }
+    }
+    return 0;
+  }
+
+  public static int processReader(BufferedReader r) throws IOException {
+    String line;
+    int ret = 0;
+    while((line = r.readLine()) != null) {
+      ret = processLine(line);
+      if(ret != 0) {
+        return ret;
+      }
+    }
+    return 0;
+  }
+
+  public static void main(String[] args) throws IOException {
+
+    OptionsProcessor oproc = new OptionsProcessor();
+    if(! oproc.process_stage1(args)) {
+      System.exit(1);
+    }
+
+    // NOTE: It is critical to do this here so that log4j is reinitialized before
+    // any of the other core hive classes are loaded
+    SessionState.initHiveLog4j();
+
+    CliSessionState ss = new CliSessionState (new HiveConf(SessionState.class));
+    SessionState.start(ss);
+
+    if(! oproc.process_stage2(ss)) {
+      System.exit(2);
+    }
+
+    ss.in = System.in;
+    ss.out = System.out;
+    ss.err = System.err;
+
+    sp = new SetProcessor();
+    qp = new Driver();
+
+    if(ss.execString != null) {
+      System.exit(processLine(ss.execString));
+    }
+
+    try {
+      if(ss.fileName != null) {
+        System.exit(processReader(new BufferedReader(new FileReader(ss.fileName))));
+      }
+    } catch (FileNotFoundException e) {
+      System.err.println("Could not open input file for reading. ("+e.getMessage()+")");
+      System.exit(3);
+    }
+
+    Character mask = null;
+    String trigger = null;
+
+    ConsoleReader reader = new ConsoleReader();
+    reader.setBellEnabled(false);
+    //reader.setDebug(new PrintWriter(new FileWriter("writer.debug", true)));
+
+    List<SimpleCompletor> completors = new LinkedList<SimpleCompletor>();
+    completors.add(new SimpleCompletor(new String[] { "set", "from",
+                                                      "create", "load",
+                                                      "describe", "quit", "exit" }));
+    reader.addCompletor(new ArgumentCompletor(completors));
+    
+    String line;
+    PrintWriter out = new PrintWriter(System.out);
+    final String HISTORYFILE = ".hivehistory";
+    String historyFile = System.getProperty("user.home") + File.separator  + HISTORYFILE;
+    reader.setHistory(new History(new File(historyFile)));
+    int ret = 0;
+    while ((line = reader.readLine(prompt+"> ")) != null) {
+      ret = processLine(line);
+    }
+
+    System.exit(ret);
+  }
+}

+ 48 - 0
src/contrib/hive/cli/src/java/org/apache/hadoop/hive/cli/CliSessionState.java

@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.cli;
+
+import org.apache.hadoop.hive.ql.session.SessionState;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.ql.metadata.Hive;
+
+public class CliSessionState extends SessionState {
+  /**
+   * -e option if any that the session has been invoked with
+   */ 
+  public String execString;
+
+  /**
+   * -f option if any that the session has been invoked with
+   */
+  public String fileName;
+
+
+  public CliSessionState() {
+    super();
+  }
+
+  public CliSessionState (HiveConf conf) {
+    super(conf);
+  }
+  
+  public CliSessionState (HiveConf conf, Hive db) {
+    super(conf, db);
+  }
+}

+ 64 - 0
src/contrib/hive/cli/src/java/org/apache/hadoop/hive/cli/MetadataProcessor.java

@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.cli;
+
+import java.util.List;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.metastore.MetaStoreClient;
+import org.apache.hadoop.hive.metastore.api.FieldSchema;
+import org.apache.hadoop.hive.metastore.api.MetaException;
+import org.apache.hadoop.hive.ql.session.SessionState;
+import org.apache.hadoop.hive.ql.CommandProcessor;
+
+
+public class MetadataProcessor implements CommandProcessor {
+
+  public int run(String command) {
+    SessionState ss = SessionState.get();
+    String table_name = command.trim();
+
+    if(table_name.equals("")) {
+      return 0;
+    }
+
+    try {
+      MetaStoreClient msc = new MetaStoreClient(ss.getConf());
+      
+      if(!msc.tableExists(table_name)) {
+        ss.err.println("table does not exist: " + table_name);
+        return 1;
+      } else {
+        List<FieldSchema> fields = msc.get_fields(table_name);
+
+        for(FieldSchema f: fields) {
+          ss.out.println(f.getName() + ": " + f.getType());
+        }
+      }
+    } catch (MetaException err) {
+      ss.err.println("Got meta exception: " + err.getMessage());
+      return 1;
+    } catch (Exception err) {
+      ss.err.println("Got exception: " + err.getMessage());
+      return 1;
+    }
+    return 0;
+  }
+
+}

+ 222 - 0
src/contrib/hive/cli/src/java/org/apache/hadoop/hive/cli/OptionsProcessor.java

@@ -0,0 +1,222 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.cli;
+
+import java.io.*;
+import java.util.*;
+
+import org.apache.commons.cli2.*;
+import org.apache.commons.cli2.builder.ArgumentBuilder;
+import org.apache.commons.cli2.builder.DefaultOptionBuilder;
+import org.apache.commons.cli2.builder.GroupBuilder;
+import org.apache.commons.cli2.commandline.Parser;
+import org.apache.commons.cli2.option.PropertyOption;
+import org.apache.commons.cli2.resource.ResourceConstants;
+import org.apache.commons.cli2.OptionException;
+import org.apache.commons.logging.*;
+
+import org.apache.hadoop.hive.conf.HiveConf;
+
+public class OptionsProcessor {
+
+  protected static final Log l4j = LogFactory.getLog(OptionsProcessor.class.getName());
+
+  private Parser parser = new Parser();
+  private Option confOptions, isSilentOption, execOption, fileOption, isHelpOption;
+
+  /** 
+   * shameless cloned from hadoop streaming
+   * take in multiple -hiveconf x=y parameters
+   */
+  class MultiPropertyOption extends PropertyOption{
+    private String optionString; 
+    MultiPropertyOption(){
+      super(); 
+    }
+    
+    MultiPropertyOption(final String optionString,
+                        final String description,
+                        final int id){
+      super(optionString, description, id); 
+      this.optionString = optionString;
+    }
+
+    public boolean canProcess(final WriteableCommandLine commandLine,
+                              final String argument) {
+      boolean ret = (argument != null) && argument.startsWith(optionString);
+        
+      return ret;
+    }    
+
+    public void process(final WriteableCommandLine commandLine,
+                        final ListIterator arguments) throws OptionException {
+      final String arg = (String) arguments.next();
+
+      if (!canProcess(commandLine, arg)) {
+        throw new OptionException(this, 
+                                  ResourceConstants.UNEXPECTED_TOKEN, arg);
+      }
+      
+      ArrayList properties = new ArrayList(); 
+      String next = ""; 
+      while(arguments.hasNext()){
+        next = (String) arguments.next();
+        if (!next.startsWith("-")){
+          
+          if(next.indexOf("=") == -1) {
+            throw new OptionException(this, ResourceConstants.UNEXPECTED_TOKEN,
+                                      "argument: '" + next + "' is not of the form x=y");
+          }
+          properties.add(next);
+        }else{
+          arguments.previous();
+          break; 
+        }
+      } 
+
+      // add to any existing values (support specifying args multiple times)
+      List<String> oldVal = (List<String>)commandLine.getValue(this); 
+      if (oldVal == null){
+        commandLine.addValue(this, properties);
+      } else{
+        oldVal.addAll(properties); 
+      }
+    }
+  }
+
+  private Option createBoolOption(DefaultOptionBuilder builder, String longName,
+                                  String shortName, String desc){
+    builder.reset();
+    if(longName == null) {
+      return builder.withShortName(shortName).withDescription(desc).create();
+    } else {
+      return builder.withShortName(shortName).withLongName(longName).withDescription(desc).create();
+    }
+  }
+
+
+  private Option createOptionWithArg(DefaultOptionBuilder builder, String longName,
+                                     String shortName, String desc, Argument arg) {
+    builder.reset();
+
+    DefaultOptionBuilder dob =
+      builder.withShortName(shortName).
+      withArgument(arg).
+      withDescription(desc);
+
+    if(longName != null) 
+      dob = dob.withLongName(longName);
+
+    return dob.create();
+  }
+
+
+  public OptionsProcessor() {
+    DefaultOptionBuilder builder =
+      new DefaultOptionBuilder("-","-", false);    
+
+    ArgumentBuilder argBuilder = new ArgumentBuilder();
+    
+    //-e
+    execOption = createOptionWithArg(builder, "exec", "e", "execute the following command",
+                                     argBuilder.withMinimum(1).withMaximum(1).create());
+
+
+    //-f
+    fileOption = createOptionWithArg(builder, "file", "f", "execute commands from the following file",
+                                     argBuilder.withMinimum(1).withMaximum(1).create());
+
+    // -S
+    isSilentOption = createBoolOption(builder, "silent", "S", "silent mode");
+
+    // -help
+    isHelpOption = createBoolOption(builder, "help", "h", "help");
+    
+    // -hiveconf var=val
+    confOptions = new MultiPropertyOption("-hiveconf", "(n=v) Optional. Add or override Hive/Hadoop properties.", 'D');
+
+    new PropertyOption();
+    Group allOptions = new GroupBuilder().
+      withOption(confOptions).
+      withOption(isSilentOption).
+      withOption(isHelpOption).
+      withOption(execOption).
+      withOption(fileOption).
+      create();
+    parser.setGroup(allOptions);
+  }
+
+  private CommandLine cmdLine;
+  
+  public boolean process_stage1(String [] argv) {
+    try {
+      cmdLine = parser.parse(argv);
+
+      List<String> hiveConfArgs = (List<String>)cmdLine.getValue(confOptions); 
+      if (null != hiveConfArgs){
+        for(String s : hiveConfArgs){
+          String []parts = s.split("=", 2); 
+          System.setProperty(parts[0], parts[1]);
+        }
+      }
+    } catch (OptionException oe) {
+      System.err.println(oe.getMessage());
+      return false;
+    }
+    return true;
+  }
+
+
+  public boolean process_stage2(CliSessionState ss) {
+    HiveConf hconf = ss.getConf();
+    //-S
+    ss.setIsSilent(cmdLine.hasOption(isSilentOption));
+    //-e
+    ss.execString = (String) cmdLine.getValue(execOption);
+    //-f
+    ss.fileName = (String) cmdLine.getValue(fileOption);
+    // -h
+    if (cmdLine.hasOption(isHelpOption)) {
+      printUsage(null);
+      return false;
+    }
+    if(ss.execString != null && ss.fileName != null) {
+      printUsage("-e and -f option cannot be specified simultaneously");
+      return false;
+    }
+    return true;
+  }
+
+  public void printUsage (String error) {
+    if (error != null) {
+      System.err.println("Invalid arguments: " + error);
+    }
+    System.err.println("");
+    System.err.println("Usage: hive [--config confdir] [-hiveconf x=y]* [<-f filename>|<-e query-string>] [-S]");
+    System.err.println("");
+    System.err.println("  -e 'quoted query string'  Sql from command line"); 
+    System.err.println("  -f <filename>             Sql from files");
+    System.err.println("  -S                        Silent mode in interactive shell");
+    System.err.println("");
+    System.err.println("-e and -f cannot be specified together. In the absence of these");
+    System.err.println("options, interactive shell is started");
+    System.err.println("");
+    
+  }
+}

+ 101 - 0
src/contrib/hive/cli/src/java/org/apache/hadoop/hive/cli/SetProcessor.java

@@ -0,0 +1,101 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.cli;
+
+import java.util.*;
+
+import org.apache.hadoop.hive.ql.session.SessionState;
+import org.apache.hadoop.hive.ql.CommandProcessor;
+
+public class SetProcessor implements CommandProcessor {
+
+  private static String prefix = "set: ";
+
+  public static boolean getBoolean(String value) {
+    if(value.equals("on") || value.equals("true"))
+      return true;
+    if(value.equals("off") || value.equals("false"))
+      return false;
+    throw new IllegalArgumentException(prefix + "'" + value + "' is not a boolean");
+  }
+
+  private void dumpOptions(Properties p) {
+    SessionState ss = SessionState.get();
+
+    ss.out.println("silent=" + (ss.getIsSilent() ? "on" : "off"));
+    for(Object one: p.keySet()) {
+      String oneProp = (String)one;
+      String oneValue = p.getProperty(oneProp);
+      ss.out.println(oneProp+"="+oneValue);
+    }
+  }
+
+  private void dumpOption(Properties p, String s) {
+    SessionState ss = SessionState.get();
+    
+    if(p.getProperty(s) != null) {
+      ss.out.println(s+"="+p.getProperty(s));
+    } else {
+      ss.out.println(s+" is undefined");
+    }
+  }
+
+  public int run(String command) {
+    SessionState ss = SessionState.get();
+
+    String nwcmd = command.trim();
+    if(nwcmd.equals("")) {
+      dumpOptions(ss.getConf().getChangedProperties());
+      return 0;
+    }
+
+    if(nwcmd.equals("-v")) {
+      dumpOptions(ss.getConf().getAllProperties());
+      return 0;
+    }
+
+    String[] part = new String [2];
+
+    int eqIndex = nwcmd.indexOf('=');
+    if(eqIndex == -1) {
+      // no equality sign - print the property out
+      dumpOption(ss.getConf().getAllProperties(), nwcmd);
+      return (0);
+    } else if (eqIndex == nwcmd.length()-1) {
+      part[0] = nwcmd.substring(0, nwcmd.length()-1);
+      part[1] = "";
+    } else {
+      part[0] = nwcmd.substring(0, eqIndex);
+      part[1] = nwcmd.substring(eqIndex+1);
+    }
+
+    try {
+      if (part[0].equals("silent")) {
+        boolean val = getBoolean(part[1]);
+        ss.setIsSilent(val);
+      } else {
+        ss.getConf().set(part[0], part[1]);
+      }
+    } catch (IllegalArgumentException err) {
+      ss.err.println(err.getMessage());
+      return 1;
+    }
+    return 0;
+  }
+}

+ 34 - 0
src/contrib/hive/common/build.xml

@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+
+
+<!-- 
+Before you can run these subtargets directly, you need 
+to call at top-level: ant deploy-contrib compile-core-test
+-->
+<project name="common" default="jar">
+
+  <property name="src.dir"  location="${basedir}/src/java"/>
+  <import file="../build-common.xml"/>
+
+  <target name="test">
+    <echo message="Nothing to do!"/>
+  </target>
+
+</project>

+ 246 - 0
src/contrib/hive/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java

@@ -0,0 +1,246 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.conf;
+
+import java.io.PrintStream;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.mapred.JobConf;
+
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * Hive Configuration
+ */
+public class HiveConf extends Configuration {
+
+  protected String hiveJar;
+  protected Properties origProp;
+  protected String auxJars;
+  private static final Log l4j = LogFactory.getLog(HiveConf.class);
+
+  public static enum ConfVars {
+    // QL execution stuff
+    SCRIPTWRAPPER("hive.exec.script.wrapper", null),
+    PLAN("hive.exec.plan", null),
+    SCRATCHDIR("hive.exec.scratchdir", "/tmp/"+System.getProperty("user.name")+"/hive"),
+    SUBMITVIACHILD("hive.exec.submitviachild", "false"),
+
+    // hadoop stuff
+    HADOOPBIN("hadoop.bin.path", System.getProperty("user.dir") + "/../../../bin/hadoop"),
+    HADOOPCONF("hadoop.config.dir", System.getProperty("user.dir") + "/../../../conf"),
+    HADOOPFS("fs.default.name", "file:///"),
+    HADOOPMAPFILENAME("map.input.file", null),
+    HADOOPJT("mapred.job.tracker", "local"),
+    HADOOPNUMREDUCERS("mapred.reduce.tasks", "1"),
+    HADOOPJOBNAME("mapred.job.name", null),
+
+    // MetaStore stuff.
+    METASTOREDIRECTORY("hive.metastore.metadb.dir", ""),
+    METASTOREWAREHOUSE("hive.metastore.warehouse.dir", ""),
+    METASTOREURIS("hive.metastore.uris", ""),
+
+    // Things we log in the jobconf
+
+    // session identifier
+    HIVESESSIONID("hive.session.id", ""),
+    // query being executed (multiple per session)
+    HIVEQUERYID("hive.query.string", ""),
+    // id of the mapred plan being executed (multiple per query)
+    HIVEPLANID("hive.query.planid", ""),
+    // max jobname length
+    HIVEJOBNAMELENGTH("hive.jobname.length", 50),
+    
+    // hive jar
+    HIVEJAR("hive.jar.path", ""), 
+    HIVEAUXJARS("hive.aux.jars.path", ""),
+   
+    // for hive script operator
+    HIVETABLENAME("hive.table.name", ""),
+    HIVEPARTITIONNAME("hive.partition.name", ""),
+    HIVEALIAS("hive.alias", "");
+    
+    public final String varname;
+    public final String defaultVal;
+    public final int defaultIntVal;
+    public final Class valClass;
+
+    ConfVars(String varname, String defaultVal) {
+      this.varname = varname;
+      this.defaultVal = defaultVal;
+      this.valClass = String.class;
+      this.defaultIntVal = -1;
+    }
+
+    ConfVars(String varname, int defaultIntVal) {
+      this.varname = varname;
+      this.defaultVal = null;
+      this.defaultIntVal = defaultIntVal;
+      this.valClass = Integer.class;
+    }
+
+    public String toString() {
+      return varname;
+    }
+  }
+
+  public static int getIntVar(Configuration conf, ConfVars var) {
+    assert(var.valClass == Integer.class);
+    return conf.getInt(var.varname, var.defaultIntVal);
+  }
+
+  public int getIntVar(ConfVars var) {
+    return getIntVar(this, var);
+  }
+
+  public static String getVar(Configuration conf, ConfVars var) {
+    assert(var.valClass == String.class);
+    return conf.get(var.varname, var.defaultVal);
+  }
+
+  public static void setVar(Configuration conf, ConfVars var, String val) {
+    assert(var.valClass == String.class);
+    conf.set(var.varname, val);
+  }
+
+  public String getVar(ConfVars var) {
+    return getVar(this, var);
+  }
+
+  public void setVar(ConfVars var, String val) {
+    setVar(this, var, val);
+  }
+
+  public void logVars(PrintStream ps) {
+    for(ConfVars one: ConfVars.values()) {
+      ps.println(one.varname + "=" + ((get(one.varname) != null) ? get(one.varname) : ""));
+    }
+  }
+
+
+  public HiveConf(Class cls) {
+    super();
+    initialize(cls);
+  }
+
+  public HiveConf(Configuration other, Class cls) {
+    super(other);
+    initialize(cls);
+  }
+
+  private Properties getUnderlyingProps() {
+    Iterator<Map.Entry<String, String>> iter = this.iterator();
+    Properties p = new Properties();
+    while(iter.hasNext()) {
+      Map.Entry<String, String> e = iter.next();
+      p.setProperty(e.getKey(), e.getValue());
+    }
+    return p;
+  }
+
+
+  private void initialize(Class cls) {
+    hiveJar = (new JobConf(cls)).getJar();
+    
+    // preserve the original configuration
+    origProp = getUnderlyingProps();
+    
+    // let's add the hive configuration 
+    URL hconfurl = getClassLoader().getResource("hive-default.xml");
+    if(hconfurl == null) {
+      l4j.warn("Unable to locate default hive configuration");
+    } else {
+      addResource("hive-default.xml");
+    }
+
+    // if hadoop configuration files are already in our path - then define 
+    // the containing directory as the configuration directory
+    URL hadoopconfurl = getClassLoader().getResource("hadoop-default.xml");
+    if(hadoopconfurl == null) 
+      hadoopconfurl = getClassLoader().getResource("hadoop-site.xml");
+    if(hadoopconfurl != null) {
+      String conffile = hadoopconfurl.getPath();
+      this.setVar(ConfVars.HADOOPCONF, conffile.substring(0, conffile.lastIndexOf('/')));
+    }
+
+    applySystemProperties();
+
+    // if the running class was loaded directly (through eclipse) rather than through a
+    // jar then this would be needed
+    if(hiveJar == null) {
+      hiveJar = this.get(ConfVars.HIVEJAR.varname);
+    }
+    
+    if(auxJars == null) {
+      auxJars = this.get(ConfVars.HIVEAUXJARS.varname);
+    }
+
+  }
+
+  public void applySystemProperties() {
+    for(ConfVars oneVar: ConfVars.values()) {
+      if(System.getProperty(oneVar.varname) != null) {
+        if(System.getProperty(oneVar.varname).length() > 0)
+        this.set(oneVar.varname, System.getProperty(oneVar.varname));
+      }
+    }
+  }
+
+  public Properties getChangedProperties() {
+    Properties ret = new Properties();
+    Properties newProp = getUnderlyingProps();
+
+    for(Object one: newProp.keySet()) {
+      String oneProp = (String)one;
+      String oldValue = origProp.getProperty(oneProp);
+      if(!StringUtils.equals(oldValue, newProp.getProperty(oneProp))) {
+        ret.setProperty(oneProp, newProp.getProperty(oneProp));
+      }
+    }
+    return (ret);
+  }
+
+  public Properties getAllProperties() {
+    return getUnderlyingProps();
+  }
+
+  public String getJar() {
+    return hiveJar;
+  }
+
+  /**
+   * @return the auxJars
+   */
+  public String getAuxJars() {
+    return auxJars;
+  }
+
+  /**
+   * @param auxJars the auxJars to set
+   */
+  public void setAuxJars(String auxJars) {
+    this.auxJars = auxJars;
+  }
+}

+ 24 - 0
src/contrib/hive/conf/configuration.xsl

@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+<xsl:output method="html"/>
+<xsl:template match="configuration">
+<html>
+<body>
+<table border="1">
+<tr>
+ <td>name</td>
+ <td>value</td>
+ <td>description</td>
+</tr>
+<xsl:for-each select="property">
+<tr>
+  <td><a name="{name}"><xsl:value-of select="name"/></a></td>
+  <td><xsl:value-of select="value"/></td>
+  <td><xsl:value-of select="description"/></td>
+</tr>
+</xsl:for-each>
+</table>
+</body>
+</html>
+</xsl:template>
+</xsl:stylesheet>

+ 87 - 0
src/contrib/hive/conf/hive-default.xml

@@ -0,0 +1,87 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
+
+<configuration>
+
+<!-- Hive Configuration can either be stored in this file or in the hadoop configuration files  -->
+<!-- that are implied by Hadoop setup variables.                                                -->
+<!-- Aside from Hadoop setup variables - this file is provided as a convenience so that Hive    -->
+<!-- users do not have to edit hadoop configuration files (that may be managed as a centralized -->
+<!-- resource).                                                                                 -->
+
+<!-- Hadoop Setup -->
+<property>
+  <name>hadoop.bin.path</name>
+  <value>${user.dir}/../../../bin/hadoop</value>
+  <!-- note that the hive shell script also uses this property name -->
+  <description>Path to hadoop binary. Assumes that by default we are executing from hive</description>
+</property>
+
+<property>
+  <name>hadoop.config.dir</name>
+  <value>${user.dir}/../../../conf</value>
+  <!-- note that the hive shell script also uses this property name -->
+  <description>Path to hadoop configuration. Again assumes that by default we are executing from hive/</description>
+</property>
+
+<!-- Hive Execution Parameters -->
+<property>
+  <name>hive.exec.scratchdir</name>
+  <value>/tmp/hive-${user.name}</value>
+  <description>Scratch space for Hive jobs</description>
+</property>
+
+<property>
+  <name>hive.metastore.local</name>
+  <value>true</value>
+  <description>controls whether to connect to remove metastore server or open a new metastore server in Hive Client JVM</description>
+</property>
+
+<property>
+  <name>javax.jdo.option.ConnectionURL</name>
+  <value>jdbc:derby:;databaseName=metastore_db;create=true</value>
+  <description>JDBC connect string for a JDBC metastore</description>
+</property>
+
+<property>
+  <name>javax.jdo.option.ConnectionDriverName</name>
+  <value>org.apache.derby.jdbc.EmbeddedDriver</value>
+  <description>Driver class name for a JDBC metastore</description>
+</property>
+
+<property>
+  <name>hive.metastore.uris</name>
+  <value>thift://</value>
+  <description>Comma separated list of URIs of metastore servers. The first server that can be connected to will be used.</description>
+</property>
+
+<property>
+  <name>hive.metastore.metadb.dir</name>
+  <value>file:///var/metastore/metadb/</value>
+  <description>The location of filestore metadata base dir</description>
+</property>
+<property>
+  <name>hive.metastore.uris</name>
+  <value>file:///var/metastore/metadb/</value>
+  <description></description>
+</property>
+
+<property>
+  <name>hive.metastore.warehouse.dir</name>
+  <value>/user/hive/warehouse</value>
+  <description>location of default database for the warehouse</description>
+</property>
+
+<property>
+  <name>hive.metastore.connect.retries</name>
+  <value>5</value>
+  <description>Number of retries while opening a connection to metastore</description>
+</property>
+
+<property>
+  <name>hive.metastore.rawstore.impl</name>
+  <value>org.apache.hadoop.hive.metastore.ObjectStore</value>
+  <description>Name of the class that implements org.apache.hadoop.hive.metastore.rawstore interface. This class is used to store and retrieval of raw metadata objects such as table, database</description>
+</property>
+
+</configuration>

+ 61 - 0
src/contrib/hive/conf/hive-log4j.properties

@@ -0,0 +1,61 @@
+# Define some default values that can be overridden by system properties
+hive.root.logger=WARN,DRFA
+hive.log.dir=/tmp/${user.name}
+hive.log.file=hive.log
+
+# Define the root logger to the system property "hadoop.root.logger".
+log4j.rootLogger=${hive.root.logger}, EventCounter
+
+# Logging Threshold
+log4j.threshhold=WARN
+
+#
+# Daily Rolling File Appender
+#
+
+log4j.appender.DRFA=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.DRFA.File=${hive.log.dir}/${hive.log.file}
+
+# Rollver at midnight
+log4j.appender.DRFA.DatePattern=.yyyy-MM-dd
+
+# 30-day backup
+#log4j.appender.DRFA.MaxBackupIndex=30
+log4j.appender.DRFA.layout=org.apache.log4j.PatternLayout
+
+# Pattern format: Date LogLevel LoggerName LogMessage
+#log4j.appender.DRFA.layout.ConversionPattern=%d{ISO8601} %p %c: %m%n
+# Debugging Pattern format
+log4j.appender.DRFA.layout.ConversionPattern=%d{ISO8601} %-5p %c{2} (%F:%M(%L)) - %m%n
+
+
+#
+# console
+# Add "console" to rootlogger above if you want to use this 
+#
+
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.target=System.err
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{2}: %m%n
+
+#custom logging levels
+#log4j.logger.xxx=DEBUG
+
+#
+# Event Counter Appender
+# Sends counts of logging messages at different severity levels to Hadoop Metrics.
+#
+log4j.appender.EventCounter=org.apache.hadoop.metrics.jvm.EventCounter
+
+
+log4j.category.JPOX=ERROR,DRFA
+log4j.category.Datastore=ERROR,DRFA
+log4j.category.Datastore.Schema=ERROR,DRFA
+log4j.category.JPOX.Datastore=ERROR,DRFA
+log4j.category.JPOX.Plugin=ERROR,DRFA
+log4j.category.JPOX.MetaData=ERROR,DRFA
+log4j.category.JPOX.Query=ERROR,DRFA
+log4j.category.JPOX.General=ERROR,DRFA
+log4j.category.JPOX.Enhancer=ERROR,DRFA
+

+ 15 - 0
src/contrib/hive/conf/jpox.properties

@@ -0,0 +1,15 @@
+javax.jdo.PersistenceManagerFactoryClass=org.jpox.PersistenceManagerFactoryImpl
+org.jpox.autoCreateSchema=false
+org.jpox.validateTables=false
+org.jpox.validateColumns=false
+org.jpox.validateConstraints=false
+org.jpox.storeManagerType=rdbms
+org.jpox.autoCreateSchema=true
+org.jpox.autoStartMechanismMode=checked
+org.jpox.transactionIsolation=read_committed
+javax.jdo.option.DetachAllOnCommit=true
+javax.jdo.option.NontransactionalRead=true
+javax.jdo.option.ConnectionDriverName=org.apache.derby.jdbc.EmbeddedDriver
+javax.jdo.option.ConnectionURL=jdbc:derby:;databaseName=test_metastore_db;create=true
+javax.jdo.option.ConnectionUserName=APP
+javax.jdo.option.ConnectionPassword=mine

+ 123 - 0
src/contrib/hive/data/conf/hive-default.xml

@@ -0,0 +1,123 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
+
+<configuration>
+
+<!-- Hive Configuration can either be stored in this file or in the hadoop configuration files  -->
+<!-- that are implied by Hadoop setup variables.                                                -->
+<!-- Aside from Hadoop setup variables - this file is provided as a convenience so that Hive    -->
+<!-- users do not have to edit hadoop configuration files (that may be managed as a centralized -->
+<!-- resource).                                                                                 -->
+
+<!-- Hadoop Setup -->
+
+<property>
+  <name>hadoop.bin.path</name>
+  <value>${user.dir}/../../../../bin/hadoop</value>
+  <description>Path to hadoop binary. Assumes that by default we are executing from hive/</description>
+</property>
+
+<property>
+  <name>hadoop.config.dir</name>
+  <value>${user.dir}/../../../../conf</value>
+  <description>Path to hadoop configuration. Again assumes that by default we are executing from hive/</description>
+</property>
+
+<!-- Hive Execution Parameters -->
+<property>
+  <name>hive.exec.scratchdir</name>
+  <value>/tmp/hive-${user.name}</value>
+  <description>Scratch space for Hive jobs</description>
+</property>
+
+<property>
+  <name>javax.jdo.option.ConnectionURL</name>
+  <value>jdbc:derby:;databaseName=../../../../build/contrib/hive/test/junit_metastore_db;create=true</value>
+</property>
+
+<property>
+  <name>javax.jdo.option.ConnectionDriverName</name>
+  <value>org.apache.derby.jdbc.EmbeddedDriver</value>
+</property>
+
+<property>
+  <name>javax.jdo.option.ConnectionUserName</name>
+  <value>APP</value>
+</property>
+
+<property>
+  <name>javax.jdo.option.ConnectionPassword</name>
+  <value>mine</value>
+</property>
+
+<property>
+  <name>hive.metastore.local</name>
+  <value>true</value>
+  <description>controls whether to connect to remove metastore server or open a new metastore server in Hive Client JVM</description>
+</property>
+
+<property>
+  <!--  this should eventually be deprecated since the metastore should supply this -->
+  <name>hive.metastore.warehouse.dir</name>
+  <value>file://${user.dir}/../../../../build/contrib/hive/ql/test/data/warehouse/</value>
+  <description></description>
+</property>
+
+<property>
+  <name>hive.metastore.metadb.dir</name>
+  <value>file://${user.dir}/../../../../build/contrib/hive/ql/test/data/metadb/</value>
+  <description> 
+  Required by metastore server or if the uris argument below is not supplied
+  </description>
+</property>
+
+<property>
+  <name>fs.default.name</name>
+  <value>file:///</value>
+  <description></description>
+</property>
+
+<property>
+  <name>mapred.job.tracker</name>
+  <value>local</value>
+  <description></description>
+</property>
+
+<property>
+  <name>test.log.dir</name>
+  <value>${user.dir}/../../../../build/contrib/hive/ql/test/logs</value>
+  <description></description>
+</property>
+
+<property>
+  <name>test.src.dir</name>
+  <value>file://${user.dir}/../../../../src/contrib/hive/ql/src/test</value>
+  <description></description>
+</property>
+
+<property>
+  <name>test.data.files</name>
+  <value>${user.dir}/../../../../build/contrib/hive/ql/test/data/files</value>
+  <description></description>
+</property>
+
+<property>
+  <name>test.query.file1</name>
+  <value>file://${user.dir}/../../../../src/contrib/hive/ql/src/test/org/apache/hadoop/hive/ql/input2.q</value>
+  <value></value>
+  <description></description>
+</property>
+
+<property>
+  <name>hive.jar.path</name>
+  <value>${user.dir}/../../../../build/contrib/hive/ql/hive_exec.jar</value>
+  <description></description>
+</property>
+
+<property>
+  <name>hive.metastore.rawstore.impl</name>
+  <value>org.apache.hadoop.hive.metastore.ObjectStore</value>
+  <description>Name of the class that implements org.apache.hadoop.hive.metastore.rawstore interface. This class is used to store and retrieval of raw metadata objects such as table, database</description>
+</property>
+
+</configuration>

+ 1 - 0
src/contrib/hive/data/conf/hive-log4j.properties

@@ -0,0 +1 @@
+../../conf/hive-log4j.properties

BIN
src/contrib/hive/data/files/complex.seq


BIN
src/contrib/hive/data/files/kv1.seq


+ 500 - 0
src/contrib/hive/data/files/kv1.string-sorted.txt

@@ -0,0 +1,500 @@
+0val_0
+0val_0
+0val_0
+10val_10
+100val_100
+100val_100
+103val_103
+103val_103
+104val_104
+104val_104
+105val_105
+11val_11
+111val_111
+113val_113
+113val_113
+114val_114
+116val_116
+118val_118
+118val_118
+119val_119
+119val_119
+119val_119
+12val_12
+12val_12
+120val_120
+120val_120
+125val_125
+125val_125
+126val_126
+128val_128
+128val_128
+128val_128
+129val_129
+129val_129
+131val_131
+133val_133
+134val_134
+134val_134
+136val_136
+137val_137
+137val_137
+138val_138
+138val_138
+138val_138
+138val_138
+143val_143
+145val_145
+146val_146
+146val_146
+149val_149
+149val_149
+15val_15
+15val_15
+150val_150
+152val_152
+152val_152
+153val_153
+155val_155
+156val_156
+157val_157
+158val_158
+160val_160
+162val_162
+163val_163
+164val_164
+164val_164
+165val_165
+165val_165
+166val_166
+167val_167
+167val_167
+167val_167
+168val_168
+169val_169
+169val_169
+169val_169
+169val_169
+17val_17
+170val_170
+172val_172
+172val_172
+174val_174
+174val_174
+175val_175
+175val_175
+176val_176
+176val_176
+177val_177
+178val_178
+179val_179
+179val_179
+18val_18
+18val_18
+180val_180
+181val_181
+183val_183
+186val_186
+187val_187
+187val_187
+187val_187
+189val_189
+19val_19
+190val_190
+191val_191
+191val_191
+192val_192
+193val_193
+193val_193
+193val_193
+194val_194
+195val_195
+195val_195
+196val_196
+197val_197
+197val_197
+199val_199
+199val_199
+199val_199
+2val_2
+20val_20
+200val_200
+200val_200
+201val_201
+202val_202
+203val_203
+203val_203
+205val_205
+205val_205
+207val_207
+207val_207
+208val_208
+208val_208
+208val_208
+209val_209
+209val_209
+213val_213
+213val_213
+214val_214
+216val_216
+216val_216
+217val_217
+217val_217
+218val_218
+219val_219
+219val_219
+221val_221
+221val_221
+222val_222
+223val_223
+223val_223
+224val_224
+224val_224
+226val_226
+228val_228
+229val_229
+229val_229
+230val_230
+230val_230
+230val_230
+230val_230
+230val_230
+233val_233
+233val_233
+235val_235
+237val_237
+237val_237
+238val_238
+238val_238
+239val_239
+239val_239
+24val_24
+24val_24
+241val_241
+242val_242
+242val_242
+244val_244
+247val_247
+248val_248
+249val_249
+252val_252
+255val_255
+255val_255
+256val_256
+256val_256
+257val_257
+258val_258
+26val_26
+26val_26
+260val_260
+262val_262
+263val_263
+265val_265
+265val_265
+266val_266
+27val_27
+272val_272
+272val_272
+273val_273
+273val_273
+273val_273
+274val_274
+275val_275
+277val_277
+277val_277
+277val_277
+277val_277
+278val_278
+278val_278
+28val_28
+280val_280
+280val_280
+281val_281
+281val_281
+282val_282
+282val_282
+283val_283
+284val_284
+285val_285
+286val_286
+287val_287
+288val_288
+288val_288
+289val_289
+291val_291
+292val_292
+296val_296
+298val_298
+298val_298
+298val_298
+30val_30
+302val_302
+305val_305
+306val_306
+307val_307
+307val_307
+308val_308
+309val_309
+309val_309
+310val_310
+311val_311
+311val_311
+311val_311
+315val_315
+316val_316
+316val_316
+316val_316
+317val_317
+317val_317
+318val_318
+318val_318
+318val_318
+321val_321
+321val_321
+322val_322
+322val_322
+323val_323
+325val_325
+325val_325
+327val_327
+327val_327
+327val_327
+33val_33
+331val_331
+331val_331
+332val_332
+333val_333
+333val_333
+335val_335
+336val_336
+338val_338
+339val_339
+34val_34
+341val_341
+342val_342
+342val_342
+344val_344
+344val_344
+345val_345
+348val_348
+348val_348
+348val_348
+348val_348
+348val_348
+35val_35
+35val_35
+35val_35
+351val_351
+353val_353
+353val_353
+356val_356
+360val_360
+362val_362
+364val_364
+365val_365
+366val_366
+367val_367
+367val_367
+368val_368
+369val_369
+369val_369
+369val_369
+37val_37
+37val_37
+373val_373
+374val_374
+375val_375
+377val_377
+378val_378
+379val_379
+382val_382
+382val_382
+384val_384
+384val_384
+384val_384
+386val_386
+389val_389
+392val_392
+393val_393
+394val_394
+395val_395
+395val_395
+396val_396
+396val_396
+396val_396
+397val_397
+397val_397
+399val_399
+399val_399
+4val_4
+400val_400
+401val_401
+401val_401
+401val_401
+401val_401
+401val_401
+402val_402
+403val_403
+403val_403
+403val_403
+404val_404
+404val_404
+406val_406
+406val_406
+406val_406
+406val_406
+407val_407
+409val_409
+409val_409
+409val_409
+41val_41
+411val_411
+413val_413
+413val_413
+414val_414
+414val_414
+417val_417
+417val_417
+417val_417
+418val_418
+419val_419
+42val_42
+42val_42
+421val_421
+424val_424
+424val_424
+427val_427
+429val_429
+429val_429
+43val_43
+430val_430
+430val_430
+430val_430
+431val_431
+431val_431
+431val_431
+432val_432
+435val_435
+436val_436
+437val_437
+438val_438
+438val_438
+438val_438
+439val_439
+439val_439
+44val_44
+443val_443
+444val_444
+446val_446
+448val_448
+449val_449
+452val_452
+453val_453
+454val_454
+454val_454
+454val_454
+455val_455
+457val_457
+458val_458
+458val_458
+459val_459
+459val_459
+460val_460
+462val_462
+462val_462
+463val_463
+463val_463
+466val_466
+466val_466
+466val_466
+467val_467
+468val_468
+468val_468
+468val_468
+468val_468
+469val_469
+469val_469
+469val_469
+469val_469
+469val_469
+47val_47
+470val_470
+472val_472
+475val_475
+477val_477
+478val_478
+478val_478
+479val_479
+480val_480
+480val_480
+480val_480
+481val_481
+482val_482
+483val_483
+484val_484
+485val_485
+487val_487
+489val_489
+489val_489
+489val_489
+489val_489
+490val_490
+491val_491
+492val_492
+492val_492
+493val_493
+494val_494
+495val_495
+496val_496
+497val_497
+498val_498
+498val_498
+498val_498
+5val_5
+5val_5
+5val_5
+51val_51
+51val_51
+53val_53
+54val_54
+57val_57
+58val_58
+58val_58
+64val_64
+65val_65
+66val_66
+67val_67
+67val_67
+69val_69
+70val_70
+70val_70
+70val_70
+72val_72
+72val_72
+74val_74
+76val_76
+76val_76
+77val_77
+78val_78
+8val_8
+80val_80
+82val_82
+83val_83
+83val_83
+84val_84
+84val_84
+85val_85
+86val_86
+87val_87
+9val_9
+90val_90
+90val_90
+90val_90
+92val_92
+95val_95
+95val_95
+96val_96
+97val_97
+97val_97
+98val_98
+98val_98

+ 500 - 0
src/contrib/hive/data/files/kv1.txt

@@ -0,0 +1,500 @@
+238val_238
+86val_86
+311val_311
+27val_27
+165val_165
+409val_409
+255val_255
+278val_278
+98val_98
+484val_484
+265val_265
+193val_193
+401val_401
+150val_150
+273val_273
+224val_224
+369val_369
+66val_66
+128val_128
+213val_213
+146val_146
+406val_406
+429val_429
+374val_374
+152val_152
+469val_469
+145val_145
+495val_495
+37val_37
+327val_327
+281val_281
+277val_277
+209val_209
+15val_15
+82val_82
+403val_403
+166val_166
+417val_417
+430val_430
+252val_252
+292val_292
+219val_219
+287val_287
+153val_153
+193val_193
+338val_338
+446val_446
+459val_459
+394val_394
+237val_237
+482val_482
+174val_174
+413val_413
+494val_494
+207val_207
+199val_199
+466val_466
+208val_208
+174val_174
+399val_399
+396val_396
+247val_247
+417val_417
+489val_489
+162val_162
+377val_377
+397val_397
+309val_309
+365val_365
+266val_266
+439val_439
+342val_342
+367val_367
+325val_325
+167val_167
+195val_195
+475val_475
+17val_17
+113val_113
+155val_155
+203val_203
+339val_339
+0val_0
+455val_455
+128val_128
+311val_311
+316val_316
+57val_57
+302val_302
+205val_205
+149val_149
+438val_438
+345val_345
+129val_129
+170val_170
+20val_20
+489val_489
+157val_157
+378val_378
+221val_221
+92val_92
+111val_111
+47val_47
+72val_72
+4val_4
+280val_280
+35val_35
+427val_427
+277val_277
+208val_208
+356val_356
+399val_399
+169val_169
+382val_382
+498val_498
+125val_125
+386val_386
+437val_437
+469val_469
+192val_192
+286val_286
+187val_187
+176val_176
+54val_54
+459val_459
+51val_51
+138val_138
+103val_103
+239val_239
+213val_213
+216val_216
+430val_430
+278val_278
+176val_176
+289val_289
+221val_221
+65val_65
+318val_318
+332val_332
+311val_311
+275val_275
+137val_137
+241val_241
+83val_83
+333val_333
+180val_180
+284val_284
+12val_12
+230val_230
+181val_181
+67val_67
+260val_260
+404val_404
+384val_384
+489val_489
+353val_353
+373val_373
+272val_272
+138val_138
+217val_217
+84val_84
+348val_348
+466val_466
+58val_58
+8val_8
+411val_411
+230val_230
+208val_208
+348val_348
+24val_24
+463val_463
+431val_431
+179val_179
+172val_172
+42val_42
+129val_129
+158val_158
+119val_119
+496val_496
+0val_0
+322val_322
+197val_197
+468val_468
+393val_393
+454val_454
+100val_100
+298val_298
+199val_199
+191val_191
+418val_418
+96val_96
+26val_26
+165val_165
+327val_327
+230val_230
+205val_205
+120val_120
+131val_131
+51val_51
+404val_404
+43val_43
+436val_436
+156val_156
+469val_469
+468val_468
+308val_308
+95val_95
+196val_196
+288val_288
+481val_481
+457val_457
+98val_98
+282val_282
+197val_197
+187val_187
+318val_318
+318val_318
+409val_409
+470val_470
+137val_137
+369val_369
+316val_316
+169val_169
+413val_413
+85val_85
+77val_77
+0val_0
+490val_490
+87val_87
+364val_364
+179val_179
+118val_118
+134val_134
+395val_395
+282val_282
+138val_138
+238val_238
+419val_419
+15val_15
+118val_118
+72val_72
+90val_90
+307val_307
+19val_19
+435val_435
+10val_10
+277val_277
+273val_273
+306val_306
+224val_224
+309val_309
+389val_389
+327val_327
+242val_242
+369val_369
+392val_392
+272val_272
+331val_331
+401val_401
+242val_242
+452val_452
+177val_177
+226val_226
+5val_5
+497val_497
+402val_402
+396val_396
+317val_317
+395val_395
+58val_58
+35val_35
+336val_336
+95val_95
+11val_11
+168val_168
+34val_34
+229val_229
+233val_233
+143val_143
+472val_472
+322val_322
+498val_498
+160val_160
+195val_195
+42val_42
+321val_321
+430val_430
+119val_119
+489val_489
+458val_458
+78val_78
+76val_76
+41val_41
+223val_223
+492val_492
+149val_149
+449val_449
+218val_218
+228val_228
+138val_138
+453val_453
+30val_30
+209val_209
+64val_64
+468val_468
+76val_76
+74val_74
+342val_342
+69val_69
+230val_230
+33val_33
+368val_368
+103val_103
+296val_296
+113val_113
+216val_216
+367val_367
+344val_344
+167val_167
+274val_274
+219val_219
+239val_239
+485val_485
+116val_116
+223val_223
+256val_256
+263val_263
+70val_70
+487val_487
+480val_480
+401val_401
+288val_288
+191val_191
+5val_5
+244val_244
+438val_438
+128val_128
+467val_467
+432val_432
+202val_202
+316val_316
+229val_229
+469val_469
+463val_463
+280val_280
+2val_2
+35val_35
+283val_283
+331val_331
+235val_235
+80val_80
+44val_44
+193val_193
+321val_321
+335val_335
+104val_104
+466val_466
+366val_366
+175val_175
+403val_403
+483val_483
+53val_53
+105val_105
+257val_257
+406val_406
+409val_409
+190val_190
+406val_406
+401val_401
+114val_114
+258val_258
+90val_90
+203val_203
+262val_262
+348val_348
+424val_424
+12val_12
+396val_396
+201val_201
+217val_217
+164val_164
+431val_431
+454val_454
+478val_478
+298val_298
+125val_125
+431val_431
+164val_164
+424val_424
+187val_187
+382val_382
+5val_5
+70val_70
+397val_397
+480val_480
+291val_291
+24val_24
+351val_351
+255val_255
+104val_104
+70val_70
+163val_163
+438val_438
+119val_119
+414val_414
+200val_200
+491val_491
+237val_237
+439val_439
+360val_360
+248val_248
+479val_479
+305val_305
+417val_417
+199val_199
+444val_444
+120val_120
+429val_429
+169val_169
+443val_443
+323val_323
+325val_325
+277val_277
+230val_230
+478val_478
+178val_178
+468val_468
+310val_310
+317val_317
+333val_333
+493val_493
+460val_460
+207val_207
+249val_249
+265val_265
+480val_480
+83val_83
+136val_136
+353val_353
+172val_172
+214val_214
+462val_462
+233val_233
+406val_406
+133val_133
+175val_175
+189val_189
+454val_454
+375val_375
+401val_401
+421val_421
+407val_407
+384val_384
+256val_256
+26val_26
+134val_134
+67val_67
+384val_384
+379val_379
+18val_18
+462val_462
+492val_492
+100val_100
+298val_298
+9val_9
+341val_341
+498val_498
+146val_146
+458val_458
+362val_362
+186val_186
+285val_285
+348val_348
+167val_167
+18val_18
+273val_273
+183val_183
+281val_281
+344val_344
+97val_97
+469val_469
+315val_315
+84val_84
+28val_28
+37val_37
+448val_448
+152val_152
+348val_348
+307val_307
+194val_194
+414val_414
+477val_477
+222val_222
+126val_126
+90val_90
+169val_169
+403val_403
+400val_400
+200val_200
+97val_97

+ 500 - 0
src/contrib/hive/data/files/kv1.val.sorted.txt

@@ -0,0 +1,500 @@
+val_0
+val_0
+val_0
+val_10
+val_100
+val_100
+val_103
+val_103
+val_104
+val_104
+val_105
+val_11
+val_111
+val_113
+val_113
+val_114
+val_116
+val_118
+val_118
+val_119
+val_119
+val_119
+val_12
+val_12
+val_120
+val_120
+val_125
+val_125
+val_126
+val_128
+val_128
+val_128
+val_129
+val_129
+val_131
+val_133
+val_134
+val_134
+val_136
+val_137
+val_137
+val_138
+val_138
+val_138
+val_138
+val_143
+val_145
+val_146
+val_146
+val_149
+val_149
+val_15
+val_15
+val_150
+val_152
+val_152
+val_153
+val_155
+val_156
+val_157
+val_158
+val_160
+val_162
+val_163
+val_164
+val_164
+val_165
+val_165
+val_166
+val_167
+val_167
+val_167
+val_168
+val_169
+val_169
+val_169
+val_169
+val_17
+val_170
+val_172
+val_172
+val_174
+val_174
+val_175
+val_175
+val_176
+val_176
+val_177
+val_178
+val_179
+val_179
+val_18
+val_18
+val_180
+val_181
+val_183
+val_186
+val_187
+val_187
+val_187
+val_189
+val_19
+val_190
+val_191
+val_191
+val_192
+val_193
+val_193
+val_193
+val_194
+val_195
+val_195
+val_196
+val_197
+val_197
+val_199
+val_199
+val_199
+val_2
+val_20
+val_200
+val_200
+val_201
+val_202
+val_203
+val_203
+val_205
+val_205
+val_207
+val_207
+val_208
+val_208
+val_208
+val_209
+val_209
+val_213
+val_213
+val_214
+val_216
+val_216
+val_217
+val_217
+val_218
+val_219
+val_219
+val_221
+val_221
+val_222
+val_223
+val_223
+val_224
+val_224
+val_226
+val_228
+val_229
+val_229
+val_230
+val_230
+val_230
+val_230
+val_230
+val_233
+val_233
+val_235
+val_237
+val_237
+val_238
+val_238
+val_239
+val_239
+val_24
+val_24
+val_241
+val_242
+val_242
+val_244
+val_247
+val_248
+val_249
+val_252
+val_255
+val_255
+val_256
+val_256
+val_257
+val_258
+val_26
+val_26
+val_260
+val_262
+val_263
+val_265
+val_265
+val_266
+val_27
+val_272
+val_272
+val_273
+val_273
+val_273
+val_274
+val_275
+val_277
+val_277
+val_277
+val_277
+val_278
+val_278
+val_28
+val_280
+val_280
+val_281
+val_281
+val_282
+val_282
+val_283
+val_284
+val_285
+val_286
+val_287
+val_288
+val_288
+val_289
+val_291
+val_292
+val_296
+val_298
+val_298
+val_298
+val_30
+val_302
+val_305
+val_306
+val_307
+val_307
+val_308
+val_309
+val_309
+val_310
+val_311
+val_311
+val_311
+val_315
+val_316
+val_316
+val_316
+val_317
+val_317
+val_318
+val_318
+val_318
+val_321
+val_321
+val_322
+val_322
+val_323
+val_325
+val_325
+val_327
+val_327
+val_327
+val_33
+val_331
+val_331
+val_332
+val_333
+val_333
+val_335
+val_336
+val_338
+val_339
+val_34
+val_341
+val_342
+val_342
+val_344
+val_344
+val_345
+val_348
+val_348
+val_348
+val_348
+val_348
+val_35
+val_35
+val_35
+val_351
+val_353
+val_353
+val_356
+val_360
+val_362
+val_364
+val_365
+val_366
+val_367
+val_367
+val_368
+val_369
+val_369
+val_369
+val_37
+val_37
+val_373
+val_374
+val_375
+val_377
+val_378
+val_379
+val_382
+val_382
+val_384
+val_384
+val_384
+val_386
+val_389
+val_392
+val_393
+val_394
+val_395
+val_395
+val_396
+val_396
+val_396
+val_397
+val_397
+val_399
+val_399
+val_4
+val_400
+val_401
+val_401
+val_401
+val_401
+val_401
+val_402
+val_403
+val_403
+val_403
+val_404
+val_404
+val_406
+val_406
+val_406
+val_406
+val_407
+val_409
+val_409
+val_409
+val_41
+val_411
+val_413
+val_413
+val_414
+val_414
+val_417
+val_417
+val_417
+val_418
+val_419
+val_42
+val_42
+val_421
+val_424
+val_424
+val_427
+val_429
+val_429
+val_43
+val_430
+val_430
+val_430
+val_431
+val_431
+val_431
+val_432
+val_435
+val_436
+val_437
+val_438
+val_438
+val_438
+val_439
+val_439
+val_44
+val_443
+val_444
+val_446
+val_448
+val_449
+val_452
+val_453
+val_454
+val_454
+val_454
+val_455
+val_457
+val_458
+val_458
+val_459
+val_459
+val_460
+val_462
+val_462
+val_463
+val_463
+val_466
+val_466
+val_466
+val_467
+val_468
+val_468
+val_468
+val_468
+val_469
+val_469
+val_469
+val_469
+val_469
+val_47
+val_470
+val_472
+val_475
+val_477
+val_478
+val_478
+val_479
+val_480
+val_480
+val_480
+val_481
+val_482
+val_483
+val_484
+val_485
+val_487
+val_489
+val_489
+val_489
+val_489
+val_490
+val_491
+val_492
+val_492
+val_493
+val_494
+val_495
+val_496
+val_497
+val_498
+val_498
+val_498
+val_5
+val_5
+val_5
+val_51
+val_51
+val_53
+val_54
+val_57
+val_58
+val_58
+val_64
+val_65
+val_66
+val_67
+val_67
+val_69
+val_70
+val_70
+val_70
+val_72
+val_72
+val_74
+val_76
+val_76
+val_77
+val_78
+val_8
+val_80
+val_82
+val_83
+val_83
+val_84
+val_84
+val_85
+val_86
+val_87
+val_9
+val_90
+val_90
+val_90
+val_92
+val_95
+val_95
+val_96
+val_97
+val_97
+val_98
+val_98

+ 1000 - 0
src/contrib/hive/data/files/kv1kv2.cogroup.txt

@@ -0,0 +1,1000 @@
+0val_0
+0val_0
+0val_0
+10
+10
+11
+0val_10
+110
+0val_100
+0val_100
+1100
+1100
+1101
+1102
+0val_103
+0val_103
+0val_104
+0val_104
+1104
+1104
+1104
+0val_105
+1105
+1105
+1106
+0val_11
+111
+111
+111
+1110
+0val_111
+0val_113
+0val_113
+0val_114
+1114
+1114
+1114
+0val_116
+1116
+1117
+1117
+0val_118
+0val_118
+1118
+1118
+1118
+0val_119
+0val_119
+0val_119
+1119
+1119
+1119
+0val_12
+0val_12
+112
+0val_120
+0val_120
+1120
+1121
+1121
+1122
+1122
+1122
+1123
+1123
+0val_125
+0val_125
+1125
+0val_126
+1126
+1126
+0val_128
+0val_128
+0val_128
+1128
+1128
+0val_129
+0val_129
+1129
+1129
+0val_131
+1132
+1132
+0val_133
+1133
+0val_134
+0val_134
+1134
+1135
+1135
+1135
+0val_136
+1136
+0val_137
+0val_137
+1137
+0val_138
+0val_138
+0val_138
+0val_138
+1138
+1138
+1140
+0val_143
+1143
+1144
+0val_145
+0val_146
+0val_146
+1147
+1147
+0val_149
+0val_149
+1149
+0val_15
+0val_15
+115
+115
+0val_150
+1151
+1151
+0val_152
+0val_152
+1152
+1152
+1152
+0val_153
+1153
+1153
+0val_155
+0val_156
+1156
+1156
+0val_157
+1157
+1157
+0val_158
+116
+116
+0val_160
+1160
+1161
+1161
+1161
+1161
+0val_162
+1162
+0val_163
+0val_164
+0val_164
+1164
+1164
+0val_165
+0val_165
+1165
+0val_166
+0val_167
+0val_167
+0val_167
+1167
+0val_168
+1168
+0val_169
+0val_169
+0val_169
+0val_169
+0val_17
+0val_170
+1170
+0val_172
+0val_172
+1172
+0val_174
+0val_174
+1174
+1174
+0val_175
+0val_175
+1175
+1175
+0val_176
+0val_176
+0val_177
+1177
+1177
+0val_178
+1178
+1178
+0val_179
+0val_179
+1179
+0val_18
+0val_18
+0val_180
+0val_181
+1182
+0val_183
+1183
+1184
+1185
+0val_186
+0val_187
+0val_187
+0val_187
+0val_189
+1189
+0val_19
+119
+0val_190
+0val_191
+0val_191
+1191
+0val_192
+1192
+0val_193
+0val_193
+0val_193
+0val_194
+0val_195
+0val_195
+0val_196
+1196
+1196
+1196
+0val_197
+0val_197
+1197
+0val_199
+0val_199
+0val_199
+1199
+0val_2
+12
+0val_20
+120
+120
+0val_200
+0val_200
+0val_201
+0val_202
+0val_203
+0val_203
+1204
+0val_205
+0val_205
+1205
+1206
+1206
+1206
+0val_207
+0val_207
+0val_208
+0val_208
+0val_208
+0val_209
+0val_209
+1209
+1209
+121
+121
+121
+121
+1212
+0val_213
+0val_213
+1213
+0val_214
+1215
+0val_216
+0val_216
+1216
+0val_217
+0val_217
+1217
+1217
+0val_218
+0val_219
+0val_219
+122
+0val_221
+0val_221
+0val_222
+1222
+0val_223
+0val_223
+0val_224
+0val_224
+1224
+0val_226
+1226
+1226
+1226
+1226
+1227
+0val_228
+1228
+0val_229
+0val_229
+123
+0val_230
+0val_230
+0val_230
+0val_230
+0val_230
+1231
+0val_233
+0val_233
+0val_235
+1235
+0val_237
+0val_237
+0val_238
+0val_238
+1238
+0val_239
+0val_239
+1239
+1239
+0val_24
+0val_24
+1240
+0val_241
+1241
+1241
+1241
+1241
+0val_242
+0val_242
+1242
+1243
+1243
+0val_244
+1244
+1244
+1244
+1245
+1245
+1246
+1246
+0val_247
+0val_248
+1248
+0val_249
+1249
+1249
+0val_252
+1252
+1254
+0val_255
+0val_255
+0val_256
+0val_256
+1256
+0val_257
+1257
+1257
+0val_258
+1258
+1259
+1259
+0val_26
+0val_26
+0val_260
+1260
+1260
+1261
+0val_262
+1262
+1262
+0val_263
+1264
+1264
+0val_265
+0val_265
+1265
+0val_266
+1267
+1268
+0val_27
+1271
+0val_272
+0val_272
+1272
+0val_273
+0val_273
+0val_273
+1273
+0val_274
+1274
+0val_275
+1275
+1275
+1276
+0val_277
+0val_277
+0val_277
+0val_277
+1277
+1277
+0val_278
+0val_278
+1278
+0val_28
+0val_280
+0val_280
+0val_281
+0val_281
+1281
+1281
+1281
+0val_282
+0val_282
+0val_283
+0val_284
+1284
+1284
+0val_285
+1285
+0val_286
+1286
+0val_287
+1287
+1287
+0val_288
+0val_288
+0val_289
+1289
+129
+129
+0val_291
+1291
+1291
+0val_292
+1292
+1292
+1293
+1293
+1295
+1295
+0val_296
+1296
+0val_298
+0val_298
+0val_298
+13
+0val_30
+130
+1300
+1300
+0val_302
+1302
+1303
+1303
+1304
+0val_305
+1305
+0val_306
+1306
+0val_307
+0val_307
+0val_308
+1308
+1308
+0val_309
+0val_309
+1309
+131
+0val_310
+1310
+1310
+1310
+0val_311
+0val_311
+0val_311
+1313
+1314
+0val_315
+0val_316
+0val_316
+0val_316
+0val_317
+0val_317
+1317
+0val_318
+0val_318
+0val_318
+1318
+132
+0val_321
+0val_321
+0val_322
+0val_322
+1322
+0val_323
+1323
+1324
+0val_325
+0val_325
+1326
+0val_327
+0val_327
+0val_327
+1328
+1328
+0val_33
+133
+1330
+0val_331
+0val_331
+1331
+1331
+0val_332
+0val_333
+0val_333
+1333
+1334
+0val_335
+1335
+1335
+0val_336
+1336
+1337
+0val_338
+1338
+0val_339
+0val_34
+1340
+0val_341
+1341
+1341
+1341
+0val_342
+0val_342
+1342
+1343
+0val_344
+0val_344
+1344
+0val_345
+1347
+1347
+0val_348
+0val_348
+0val_348
+0val_348
+0val_348
+1348
+1349
+1349
+1349
+1349
+0val_35
+0val_35
+0val_35
+135
+135
+135
+0val_351
+1351
+1351
+1352
+1352
+0val_353
+0val_353
+1353
+1355
+1355
+0val_356
+1356
+1356
+1358
+0val_360
+1360
+0val_362
+1363
+1363
+1363
+0val_364
+1364
+0val_365
+0val_366
+0val_367
+0val_367
+1367
+1367
+0val_368
+0val_369
+0val_369
+0val_369
+1369
+0val_37
+0val_37
+1371
+1371
+1371
+1371
+0val_373
+1373
+0val_374
+1374
+0val_375
+1375
+1375
+1375
+1375
+1375
+1376
+0val_377
+0val_378
+1378
+0val_379
+1379
+1381
+0val_382
+0val_382
+1382
+1382
+0val_384
+0val_384
+0val_384
+1384
+1384
+1384
+1385
+1385
+0val_386
+1386
+1386
+1388
+0val_389
+1389
+1389
+1390
+1390
+1390
+1391
+1391
+0val_392
+1392
+1392
+0val_393
+1393
+1393
+0val_394
+0val_395
+0val_395
+1395
+1395
+0val_396
+0val_396
+0val_396
+0val_397
+0val_397
+1398
+0val_399
+0val_399
+1399
+1399
+0val_4
+14
+140
+140
+0val_400
+0val_401
+0val_401
+0val_401
+0val_401
+0val_401
+1401
+0val_402
+1402
+1402
+1402
+0val_403
+0val_403
+0val_403
+0val_404
+0val_404
+1404
+1404
+1404
+1405
+0val_406
+0val_406
+0val_406
+0val_406
+1406
+0val_407
+1407
+1407
+1407
+1408
+1408
+0val_409
+0val_409
+0val_409
+1409
+1409
+0val_41
+1410
+0val_411
+1411
+1412
+1412
+0val_413
+0val_413
+1413
+0val_414
+0val_414
+1414
+1415
+1416
+0val_417
+0val_417
+0val_417
+0val_418
+0val_419
+0val_42
+0val_42
+142
+142
+142
+0val_421
+1421
+1421
+1423
+0val_424
+0val_424
+1424
+1425
+1426
+0val_427
+1427
+1427
+1428
+0val_429
+0val_429
+1429
+1429
+0val_43
+0val_430
+0val_430
+0val_430
+1430
+0val_431
+0val_431
+0val_431
+1431
+0val_432
+1432
+0val_435
+1435
+0val_436
+1436
+0val_437
+1437
+0val_438
+0val_438
+0val_438
+1438
+1438
+0val_439
+0val_439
+1439
+1439
+0val_44
+1440
+1440
+1441
+1442
+0val_443
+1443
+1443
+1443
+0val_444
+0val_446
+1446
+1446
+1447
+0val_448
+1448
+0val_449
+1450
+1450
+1451
+0val_452
+0val_453
+1453
+0val_454
+0val_454
+0val_454
+1454
+1454
+0val_455
+1455
+1455
+0val_457
+1457
+1457
+0val_458
+0val_458
+0val_459
+0val_459
+1459
+146
+0val_460
+1461
+0val_462
+0val_462
+1462
+0val_463
+0val_463
+1463
+0val_466
+0val_466
+0val_466
+0val_467
+1467
+0val_468
+0val_468
+0val_468
+0val_468
+1468
+1468
+1468
+0val_469
+0val_469
+0val_469
+0val_469
+0val_469
+1469
+0val_47
+147
+0val_470
+1470
+0val_472
+1473
+1474
+1474
+0val_475
+1475
+1476
+1476
+0val_477
+1477
+0val_478
+0val_478
+1478
+1478
+0val_479
+148
+148
+0val_480
+0val_480
+0val_480
+1480
+1480
+0val_481
+1481
+0val_482
+1482
+0val_483
+0val_484
+1484
+0val_485
+1485
+1485
+1486
+0val_487
+1487
+1488
+0val_489
+0val_489
+0val_489
+0val_489
+1489
+149
+149
+0val_490
+1490
+0val_491
+1491
+1491
+0val_492
+0val_492
+1492
+1492
+0val_493
+0val_494
+1494
+1494
+0val_495
+1495
+0val_496
+1496
+0val_497
+1497
+1497
+0val_498
+0val_498
+0val_498
+0val_5
+0val_5
+0val_5
+15
+150
+0val_51
+0val_51
+151
+152
+152
+152
+152
+0val_53
+153
+0val_54
+156
+0val_57
+0val_58
+0val_58
+158
+158
+159
+16
+16
+160
+161
+162
+162
+163
+0val_64
+0val_65
+165
+165
+0val_66
+0val_67
+0val_67
+168
+0val_69
+169
+0val_70
+0val_70
+0val_70
+170
+171
+0val_72
+0val_72
+0val_74
+175
+0val_76
+0val_76
+176
+176
+176
+0val_77
+177
+177
+0val_78
+178
+0val_8
+18
+0val_80
+180
+0val_82
+182
+182
+0val_83
+0val_83
+0val_84
+0val_84
+0val_85
+185
+0val_86
+186
+0val_87
+187
+187
+189
+189
+189
+0val_9
+0val_90
+0val_90
+0val_90
+191
+0val_92
+193
+193
+193
+194
+0val_95
+0val_95
+0val_96
+0val_97
+0val_97
+197
+197
+0val_98
+0val_98
+199

+ 500 - 0
src/contrib/hive/data/files/kv2.txt

@@ -0,0 +1,500 @@
+474val_475
+281val_282
+179val_180
+291val_292
+62val_63
+271val_272
+217val_218
+135val_136
+167val_168
+468val_469
+423val_424
+413val_414
+245val_246
+455val_456
+425val_426
+241val_242
+177val_178
+272val_273
+231val_232
+448val_449
+287val_288
+246val_247
+440val_441
+31val_32
+373val_374
+447val_448
+443val_444
+175val_176
+278val_279
+296val_297
+147val_148
+428val_429
+126val_127
+249val_250
+21val_22
+273val_274
+441val_442
+106val_107
+371val_372
+153val_154
+356val_357
+217val_218
+490val_491
+33val_34
+35val_36
+421val_422
+243val_244
+402val_403
+128val_129
+10val_11
+226val_227
+133val_134
+333val_334
+15val_16
+110val_111
+391val_392
+343val_344
+275val_276
+0val_1
+485val_486
+293val_294
+240val_241
+241val_242
+286val_287
+85val_86
+408val_409
+477val_478
+455val_456
+99val_100
+335val_336
+476val_477
+482val_483
+367val_368
+59val_60
+48val_49
+424val_425
+226val_227
+494val_495
+488val_489
+94val_95
+485val_486
+393val_394
+349val_350
+11val_12
+161val_162
+123val_124
+409val_410
+50val_51
+265val_266
+402val_403
+128val_129
+468val_469
+314val_315
+497val_498
+224val_225
+63val_64
+344val_345
+4val_5
+277val_278
+135val_136
+3val_4
+206val_207
+101val_102
+331val_332
+114val_115
+209val_210
+281val_282
+56val_57
+239val_240
+389val_390
+114val_115
+254val_255
+235val_236
+390val_391
+165val_166
+304val_305
+264val_265
+196val_197
+238val_239
+20val_21
+11val_12
+492val_493
+129val_130
+257val_258
+71val_72
+289val_290
+453val_454
+421val_422
+82val_83
+58val_59
+5val_6
+86val_87
+249val_250
+438val_439
+360val_361
+323val_324
+222val_223
+42val_43
+467val_468
+411val_412
+175val_176
+429val_430
+338val_339
+281val_282
+68val_69
+185val_186
+16val_17
+147val_148
+119val_120
+492val_493
+473val_474
+376val_377
+347val_348
+120val_121
+213val_214
+306val_307
+393val_394
+427val_428
+291val_292
+426val_427
+132val_133
+446val_447
+386val_387
+65val_66
+121val_122
+388val_389
+184val_185
+375val_376
+284val_285
+191val_192
+129val_130
+246val_247
+197val_198
+491val_492
+369val_370
+262val_263
+122val_123
+438val_439
+351val_352
+390val_391
+352val_353
+23val_24
+226val_227
+328val_329
+382val_383
+342val_343
+349val_350
+480val_481
+102val_103
+497val_498
+487val_488
+480val_481
+331val_332
+409val_410
+475val_476
+463val_464
+183val_184
+177val_178
+399val_400
+15val_16
+318val_319
+149val_150
+392val_393
+77val_78
+275val_276
+476val_477
+258val_259
+174val_175
+252val_253
+114val_115
+87val_88
+161val_162
+75val_76
+264val_265
+48val_49
+336val_337
+340val_341
+390val_391
+443val_444
+484val_485
+407val_408
+189val_190
+305val_306
+367val_368
+6val_7
+260val_261
+2val_3
+349val_350
+170val_171
+51val_52
+355val_356
+363val_364
+164val_165
+118val_119
+310val_311
+104val_105
+19val_20
+80val_81
+117val_118
+326val_327
+47val_48
+121val_122
+241val_242
+450val_451
+140val_141
+212val_213
+308val_309
+30val_31
+405val_406
+239val_240
+119val_120
+358val_359
+11val_12
+49val_50
+143val_144
+153val_154
+341val_342
+21val_22
+105val_106
+157val_158
+416val_417
+199val_200
+375val_376
+42val_43
+89val_90
+363val_364
+395val_396
+347val_348
+386val_387
+77val_78
+454val_455
+293val_294
+364val_365
+20val_21
+89val_90
+461val_462
+52val_53
+40val_41
+8val_9
+168val_169
+384val_385
+313val_314
+324val_325
+310val_311
+206val_207
+381val_382
+404val_405
+206val_207
+385val_386
+259val_260
+226val_227
+262val_263
+69val_70
+303val_304
+245val_246
+260val_261
+328val_329
+322val_323
+122val_123
+241val_242
+469val_470
+404val_405
+384val_385
+76val_77
+116val_117
+42val_43
+104val_105
+481val_482
+303val_304
+93val_94
+277val_278
+406val_407
+451val_452
+53val_54
+32val_33
+132val_133
+192val_193
+58val_59
+351val_352
+70val_71
+443val_444
+356val_357
+399val_400
+205val_206
+352val_353
+52val_53
+21val_22
+317val_318
+330val_331
+209val_210
+138val_139
+429val_430
+160val_161
+267val_268
+454val_455
+257val_258
+76val_77
+174val_175
+412val_413
+16val_17
+375val_376
+489val_490
+295val_296
+105val_106
+204val_205
+126val_127
+274val_275
+439val_440
+374val_375
+494val_495
+216val_217
+457val_458
+93val_94
+470val_471
+196val_197
+302val_303
+119val_120
+375val_376
+391val_392
+287val_288
+450val_451
+375val_376
+437val_438
+12val_13
+398val_399
+35val_36
+334val_335
+384val_385
+435val_436
+60val_61
+29val_30
+442val_443
+151val_152
+52val_53
+404val_405
+446val_447
+300val_301
+0val_1
+268val_269
+491val_492
+392val_393
+21val_22
+295val_296
+93val_94
+104val_105
+436val_437
+61val_62
+407val_408
+439val_440
+156val_157
+341val_342
+118val_119
+335val_336
+172val_173
+244val_245
+6val_7
+284val_285
+164val_165
+136val_137
+349val_350
+371val_372
+462val_463
+123val_124
+432val_433
+496val_497
+355val_356
+144val_145
+87val_88
+408val_409
+152val_153
+382val_383
+348val_349
+122val_123
+427val_428
+292val_293
+182val_183
+474val_475
+353val_354
+310val_311
+52val_53
+486val_487
+152val_153
+378val_379
+414val_415
+261val_262
+65val_66
+371val_372
+256val_257
+292val_293
+412val_413
+97val_98
+495val_496
+385val_386
+40val_41
+49val_50
+389val_390
+259val_260
+97val_98
+478val_479
+125val_126
+243val_244
+151val_152
+178val_179
+100val_101
+415val_416
+401val_402
+156val_157
+228val_229
+363val_364
+117val_118
+22val_23
+248val_249
+459val_460
+402val_403
+62val_63
+137val_138
+162val_163
+244val_245
+276val_277
+46val_47
+341val_342
+78val_79
+379val_380
+215val_216
+134val_135
+196val_197
+410val_411
+157val_158
+431val_432
+82val_83
+440val_441
+100val_101
+407val_408
+371val_372
+308val_309
+430val_431
+309val_310
+135val_136
+161val_162
+468val_469
+152val_153
+138val_139
+76val_77
+161val_162
+300val_301
+337val_338
+91val_92
+478val_479
+118val_119
+1val_2
+89val_90
+178val_179
+457val_458
+29val_30
+242val_243
+285val_286
+35val_36
+227val_228
+395val_396
+244val_245

+ 25 - 0
src/contrib/hive/data/files/kv3.txt

@@ -0,0 +1,25 @@
+238val_238
+
+311val_311
+val_27
+val_165
+val_409
+255val_255
+278val_278
+98val_98
+val_484
+val_265
+val_193
+401val_401
+150val_150
+273val_273
+224
+369
+66val_66
+128
+213val_213
+146val_146
+406val_406
+
+
+

+ 84 - 0
src/contrib/hive/data/files/lt100.sorted.txt

@@ -0,0 +1,84 @@
+0val_0
+0val_0
+0val_0
+10val_10
+11val_11
+12val_12
+12val_12
+15val_15
+15val_15
+17val_17
+18val_18
+18val_18
+19val_19
+2val_2
+20val_20
+24val_24
+24val_24
+26val_26
+26val_26
+27val_27
+28val_28
+30val_30
+33val_33
+34val_34
+35val_35
+35val_35
+35val_35
+37val_37
+37val_37
+4val_4
+41val_41
+42val_42
+42val_42
+43val_43
+44val_44
+47val_47
+5val_5
+5val_5
+5val_5
+51val_51
+51val_51
+53val_53
+54val_54
+57val_57
+58val_58
+58val_58
+64val_64
+65val_65
+66val_66
+67val_67
+67val_67
+69val_69
+70val_70
+70val_70
+70val_70
+72val_72
+72val_72
+74val_74
+76val_76
+76val_76
+77val_77
+78val_78
+8val_8
+80val_80
+82val_82
+83val_83
+83val_83
+84val_84
+84val_84
+85val_85
+86val_86
+87val_87
+9val_9
+90val_90
+90val_90
+90val_90
+92val_92
+95val_95
+95val_95
+96val_96
+97val_97
+97val_97
+98val_98
+98val_98

+ 84 - 0
src/contrib/hive/data/files/lt100.txt

@@ -0,0 +1,84 @@
+86val_86
+27val_27
+98val_98
+66val_66
+37val_37
+15val_15
+82val_82
+17val_17
+0val_0
+57val_57
+20val_20
+92val_92
+47val_47
+72val_72
+4val_4
+35val_35
+54val_54
+51val_51
+65val_65
+83val_83
+12val_12
+67val_67
+84val_84
+58val_58
+8val_8
+24val_24
+42val_42
+0val_0
+96val_96
+26val_26
+51val_51
+43val_43
+95val_95
+98val_98
+85val_85
+77val_77
+0val_0
+87val_87
+15val_15
+72val_72
+90val_90
+19val_19
+10val_10
+5val_5
+58val_58
+35val_35
+95val_95
+11val_11
+34val_34
+42val_42
+78val_78
+76val_76
+41val_41
+30val_30
+64val_64
+76val_76
+74val_74
+69val_69
+33val_33
+70val_70
+5val_5
+2val_2
+35val_35
+80val_80
+44val_44
+53val_53
+90val_90
+12val_12
+5val_5
+70val_70
+24val_24
+70val_70
+83val_83
+26val_26
+67val_67
+18val_18
+9val_9
+18val_18
+97val_97
+84val_84
+28val_28
+37val_37
+90val_90
+97val_97

+ 14 - 0
src/contrib/hive/lib/README

@@ -0,0 +1,14 @@
+Folowing is the list of external jars contained in this directory and the sources from where they were obtained:
+---------------------------------------------------------------------------------------------------------------
+
+*  libfb303.jar - http://developers.facebook.com/thrift/
+*  libthrift.jar - http://developers.facebook.com/thrift/
+*  jpox-core-1.2.2.jar - http://www.jpox.org/docs/download.html
+*  derby.jar - http://db.apache.org/derby/derby_downloads.html
+*  asm-3.1.jar - http://forge.objectweb.org/projects/asm/
+*  jpox-enhancer-1.2.2.jar - http://www.jpox.org/docs/download.html
+*  jdo2-api-2.1.jar - http://db.apache.org/jdo/downloads.html
+*  jpox-rdbms-1.2.2.jar - http://www.jpox.org/docs/download.html
+*  velocity-1.5.jar - http://velocity.apache.org/engine/releases/velocity-1.5/
+*  commons-collections-3.2.1.jar - http://commons.apache.org/downloads/download_collections.cgi
+*  commons-lang-2.4.jar - http://commons.apache.org/downloads/download_lang.cgi

+ 29 - 0
src/contrib/hive/lib/asm-3.1.LICENSE

@@ -0,0 +1,29 @@
+Copyright (c) 2000-2005 INRIA, France Telecom
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holders nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.

BIN
src/contrib/hive/lib/asm-3.1.jar


+ 201 - 0
src/contrib/hive/lib/commons-collections-3.2.1.LICENSE

@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.

BIN
src/contrib/hive/lib/commons-collections-3.2.1.jar


+ 201 - 0
src/contrib/hive/lib/commons-lang-2.4.LICENSE

@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.

BIN
src/contrib/hive/lib/commons-lang-2.4.jar


+ 201 - 0
src/contrib/hive/lib/derby.LICENSE

@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.

BIN
src/contrib/hive/lib/derby.jar


+ 201 - 0
src/contrib/hive/lib/jdo2-api-2.1.LICENSE

@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.

BIN
src/contrib/hive/lib/jdo2-api-2.1.jar


+ 174 - 0
src/contrib/hive/lib/jpox-core-1.2.2.LICENSE

@@ -0,0 +1,174 @@
+                                Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.

BIN
src/contrib/hive/lib/jpox-core-1.2.2.jar


+ 174 - 0
src/contrib/hive/lib/jpox-enhancer-1.2.2.LICENSE

@@ -0,0 +1,174 @@
+                                Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.

BIN
src/contrib/hive/lib/jpox-enhancer-1.2.2.jar


+ 174 - 0
src/contrib/hive/lib/jpox-rdbms-1.2.2.LICENSE

@@ -0,0 +1,174 @@
+                                Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.

BIN
src/contrib/hive/lib/jpox-rdbms-1.2.2.jar


+ 19 - 0
src/contrib/hive/lib/libfb303.LICENSE

@@ -0,0 +1,19 @@
+Thrift Software License
+
+Copyright © 2006- Facebook, Inc.
+
+Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the 
+software and accompanying documentation covered by this license (the "Software") to use, reproduce, 
+display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, 
+and to permit third-parties to whom the Software is furnished to do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including the above license grant, 
+this restriction and the following disclaimer, must be included in all copies of the Software, in whole 
+or in part, and all derivative works of the Software, unless such copies or derivative works are solely 
+in the form of machine-executable object code generated by a source language processor.
+
+The software is provided "as is", without warranty of any kind, express or implied, including but not 
+limited to the warranties of merchantability, fitness for a particular purpose, title and non-infringement. 
+In no event shall the copyright holders or anyone distributing the software be liable for any damages or 
+other liability, whether in contract, tort, or otherwise, arising from, out of or in connection with the 
+software or the use or other dealings in the software.

BIN
src/contrib/hive/lib/libfb303.jar


+ 19 - 0
src/contrib/hive/lib/libthrift.LICENSE

@@ -0,0 +1,19 @@
+Thrift Software License
+
+Copyright © 2006- Facebook, Inc.
+
+Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the 
+software and accompanying documentation covered by this license (the "Software") to use, reproduce, 
+display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, 
+and to permit third-parties to whom the Software is furnished to do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including the above license grant, 
+this restriction and the following disclaimer, must be included in all copies of the Software, in whole 
+or in part, and all derivative works of the Software, unless such copies or derivative works are solely 
+in the form of machine-executable object code generated by a source language processor.
+
+The software is provided "as is", without warranty of any kind, express or implied, including but not 
+limited to the warranties of merchantability, fitness for a particular purpose, title and non-infringement. 
+In no event shall the copyright holders or anyone distributing the software be liable for any damages or 
+other liability, whether in contract, tort, or otherwise, arising from, out of or in connection with the 
+software or the use or other dealings in the software.

BIN
src/contrib/hive/lib/libthrift.jar


BIN
src/contrib/hive/lib/velocity-1.5.jar


+ 201 - 0
src/contrib/hive/lib/velocity.LICENSE

@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.

+ 93 - 0
src/contrib/hive/metastore/build.xml

@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+
+<project name="metastore" default="jar">
+  <property name="src.dir" value="${basedir}/src"/>
+  <import file="../build-common.xml"/>
+  <property name="model.dir" value="${src.dir}/model"/>
+
+  <target name="thriftif">
+    <echo>Executing thrift (which needs to be in your path) to build java metastore APIs.... </echo>
+    <exec executable="thrift"  failonerror="true" dir=".">
+      <arg line="--gen java:beans -php --gen py -I ${basedir}/include/ -o ${src.dir} if/hive_metastore.thrift " />
+    </exec>
+  </target>
+
+  <target name="core-compile" depends="init, model-compile">
+    <echo message="Compiling: "/>
+    <javac
+     encoding="${build.encoding}"
+     srcdir="${src.dir}/java:${src.dir}/gen-javabean"
+     includes="**/*.java"
+     destdir="${build.classes}"
+     debug="${javac.debug}"
+     deprecation="${javac.deprecation}"
+     >
+      <classpath refid="classpath"/>
+    </javac>
+  </target>
+ 
+  <target name="compile" depends="core-compile, model-compile, model-enhance">
+  </target>
+
+  <target name="model-compile" depends="init">
+    <javac srcdir="${model.dir}"  destdir="${build.classes}" debug="${javac.debug}"> 
+       <classpath refid="classpath"/> 
+    </javac> 
+    <!-- ORM data for model -->
+    <copy file="${model.dir}/package.jdo" todir="${build.classes}"/>
+  </target>
+
+  <uptodate property="enhanceModel.notRequired">
+    <srcfiles dir= "${model.dir}" includes="**/*.java,*.jdo"/>
+    <mapper type="merge" to="${build.dir}/hive_${name}.jar"/>
+  </uptodate>
+
+  <target name="model-enhance" depends="model-compile" unless="enhanceModel.notRequired">
+    <echo>Enhancing model classes with JPOX stuff....</echo>
+    <java classname="org.jpox.enhancer.JPOXEnhancer"  failonerror="true" dir="${basedir}" fork="true">
+      <classpath>
+        <path refid="classpath"/>
+        <pathelement path="${build.dir}/classes/"/>
+      </classpath>
+      <sysproperty key="log4j.configuration" value="file:${basedir}/../conf/hive-log4j.properties"/>
+      <arg value="${model.dir}/package.jdo" />
+    </java>
+  </target>
+
+  <target name="model-jar" depends="model-enhance">
+    <echo message="Jar: ${name}"/>
+    <jar
+      jarfile="${build.dir}/${name}_model.jar"
+      basedir="${build.classes}"     
+      includes="**/model/M*" 
+    />
+  </target>
+
+  <target name="generate-schema">
+    <java classname="org.jpox.SchemaTool"  failonerror="true" dir="${basedir}" fork="true">
+      <classpath>
+        <path refid="classpath"/>
+        <pathelement path="${build.dir}/classes/"/>
+      </classpath>
+      <sysproperty key="log4j.configuration" value="file:${basedir}/../../../../conf/log4j.properties"/>
+      <arg line="-props jdo/jpox.properties -create jdo/package.jdo" />
+    </java>
+  </target>
+</project>

+ 6 - 0
src/contrib/hive/metastore/derby.log

@@ -0,0 +1,6 @@
+----------------------------------------------------------------
+2008-08-29 00:34:24.906 GMT:
+ Booting Derby version The Apache Software Foundation - Apache Derby - 10.4.1.3 - (648739): instance a816c00e-011c-0be1-e12e-000000decd40
+on database directory /home/athusoo/apacheprojects/hadoop-core-trunk_ws1/build/contrib/hive/test/junit_metastore_db  
+
+Database Class Loader started - derby.database.classpath=''

+ 291 - 0
src/contrib/hive/metastore/if/hive_metastore.thrift

@@ -0,0 +1,291 @@
+#!/usr/local/bin/thrift -java
+#
+# Thrift Service that the MetaStore is built on
+# Pete Wyckoff (pwyckoff@facebook.com)
+#
+
+/**
+ * The available types in Thrift:
+ *
+ *  bool        Boolean, one byte
+ *  byte        Signed byte
+ *  i16         Signed 16-bit integer
+ *  i32         Signed 32-bit integer
+ *  i64         Signed 64-bit integer
+ *  double      64-bit floating point value
+ *  string      String
+ *  map<t1,t2>  Map from one type to another
+ *  list<t1>    Ordered list of one type
+ *  set<t1>     Set of unique elements of one type
+ *
+ */
+
+include "thrift/fb303/if/fb303.thrift"
+
+
+namespace java org.apache.hadoop.hive.metastore.api
+namespace php metastore
+
+// below is terrible - tight, tight integration like you know who... bugbug
+// need to add a level of indirection to name these things..
+const string META_SERDE = "com.facebook.serde.simple_meta.MetadataTypedColumnsetSerDe"
+
+const string META_TABLE_COLUMNS  = "columns",
+const string BUCKET_FIELD_NAME   = "bucket_field_name",
+const string BUCKET_COUNT        = "bucket_count",
+const string FIELD_TO_DIMENSION  = "field_to_dimension",
+const string META_TABLE_NAME     = "name",
+const string META_TABLE_DB     = "db",
+const string META_TABLE_LOCATION = "location",
+const string META_TABLE_SERDE    = "serde",
+const string SERIALIZATION_FORMAT = "serialization.format",
+const string SERIALIZATION_CLASS = "serialization.class",
+const string SERIALIZATION_LIB = "serialization.lib",
+const string META_TABLE_PARTITION_COLUMNS = "partition_columns",
+const string FILE_INPUT_FORMAT = "file.inputformat",
+const string FILE_OUTPUT_FORMAT = "file.outputformat",
+
+
+exception MetaException {
+  string message
+}
+
+exception UnknownTableException {
+  string message
+}
+
+exception UnknownDBException {
+  string message
+}
+
+// new metastore api, below will be merged with above
+
+const string KEY_COMMENTS = "key_comments";
+const string VERSION_0_1 = "0.1";
+
+typedef string PrimitiveType
+typedef string CollectionType
+
+const string TINYINT_TYPE_NAME = "tinyint";
+const string INT_TYPE_NAME = "int";
+const string BIGINT_TYPE_NAME = "bigint";
+const string FLOAT_TYPE_NAME = "float";
+const string DOUBLE_TYPE_NAME = "double"; 
+const string STRING_TYPE_NAME = "string";
+const string DATE_TYPE_NAME = "date";
+const string DATETIME_TYPE_NAME = "datetime";
+const string TIMESTAMP_TYPE_NAME = "timestamp";
+
+const string LIST_TYPE_NAME = "list";
+const string MAP_TYPE_NAME = "map";
+
+const set<string> PrimitiveTypes = [ TINYINT_TYPE_NAME INT_TYPE_NAME BIGINT_TYPE_NAME FLOAT_TYPE_NAME DOUBLE_TYPE_NAME STRING_TYPE_NAME  DATE_TYPE_NAME DATETIME_TYPE_NAME TIMESTAMP_TYPE_NAME ],
+const set<string> CollectionTypes = [ LIST_TYPE_NAME MAP_TYPE_NAME ],
+
+struct Version {
+  string version,
+  string comments
+}
+
+struct FieldSchema {
+  string name,
+  string type,
+  string comment
+}
+
+struct Type {
+  string name, // one of the types in PrimitiveTypes or CollectionTypes or User defined types
+  optional string type1, // object type if the name is 'list' (LIST_TYPE), key type if the name is 'map' (MAP_TYPE)
+  optional string type2, // val type if the name is 'map' (MAP_TYPE)
+  optional list<FieldSchema> fields //if the name is one of the user defined types
+}
+
+// groups a set of tables
+struct Database {
+  string name,
+  string locationUri,
+}
+
+struct SerDeInfo {
+  string name;
+  string serializationFormat;
+  string serializationClass;
+  string serializationLib;
+  string fieldDelim;
+  string collectionItemDelim;
+  string mapKeyDelim;
+  string lineDelim;
+  map<string, string> parameters
+}
+
+struct Order {
+  string col,
+  i32 order
+}
+
+struct StorageDescriptor {
+  list<FieldSchema> cols,
+  string location,
+  string inputFormat;
+  string outputFormat;
+  bool isCompressed;
+  i32 numBuckets = 32, // this must be specified if there are any dimension columns
+  SerDeInfo serdeInfo;
+  list<string> bucketCols, //reducer grouping columns and clustering columns and bucketing columns`
+  list<Order> sortCols,
+  map<string, string> parameters
+}
+
+struct Table {
+  string tableName,
+  string database,
+  string owner,
+  i32 createTime,
+  i32 lastAccessTime,
+  i32 retention,
+  StorageDescriptor sd,
+  list<FieldSchema> partitionKeys, // optional
+  map<string, string> parameters // to store comments or any other user level parameters
+}
+
+struct Partition {
+  // keys are inherited from table. this should be okay because partition keys can't be changed over time
+  list<string> values // string value is converted to appropriate partition key type
+  string database,
+  string tableName,
+  i32 createTime,
+  i32 lastAccessTime,
+  StorageDescriptor sd,
+  map<string, string> parameters
+}
+
+// index on a hive table is also another table whose columns are the subset of the base table columns along with the offset
+// this will automatically generate table (table_name_index_name)
+struct Index {
+  string indexName, // unique with in the whole database namespace
+  i32 indexType, // reserved
+  string tableName,
+  string databaseName,
+  list<string> colNames, // for now columns will be sorted in the ascending order
+}
+
+exception AlreadyExistsException {
+  string message
+}
+
+exception InvalidObjectException {
+  string message
+}
+
+exception ExistingDependentsException {
+  string message
+}
+
+exception NoSuchObjectException {
+  string message
+}
+
+exception IndexAlreadyExistsException {
+  string message
+}
+
+exception InvalidOperationException {
+  string message
+}
+
+/**
+* This interface is NOT live yet.
+*/
+service ThriftHiveMetastore extends fb303.FacebookService
+{
+  // Database
+  bool create_database(1:string name, 2:string location_uri) throws(1:AlreadyExistsException o1, 2:MetaException o2)
+  Database get_database(1:string name) throws(1:NoSuchObjectException o1, 2:MetaException o2)
+  bool drop_database(1:string name) throws(2:MetaException o2)
+  list<string> get_databases() throws(1:MetaException o1)
+
+  // Type
+  // returns the type with given name (make seperate calls for the dependent types if needed)
+  Type get_type(1:string name) throws(1:MetaException o2)
+  bool create_type(1:Type type) throws(1:AlreadyExistsException o1, 2:InvalidObjectException o2, 3:MetaException o3)
+  bool drop_type(1:string type) throws(1:MetaException o2)
+  map<string, Type> get_type_all(1:string name) throws(1:MetaException o2)
+
+  list<FieldSchema> get_fields(string db_name, string table_name) throws (MetaException ouch1, UnknownTableException ouch2, UnknownDBException ouch3),
+
+  // Tables
+  // create the table with the given table object in the given database
+  void create_table(1:Table tbl) throws(1:AlreadyExistsException ouch1, 2:InvalidObjectException ouch2, 3:MetaException ouch3, 4:NoSuchObjectException o4)
+  // drops the table and all the partitions associated with it if the table has partitions
+  // delete data (including partitions) if deleteData is set to true
+  void drop_table(1:string dbname, 2:string name, 3:bool deleteData) throws(1:NoSuchObjectException o1, 2:MetaException ouch3)
+  list<string> get_tables(string db_name, string pattern)  throws (MetaException ouch1, UnknownTableException ouch2, UnknownDBException ouch3)
+  Table get_table(1:string dbname, 2:string tbl_name) throws (1:MetaException o1, 2:NoSuchObjectException o2)
+  bool set_table_parameters(1:string dbname, 2:string tbl_name, 3:map<string, string> params) throws(1:NoSuchObjectException o1, 2:MetaException o2)
+  // this applies to only future partitions not for existing partitions
+  void alter_table(1:string dbname, 2:string tbl_name, 3:Table new_tbl) throws (1:InvalidOperationException o1, 2:MetaException o2)
+  void truncate_table(1:string db_name, 2:string table_name, 3:string partition)  throws (1:MetaException ouch1, 2:UnknownTableException ouch2, 3:UnknownDBException ouch3),
+  list<string> cat(1:string db_name, 2:string table_name, 3:string partition, i32 high) throws  (MetaException ouch1, UnknownDBException ouch2, UnknownTableException ouch3),
+
+  // Partition
+  // the following applies to only tables that have partitions
+  Partition add_partition(1:Partition new_part) throws(1:InvalidObjectException o1, 2:AlreadyExistsException o2, 3:MetaException o3)
+  Partition append_partition(1:string db_name, 2:string tbl_name, 3:list<string> part_vals) throws (1:InvalidObjectException o1, 2:AlreadyExistsException o2, 3:MetaException o3)
+  bool drop_partition(1:string db_name, 2:string tbl_name, 3:list<string> part_vals, 4:bool deleteData) throws(1:NoSuchObjectException o1, 2:MetaException o2)
+  Partition get_partition(1:string db_name, 2:string tbl_name, 3:list<string> part_vals) throws(1:MetaException o1)
+  // returns all the partitions for this table in reverse chronological order. if max parts is given then it will return only that many
+  list<Partition> get_partitions(1:string db_name, 2:string tbl_name, 3:i16 max_parts=-1) throws(1:NoSuchObjectException o1, 2:MetaException o2)
+  // this can be used if an old parition has to be recreated
+  bool set_partition_parameters(1:string db_name, 2:string tbl_name, 3:string pname, 4:map<string, string> params) throws(1:NoSuchObjectException o1, 2:MetaException o2)
+  // changes the given partitions to the new storage descriptor. all partitions should belong to the same table
+  bool alter_partitions(1:StorageDescriptor sd, 2:list<string> parts) throws(1:InvalidOperationException o1, 2:MetaException o2)
+
+  // Index
+  // index related metadata (may not be in the open source)
+  bool create_index(1:Index index_def) throws(1:IndexAlreadyExistsException o1, 2:MetaException o2)
+}
+
+
+/**
+* This interface is the live.
+*/
+service ThriftMetaStore extends fb303.FacebookService
+{
+  // retrieve a printable representation of the fields in a table (logfile, type) or table subtype
+  list<FieldSchema> get_fields(string db_name, string table_name) throws (MetaException ouch1, UnknownTableException ouch2, UnknownDBException ouch3),
+
+  // get all the tables (logfiles, types) in the metastore - no partitioning like different dbs yet
+  list<string> get_tables(string db_name, string pattern)  throws (MetaException ouch1, UnknownTableException ouch2, UnknownDBException ouch3),
+
+  // retrieve the opaque schema representation of this table (logfile, type) which contains enough
+  // information for the caller to instantiate some kind of object that will let it examine the type.
+  // That object might be a thrift, jute, or SerDe.
+  map<string,string> get_schema(string table_name) throws (MetaException ouch1, UnknownTableException ouch2, UnknownDBException ouch3),
+
+  // add some structure to the table or change its structure
+  void alter_table(string db_name, string table_name, map<string,string> schema) throws (MetaException ouch1, UnknownTableException ouch2, UnknownDBException ouch3),
+
+  // create_table == create_table4 (table_name, SIMPLE_META_SERDE, '\t', "",  dict [ META_COLUMNS => columns]
+  // bugbug do above transformation and deprecate this API
+  void create_table(string db_name, string table_name, map<string,string> schema) throws (MetaException ouch1, UnknownDBException ouch2),
+
+  // drop a table (i.e., remove it from the metastore) - for now allow metastore to do the delete (so python shell can do drops)
+  void drop_table(string db_name, string table_name) throws  (MetaException ouch1, UnknownTableException ouch2, UnknownDBException ouch3),
+
+  // truncate a table - i.e., delete its data, but keep the hdfs directory and the schema
+  void truncate_table(string db_name, string table_name, string partition)  throws (MetaException ouch1, UnknownTableException ouch2, UnknownDBException ouch3),
+
+  // generally does the table exist
+  bool table_exists(string db_name, string table_name) throws (MetaException ouch1, UnknownDBException ouch2),
+
+  // create a table with named columns
+  list<string> get_partitions(string db_name, string table_name) throws (MetaException ouch1, UnknownTableException ouch2, UnknownDBException ouch3),
+
+  // enumerate all the databases in this store
+  list<string> get_dbs() throws  (MetaException ouch),
+
+  // /bin/cat the table in human readable format
+  list<string> cat(string db_name, string table_name,string partition, i32 high) throws  (MetaException ouch1, UnknownDBException ouch2, UnknownTableException ouch3),
+}
+
+

+ 151 - 0
src/contrib/hive/metastore/include/thrift/TLogging.h

@@ -0,0 +1,151 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#ifndef _THRIFT_TLOGGING_H_
+#define _THRIFT_TLOGGING_H_ 1
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+/**
+ * Contains utility macros for debugging and logging.
+ *
+ * @author Aditya Agarwal
+ */
+
+#ifndef HAVE_CLOCK_GETTIME
+#include <time.h>
+#else
+#include <sys/time.h>
+#endif
+
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
+/**
+ * T_GLOBAL_DEBUGGING_LEVEL = 0: all debugging turned off, debug macros undefined
+ * T_GLOBAL_DEBUGGING_LEVEL = 1: all debugging turned on  
+ */
+#define T_GLOBAL_DEBUGGING_LEVEL 0
+
+
+/**
+ * T_GLOBAL_LOGGING_LEVEL = 0: all logging turned off, logging macros undefined
+ * T_GLOBAL_LOGGING_LEVEL = 1: all logging turned on  
+ */
+#define T_GLOBAL_LOGGING_LEVEL   1
+
+
+/** 
+ * Standard wrapper around fprintf what will prefix the file name and line
+ * number to the line. Uses T_GLOBAL_DEBUGGING_LEVEL to control whether it is
+ * turned on or off.
+ *
+ * @param format_string 
+ */
+#if T_GLOBAL_DEBUGGING_LEVEL > 0
+  #define T_DEBUG(format_string,...)                                        \
+    if (T_GLOBAL_DEBUGGING_LEVEL > 0) {                                     \
+      fprintf(stderr,"[%s,%d] " #format_string " \n", __FILE__, __LINE__,##__VA_ARGS__); \
+  } 
+#else
+  #define T_DEBUG(format_string,...)
+#endif
+
+
+/** 
+ * analagous to T_DEBUG but also prints the time 
+ *
+ * @param string  format_string input: printf style format string
+ */
+#if T_GLOBAL_DEBUGGING_LEVEL > 0
+  #define T_DEBUG_T(format_string,...)                                    \
+    {                                                                     \
+      if (T_GLOBAL_DEBUGGING_LEVEL > 0) {                                 \
+        time_t now;                                                       \
+        char dbgtime[26] ;                                                \
+        time(&now);                                                       \
+        ctime_r(&now, dbgtime);                                           \
+        dbgtime[24] = '\0';                                               \
+        fprintf(stderr,"[%s,%d] [%s] " #format_string " \n", __FILE__, __LINE__,dbgtime,##__VA_ARGS__); \
+      }                                                                   \
+    }
+#else
+  #define T_DEBUG_T(format_string,...)
+#endif
+
+
+/** 
+ * analagous to T_DEBUG but uses input level to determine whether or not the string
+ * should be logged.
+ *
+ * @param int     level: specified debug level
+ * @param string  format_string input: format string
+ */
+#define T_DEBUG_L(level, format_string,...)                               \
+  if ((level) > 0) {                                                      \
+    fprintf(stderr,"[%s,%d] " #format_string " \n", __FILE__, __LINE__,##__VA_ARGS__); \
+  }
+
+
+/** 
+ * Explicit error logging. Prints time, file name and line number
+ *
+ * @param string  format_string input: printf style format string
+ */
+#define T_ERROR(format_string,...)                                      \
+  {                                                                     \
+    time_t now;                                                         \
+    char dbgtime[26] ;                                                  \
+    time(&now);                                                         \
+    ctime_r(&now, dbgtime);                                             \
+    dbgtime[24] = '\0';                                                 \
+    fprintf(stderr,"[%s,%d] [%s] ERROR: " #format_string " \n", __FILE__, __LINE__,dbgtime,##__VA_ARGS__); \
+  }
+
+
+/** 
+ * Analagous to T_ERROR, additionally aborting the process.
+ * WARNING: macro calls abort(), ending program execution
+ *
+ * @param string  format_string input: printf style format string
+ */
+#define T_ERROR_ABORT(format_string,...)                                \
+  {                                                                     \
+    time_t now;                                                         \
+    char dbgtime[26] ;                                                  \
+    time(&now);                                                         \
+    ctime_r(&now, dbgtime);                                             \
+    dbgtime[24] = '\0';                                                 \
+    fprintf(stderr,"[%s,%d] [%s] ERROR: Going to abort " #format_string " \n", __FILE__, __LINE__,dbgtime,##__VA_ARGS__); \
+    exit(1);                                                            \
+  }
+
+
+/** 
+ * Log input message
+ *
+ * @param string  format_string input: printf style format string
+ */
+#if T_GLOBAL_LOGGING_LEVEL > 0
+  #define T_LOG_OPER(format_string,...)                                       \
+    {                                                                         \
+      if (T_GLOBAL_LOGGING_LEVEL > 0) {                                       \
+        time_t now;                                                           \
+        char dbgtime[26] ;                                                    \
+        time(&now);                                                           \
+        ctime_r(&now, dbgtime);                                               \
+        dbgtime[24] = '\0';                                                   \
+        fprintf(stderr,"[%s] " #format_string " \n", dbgtime,##__VA_ARGS__);  \
+      }                                                                       \
+    } 
+#else
+  #define T_LOG_OPER(format_string,...)
+#endif
+
+#endif // #ifndef _THRIFT_TLOGGING_H_

+ 41 - 0
src/contrib/hive/metastore/include/thrift/TProcessor.h

@@ -0,0 +1,41 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#ifndef _THRIFT_TPROCESSOR_H_
+#define _THRIFT_TPROCESSOR_H_ 1
+
+#include <string>
+#include <protocol/TProtocol.h>
+#include <boost/shared_ptr.hpp>
+
+namespace facebook { namespace thrift { 
+
+/**
+ * A processor is a generic object that acts upon two streams of data, one
+ * an input and the other an output. The definition of this object is loose,
+ * though the typical case is for some sort of server that either generates
+ * responses to an input stream or forwards data from one pipe onto another.
+ *
+ * @author Mark Slee <mcslee@facebook.com>
+ */
+class TProcessor {
+ public:
+  virtual ~TProcessor() {}
+
+  virtual bool process(boost::shared_ptr<protocol::TProtocol> in,
+                       boost::shared_ptr<protocol::TProtocol> out) = 0;
+
+  bool process(boost::shared_ptr<facebook::thrift::protocol::TProtocol> io) {
+    return process(io, io);
+  }
+
+ protected:
+  TProcessor() {}
+};
+
+}} // facebook::thrift
+
+#endif // #ifndef _THRIFT_PROCESSOR_H_

+ 84 - 0
src/contrib/hive/metastore/include/thrift/TReflectionLocal.h

@@ -0,0 +1,84 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#ifndef _THRIFT_TREFLECTIONLOCAL_H_
+#define _THRIFT_TREFLECTIONLOCAL_H_ 1
+
+#include <stdint.h>
+#include <cstring>
+#include <protocol/TProtocol.h>
+
+/**
+ * Local Reflection is a blanket term referring to the the structure
+ * and generation of this particular representation of Thrift types.
+ * (It is called local because it cannot be serialized by Thrift).
+ *
+ * @author David Reiss <dreiss@facebook.com>
+ */
+
+namespace facebook { namespace thrift { namespace reflection { namespace local {
+
+using facebook::thrift::protocol::TType;
+
+// We include this many bytes of the structure's fingerprint when serializing
+// a top-level structure.  Long enough to make collisions unlikely, short
+// enough to not significantly affect the amount of memory used.
+const int FP_PREFIX_LEN = 4;
+
+struct FieldMeta {
+  int16_t tag;
+  bool is_optional;
+};
+
+struct TypeSpec {
+  TType ttype;
+  uint8_t    fp_prefix[FP_PREFIX_LEN];
+
+  // Use an anonymous union here so we can fit two TypeSpecs in one cache line.
+  union {
+    struct {
+      // Use parallel arrays here for denser packing (of the arrays).
+      FieldMeta* metas;
+      TypeSpec** specs;
+    } tstruct;
+    struct {
+      TypeSpec *subtype1;
+      TypeSpec *subtype2;
+    } tcontainer;
+  };
+
+  // Static initialization of unions isn't really possible,
+  // so take the plunge and use constructors.
+  // Hopefully they'll be evaluated at compile time.
+
+  TypeSpec(TType ttype) : ttype(ttype) {
+    std::memset(fp_prefix, 0, FP_PREFIX_LEN);
+  }
+
+  TypeSpec(TType ttype,
+           const uint8_t* fingerprint,
+           FieldMeta* metas,
+           TypeSpec** specs) :
+    ttype(ttype)
+  {
+    std::memcpy(fp_prefix, fingerprint, FP_PREFIX_LEN);
+    tstruct.metas = metas;
+    tstruct.specs = specs;
+  }
+
+  TypeSpec(TType ttype, TypeSpec* subtype1, TypeSpec* subtype2) :
+    ttype(ttype)
+  {
+    std::memset(fp_prefix, 0, FP_PREFIX_LEN);
+    tcontainer.subtype1 = subtype1;
+    tcontainer.subtype2 = subtype2;
+  }
+
+};
+
+}}}} // facebook::thrift::reflection::local
+
+#endif // #ifndef _THRIFT_TREFLECTIONLOCAL_H_

+ 162 - 0
src/contrib/hive/metastore/include/thrift/Thrift.h

@@ -0,0 +1,162 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#ifndef _THRIFT_THRIFT_H_
+#define _THRIFT_THRIFT_H_ 1
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <netinet/in.h>
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
+#include <string>
+#include <map>
+#include <list>
+#include <set>
+#include <vector>
+#include <exception>
+
+#include "TLogging.h"
+
+namespace facebook { namespace thrift {
+
+class TOutput {
+ public:
+  TOutput() : f_(&perrorTimeWrapper) {}
+
+  inline void setOutputFunction(void (*function)(const char *)){
+    f_ = function;
+  }
+
+  inline void operator()(const char *message){
+    f_(message);
+  }
+
+  inline static void perrorTimeWrapper(const char* msg) {
+    time_t now;
+    char dbgtime[25];
+    time(&now);
+    ctime_r(&now, dbgtime);
+    dbgtime[24] = 0;
+    fprintf(stderr, "%s ", dbgtime);
+    perror(msg);
+  }
+ private:
+  void (*f_)(const char *);
+};
+
+extern TOutput GlobalOutput;
+
+namespace protocol {
+  class TProtocol;
+}
+
+class TException : public std::exception {
+ public:
+  TException() {}
+
+  TException(const std::string& message) :
+    message_(message) {}
+
+  virtual ~TException() throw() {}
+
+  virtual const char* what() const throw() {
+    if (message_.empty()) {
+      return "Default TException.";
+    } else {
+      return message_.c_str();
+    }
+  }
+
+ protected:
+  std::string message_;
+
+};
+
+class TApplicationException : public TException {
+ public:
+
+  /**
+   * Error codes for the various types of exceptions.
+   */
+  enum TApplicationExceptionType {
+    UNKNOWN = 0,
+    UNKNOWN_METHOD = 1,
+    INVALID_MESSAGE_TYPE = 2,
+    WRONG_METHOD_NAME = 3,
+    BAD_SEQUENCE_ID = 4,
+    MISSING_RESULT = 5,
+  };
+
+  TApplicationException() :
+    TException(),
+    type_(UNKNOWN) {}
+
+  TApplicationException(TApplicationExceptionType type) :
+    TException(), 
+    type_(type) {}
+
+  TApplicationException(const std::string& message) :
+    TException(message),
+    type_(UNKNOWN) {}
+
+  TApplicationException(TApplicationExceptionType type,
+                        const std::string& message) :
+    TException(message),
+    type_(type) {}
+
+  virtual ~TApplicationException() throw() {}
+
+  /**
+   * Returns an error code that provides information about the type of error
+   * that has occurred.
+   *
+   * @return Error code
+   */
+  TApplicationExceptionType getType() {
+    return type_;
+  }
+
+  virtual const char* what() const throw() {
+    if (message_.empty()) {
+      switch (type_) {
+        case UNKNOWN              : return "TApplicationException: Unknown application exception";
+        case UNKNOWN_METHOD       : return "TApplicationException: Unknown method";
+        case INVALID_MESSAGE_TYPE : return "TApplicationException: Invalid message type";
+        case WRONG_METHOD_NAME    : return "TApplicationException: Wrong method name";
+        case BAD_SEQUENCE_ID      : return "TApplicationException: Bad sequence identifier";
+        case MISSING_RESULT       : return "TApplicationException: Missing result";
+        default                   : return "TApplicationException: (Invalid exception type)";
+      };
+    } else {
+      return message_.c_str();
+    }
+  }
+
+  uint32_t read(protocol::TProtocol* iprot);
+  uint32_t write(protocol::TProtocol* oprot) const;
+
+ protected:
+  /**
+   * Error code
+   */
+  TApplicationExceptionType type_;
+
+};
+
+
+// Forward declare this structure used by TDenseProtocol
+namespace reflection { namespace local {
+struct TypeSpec;
+}}
+
+
+}} // facebook::thrift
+
+#endif // #ifndef _THRIFT_THRIFT_H_

+ 47 - 0
src/contrib/hive/metastore/include/thrift/concurrency/Exception.h

@@ -0,0 +1,47 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#ifndef _THRIFT_CONCURRENCY_EXCEPTION_H_
+#define _THRIFT_CONCURRENCY_EXCEPTION_H_ 1
+
+#include <exception>
+#include <Thrift.h>
+
+namespace facebook { namespace thrift { namespace concurrency {
+
+class NoSuchTaskException : public facebook::thrift::TException {};
+
+class UncancellableTaskException : public facebook::thrift::TException {};
+
+class InvalidArgumentException : public facebook::thrift::TException {};
+
+class IllegalStateException : public facebook::thrift::TException {};
+
+class TimedOutException : public facebook::thrift::TException {
+public:                                            
+  TimedOutException():TException("TimedOutException"){};
+  TimedOutException(const std::string& message ) : 
+    TException(message) {}
+};
+
+class TooManyPendingTasksException : public facebook::thrift::TException {
+public:                                            
+  TooManyPendingTasksException():TException("TooManyPendingTasksException"){};
+  TooManyPendingTasksException(const std::string& message ) : 
+    TException(message) {}
+};
+
+class SystemResourceException : public facebook::thrift::TException {
+public:
+    SystemResourceException() {}
+
+    SystemResourceException(const std::string& message) :
+        TException(message) {}
+};
+
+}}} // facebook::thrift::concurrency
+
+#endif // #ifndef _THRIFT_CONCURRENCY_EXCEPTION_H_

+ 72 - 0
src/contrib/hive/metastore/include/thrift/concurrency/Monitor.h

@@ -0,0 +1,72 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#ifndef _THRIFT_CONCURRENCY_MONITOR_H_
+#define _THRIFT_CONCURRENCY_MONITOR_H_ 1
+
+#include "Exception.h"
+
+namespace facebook { namespace thrift { namespace concurrency {
+
+/**
+ * A monitor is a combination mutex and condition-event.  Waiting and
+ * notifying condition events requires that the caller own the mutex.  Mutex
+ * lock and unlock operations can be performed independently of condition
+ * events.  This is more or less analogous to java.lang.Object multi-thread
+ * operations
+ *
+ * Note that all methods are const.  Monitors implement logical constness, not
+ * bit constness.  This allows const methods to call monitor methods without
+ * needing to cast away constness or change to non-const signatures.
+ *
+ * @author marc
+ * @version $Id:$
+ */
+class Monitor {
+
+ public:
+
+  Monitor();
+
+  virtual ~Monitor();
+
+  virtual void lock() const;
+
+  virtual void unlock() const;
+
+  virtual void wait(int64_t timeout=0LL) const;
+
+  virtual void notify() const;
+
+  virtual void notifyAll() const;
+
+ private:
+
+  class Impl;
+
+  Impl* impl_;
+};
+
+class Synchronized {
+ public:
+
+ Synchronized(const Monitor& value) :
+   monitor_(value) {
+   monitor_.lock();
+  }
+
+  ~Synchronized() {
+    monitor_.unlock();
+  }
+
+ private:
+  const Monitor& monitor_;
+};
+
+
+}}} // facebook::thrift::concurrency
+
+#endif // #ifndef _THRIFT_CONCURRENCY_MONITOR_H_

+ 94 - 0
src/contrib/hive/metastore/include/thrift/concurrency/Mutex.h

@@ -0,0 +1,94 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#ifndef _THRIFT_CONCURRENCY_MUTEX_H_
+#define _THRIFT_CONCURRENCY_MUTEX_H_ 1
+
+#include <boost/shared_ptr.hpp>
+
+namespace facebook { namespace thrift { namespace concurrency { 
+
+/**
+ * A simple mutex class
+ *
+ * @author marc
+ * @version $Id:$
+ */
+class Mutex {
+ public:
+  Mutex();
+  virtual ~Mutex() {}
+  virtual void lock() const;
+  virtual bool trylock() const;
+  virtual void unlock() const;
+
+ private:
+
+  class impl;
+  boost::shared_ptr<impl> impl_;
+};
+
+class ReadWriteMutex {
+public:
+  ReadWriteMutex();
+  virtual ~ReadWriteMutex() {}
+
+  // these get the lock and block until it is done successfully
+  virtual void acquireRead() const;
+  virtual void acquireWrite() const;
+
+  // these attempt to get the lock, returning false immediately if they fail
+  virtual bool attemptRead() const;
+  virtual bool attemptWrite() const;
+
+  // this releases both read and write locks
+  virtual void release() const;
+   
+private:
+
+  class impl;
+  boost::shared_ptr<impl> impl_;
+};
+
+class Guard {
+ public: 
+  Guard(const Mutex& value) : mutex_(value) {
+    mutex_.lock();
+  }
+  ~Guard() {
+    mutex_.unlock();
+  }
+
+ private:
+  const Mutex& mutex_;
+};
+
+class RWGuard {
+  public: 
+    RWGuard(const ReadWriteMutex& value, bool write = 0) : rw_mutex_(value) {
+      if (write) {
+        rw_mutex_.acquireWrite();
+      } else {
+        rw_mutex_.acquireRead();
+      }
+    }  
+    ~RWGuard() {
+      rw_mutex_.release();
+    }  
+  private: 
+    const ReadWriteMutex& rw_mutex_;
+};  
+
+
+// A little hack to prevent someone from trying to do "Guard(m);"
+// Sorry for polluting the global namespace, but I think it's worth it.
+#define Guard(m) incorrect_use_of_Guard(m)
+#define RWGuard(m) incorrect_use_of_RWGuard(m)
+
+
+}}} // facebook::thrift::concurrency
+
+#endif // #ifndef _THRIFT_CONCURRENCY_MUTEX_H_

+ 118 - 0
src/contrib/hive/metastore/include/thrift/concurrency/PosixThreadFactory.h

@@ -0,0 +1,118 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#ifndef _THRIFT_CONCURRENCY_POSIXTHREADFACTORY_H_
+#define _THRIFT_CONCURRENCY_POSIXTHREADFACTORY_H_ 1
+
+#include "Thread.h"
+
+#include <boost/shared_ptr.hpp>
+
+namespace facebook { namespace thrift { namespace concurrency {
+
+/**
+ * A thread factory to create posix threads
+ *
+ * @author marc
+ * @version $Id:$
+ */
+class PosixThreadFactory : public ThreadFactory {
+
+ public:
+
+  /**
+   * POSIX Thread scheduler policies
+   */
+  enum POLICY {
+    OTHER,
+    FIFO,
+    ROUND_ROBIN
+  };
+
+  /**
+   * POSIX Thread scheduler relative priorities,
+   *
+   * Absolute priority is determined by scheduler policy and OS. This
+   * enumeration specifies relative priorities such that one can specify a
+   * priority withing a giving scheduler policy without knowing the absolute
+   * value of the priority.
+   */
+  enum PRIORITY {
+    LOWEST = 0,
+    LOWER = 1,
+    LOW = 2,
+    NORMAL = 3,
+    HIGH = 4,
+    HIGHER = 5,
+    HIGHEST = 6,
+    INCREMENT = 7,
+    DECREMENT = 8
+  };
+
+  /**
+   * Posix thread (pthread) factory.  All threads created by a factory are reference-counted
+   * via boost::shared_ptr and boost::weak_ptr.  The factory guarantees that threads and
+   * the Runnable tasks they host will be properly cleaned up once the last strong reference
+   * to both is given up.
+   *
+   * Threads are created with the specified policy, priority, stack-size and detachable-mode
+   * detached means the thread is free-running and will release all system resources the
+   * when it completes.  A detachable thread is not joinable.  The join method
+   * of a detachable thread will return immediately with no error.
+   *
+   * By default threads are not joinable.
+   */
+
+  PosixThreadFactory(POLICY policy=ROUND_ROBIN, PRIORITY priority=NORMAL, int stackSize=1, bool detached=true);
+
+  // From ThreadFactory;
+  boost::shared_ptr<Thread> newThread(boost::shared_ptr<Runnable> runnable) const;
+
+  // From ThreadFactory;
+  Thread::id_t getCurrentThreadId() const;
+
+  /**
+   * Gets stack size for created threads
+   *
+   * @return int size in megabytes
+   */
+  virtual int getStackSize() const;
+
+  /**
+   * Sets stack size for created threads
+   *
+   * @param value size in megabytes
+   */
+  virtual void setStackSize(int value);
+
+  /**
+   * Gets priority relative to current policy
+   */
+  virtual PRIORITY getPriority() const;
+
+  /**
+   * Sets priority relative to current policy
+   */
+  virtual void setPriority(PRIORITY priority);
+
+  /**
+   * Sets detached mode of threads
+   */
+  virtual void setDetached(bool detached);
+
+  /**
+   * Gets current detached mode
+   */
+  virtual bool isDetached() const;
+
+ private:
+  class Impl;
+  boost::shared_ptr<Impl> impl_;
+};
+
+}}} // facebook::thrift::concurrency
+
+#endif // #ifndef _THRIFT_CONCURRENCY_POSIXTHREADFACTORY_H_

+ 112 - 0
src/contrib/hive/metastore/include/thrift/concurrency/Thread.h

@@ -0,0 +1,112 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#ifndef _THRIFT_CONCURRENCY_THREAD_H_
+#define _THRIFT_CONCURRENCY_THREAD_H_ 1
+
+#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+
+namespace facebook { namespace thrift { namespace concurrency {
+
+class Thread;
+
+/**
+ * Minimal runnable class.  More or less analogous to java.lang.Runnable.
+ *
+ * @author marc
+ * @version $Id:$
+ */
+class Runnable {
+
+ public:
+  virtual ~Runnable() {};
+  virtual void run() = 0;
+
+  /**
+   * Gets the thread object that is hosting this runnable object  - can return
+   * an empty boost::shared pointer if no references remain on thet thread  object
+   */
+  virtual boost::shared_ptr<Thread> thread() { return thread_.lock(); }
+
+  /**
+   * Sets the thread that is executing this object.  This is only meant for
+   * use by concrete implementations of Thread.
+   */
+  virtual void thread(boost::shared_ptr<Thread> value) { thread_ = value; }
+
+ private:
+  boost::weak_ptr<Thread> thread_;
+};
+
+/**
+ * Minimal thread class. Returned by thread factory bound to a Runnable object
+ * and ready to start execution.  More or less analogous to java.lang.Thread
+ * (minus all the thread group, priority, mode and other baggage, since that
+ * is difficult to abstract across platforms and is left for platform-specific
+ * ThreadFactory implemtations to deal with
+ *
+ * @see facebook::thrift::concurrency::ThreadFactory)
+ */
+class Thread {
+
+ public:
+
+  typedef uint64_t id_t;
+
+  virtual ~Thread() {};
+
+  /**
+   * Starts the thread. Does platform specific thread creation and
+   * configuration then invokes the run method of the Runnable object bound
+   * to this thread.
+   */
+  virtual void start() = 0;
+
+  /**
+   * Join this thread. Current thread blocks until this target thread
+   * completes.
+   */
+  virtual void join() = 0;
+
+  /**
+   * Gets the thread's platform-specific ID
+   */
+  virtual id_t getId() = 0;
+
+  /**
+   * Gets the runnable object this thread is hosting
+   */
+  virtual boost::shared_ptr<Runnable> runnable() const { return _runnable; }
+
+ protected:
+  virtual void runnable(boost::shared_ptr<Runnable> value) { _runnable = value; }
+
+ private:
+  boost::shared_ptr<Runnable> _runnable;
+
+};
+
+/**
+ * Factory to create platform-specific thread object and bind them to Runnable
+ * object for execution
+ */
+class ThreadFactory {
+
+ public:
+  virtual ~ThreadFactory() {}
+  virtual boost::shared_ptr<Thread> newThread(boost::shared_ptr<Runnable> runnable) const = 0;
+
+  /** Gets the current thread id or unknown_thread_id if the current thread is not a thrift thread */
+
+  static const Thread::id_t unknown_thread_id;
+
+  virtual Thread::id_t getCurrentThreadId() const = 0;
+};
+
+}}} // facebook::thrift::concurrency
+
+#endif // #ifndef _THRIFT_CONCURRENCY_THREAD_H_

+ 157 - 0
src/contrib/hive/metastore/include/thrift/concurrency/ThreadManager.h

@@ -0,0 +1,157 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#ifndef _THRIFT_CONCURRENCY_THREADMANAGER_H_
+#define _THRIFT_CONCURRENCY_THREADMANAGER_H_ 1
+
+#include <boost/shared_ptr.hpp>
+#include <sys/types.h>
+#include "Thread.h"
+
+namespace facebook { namespace thrift { namespace concurrency {
+
+/**
+ * Thread Pool Manager and related classes
+ *
+ * @author marc
+ * @version $Id:$
+ */
+class ThreadManager;
+
+/**
+ * ThreadManager class
+ *
+ * This class manages a pool of threads. It uses a ThreadFactory to create
+ * threads. It never actually creates or destroys worker threads, rather
+ * It maintains statistics on number of idle threads, number of active threads,
+ * task backlog, and average wait and service times and informs the PoolPolicy
+ * object bound to instances of this manager of interesting transitions. It is
+ * then up the PoolPolicy object to decide if the thread pool size needs to be
+ * adjusted and call this object addWorker and removeWorker methods to make
+ * changes.
+ *
+ * This design allows different policy implementations to used this code to
+ * handle basic worker thread management and worker task execution and focus on
+ * policy issues. The simplest policy, StaticPolicy, does nothing other than
+ * create a fixed number of threads.
+ */
+class ThreadManager {
+
+ protected:
+  ThreadManager() {}
+
+ public:
+  virtual ~ThreadManager() {}
+
+  /**
+   * Starts the thread manager. Verifies all attributes have been properly
+   * initialized, then allocates necessary resources to begin operation
+   */
+  virtual void start() = 0;
+
+  /**
+   * Stops the thread manager. Aborts all remaining unprocessed task, shuts
+   * down all created worker threads, and realeases all allocated resources.
+   * This method blocks for all worker threads to complete, thus it can
+   * potentially block forever if a worker thread is running a task that
+   * won't terminate.
+   */
+  virtual void stop() = 0;
+
+  /**
+   * Joins the thread manager. This is the same as stop, except that it will
+   * block until all the workers have finished their work. At that point
+   * the ThreadManager will transition into the STOPPED state.
+   */
+  virtual void join() = 0;
+
+  enum STATE {
+    UNINITIALIZED,
+    STARTING,
+    STARTED,
+    JOINING,
+    STOPPING,
+    STOPPED
+  };
+
+  virtual const STATE state() const = 0;
+
+  virtual boost::shared_ptr<ThreadFactory> threadFactory() const = 0;
+
+  virtual void threadFactory(boost::shared_ptr<ThreadFactory> value) = 0;
+
+  virtual void addWorker(size_t value=1) = 0;
+
+  virtual void removeWorker(size_t value=1) = 0;
+
+  /**
+   * Gets the current number of idle worker threads
+   */
+  virtual size_t idleWorkerCount() const = 0;
+
+  /**
+   * Gets the current number of total worker threads
+   */
+  virtual size_t workerCount() const = 0;
+
+  /**
+   * Gets the current number of pending tasks
+   */
+  virtual size_t pendingTaskCount() const  = 0;
+
+  /**
+   * Gets the current number of pending and executing tasks
+   */
+  virtual size_t totalTaskCount() const = 0;
+
+  /**
+   * Gets the maximum pending task count.  0 indicates no maximum
+   */
+  virtual size_t pendingTaskCountMax() const = 0;
+
+  /**
+   * Adds a task to be executed at some time in the future by a worker thread.
+   *
+   * This method will block if pendingTaskCountMax() in not zero and pendingTaskCount()
+   * is greater than or equalt to pendingTaskCountMax().  If this method is called in the
+   * context of a ThreadManager worker thread it will throw a
+   * TooManyPendingTasksException
+   *
+   * @param task  The task to queue for execution
+   *
+   * @param timeout Time to wait in milliseconds to add a task when a pending-task-count
+   * is specified. Specific cases:
+   * timeout = 0  : Wait forever to queue task.
+   * timeout = -1 : Return immediately if pending task count exceeds specified max
+   *
+   * @throws TooManyPendingTasksException Pending task count exceeds max pending task count
+   */
+  virtual void add(boost::shared_ptr<Runnable>task, int64_t timeout=0LL) = 0;
+
+  /**
+   * Removes a pending task
+   */
+  virtual void remove(boost::shared_ptr<Runnable> task) = 0;
+
+  static boost::shared_ptr<ThreadManager> newThreadManager();
+
+  /**
+   * Creates a simple thread manager the uses count number of worker threads and has
+   * a pendingTaskCountMax maximum pending tasks. The default, 0, specified no limit
+   * on pending tasks
+   */
+  static boost::shared_ptr<ThreadManager> newSimpleThreadManager(size_t count=4, size_t pendingTaskCountMax=0);
+
+  class Task;
+
+  class Worker;
+
+  class Impl;
+};
+
+}}} // facebook::thrift::concurrency
+
+#endif // #ifndef _THRIFT_CONCURRENCY_THREADMANAGER_H_

+ 108 - 0
src/contrib/hive/metastore/include/thrift/concurrency/TimerManager.h

@@ -0,0 +1,108 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#ifndef _THRIFT_CONCURRENCY_TIMERMANAGER_H_
+#define _THRIFT_CONCURRENCY_TIMERMANAGER_H_ 1
+
+#include "Exception.h"
+#include "Monitor.h"
+#include "Thread.h"
+
+#include <boost/shared_ptr.hpp>
+#include <map>
+#include <time.h>
+
+namespace facebook { namespace thrift { namespace concurrency { 
+
+/**
+ * Timer Manager 
+ * 
+ * This class dispatches timer tasks when they fall due.
+ *  
+ * @author marc
+ * @version $Id:$
+ */
+class TimerManager {
+
+ public:
+
+  TimerManager();
+
+  virtual ~TimerManager();
+
+  virtual boost::shared_ptr<const ThreadFactory> threadFactory() const;
+
+  virtual void threadFactory(boost::shared_ptr<const ThreadFactory> value);
+
+  /**
+   * Starts the timer manager service 
+   *
+   * @throws IllegalArgumentException Missing thread factory attribute
+   */
+  virtual void start();
+
+  /**
+   * Stops the timer manager service
+   */
+  virtual void stop();
+
+  virtual size_t taskCount() const ;
+
+  /**
+   * Adds a task to be executed at some time in the future by a worker thread.
+   * 
+   * @param task The task to execute
+   * @param timeout Time in milliseconds to delay before executing task
+   */
+  virtual void add(boost::shared_ptr<Runnable> task, int64_t timeout);
+
+  /**
+   * Adds a task to be executed at some time in the future by a worker thread.
+   * 
+   * @param task The task to execute
+   * @param timeout Absolute time in the future to execute task.
+   */ 
+  virtual void add(boost::shared_ptr<Runnable> task, const struct timespec& timeout);
+
+  /**
+   * Removes a pending task 
+   *
+   * @throws NoSuchTaskException Specified task doesn't exist. It was either
+   *                             processed already or this call was made for a
+   *                             task that was never added to this timer
+   *
+   * @throws UncancellableTaskException Specified task is already being
+   *                                    executed or has completed execution.
+   */
+  virtual void remove(boost::shared_ptr<Runnable> task);
+
+  enum STATE {
+    UNINITIALIZED,
+    STARTING,
+    STARTED,
+    STOPPING,
+    STOPPED
+  };
+  
+  virtual const STATE state() const;
+
+ private:
+  boost::shared_ptr<const ThreadFactory> threadFactory_;
+  class Task;
+  friend class Task;
+  std::multimap<int64_t, boost::shared_ptr<Task> > taskMap_;
+  size_t taskCount_;
+  Monitor monitor_;
+  STATE state_;
+  class Dispatcher;
+  friend class Dispatcher;
+  boost::shared_ptr<Dispatcher> dispatcher_;
+  boost::shared_ptr<Thread> dispatcherThread_;
+};
+
+}}} // facebook::thrift::concurrency
+
+#endif // #ifndef _THRIFT_CONCURRENCY_TIMERMANAGER_H_

+ 91 - 0
src/contrib/hive/metastore/include/thrift/concurrency/Util.h

@@ -0,0 +1,91 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#ifndef _THRIFT_CONCURRENCY_UTIL_H_
+#define _THRIFT_CONCURRENCY_UTIL_H_ 1
+
+#include <config.h>
+
+#include <assert.h>
+#include <stddef.h>
+#if defined(HAVE_CLOCK_GETTIME)
+#include <time.h>
+#else // defined(HAVE_CLOCK_GETTIME)
+#include <sys/time.h>
+#endif // defined(HAVE_CLOCK_GETTIME)
+
+namespace facebook { namespace thrift { namespace concurrency { 
+
+/**
+ * Utility methods
+ *
+ * This class contains basic utility methods for converting time formats,
+ * and other common platform-dependent concurrency operations.
+ * It should not be included in API headers for other concurrency library
+ * headers, since it will, by definition, pull in all sorts of horrid
+ * platform dependent crap.  Rather it should be inluded directly in 
+ * concurrency library implementation source.
+ *
+ * @author marc
+ * @version $Id:$
+ */
+class Util {
+
+  static const int64_t NS_PER_S = 1000000000LL;
+  static const int64_t MS_PER_S = 1000LL;
+  static const int64_t NS_PER_MS = 1000000LL;
+
+ public:
+
+  /**
+   * Converts timespec to milliseconds
+   *
+   * @param struct timespec& result
+   * @param time or duration in milliseconds
+   */
+  static void toTimespec(struct timespec& result, int64_t value) {
+    result.tv_sec = value / MS_PER_S; // ms to s   
+    result.tv_nsec = (value % MS_PER_S) * NS_PER_MS; // ms to ns
+  }
+
+  /**
+   * Converts timespec to milliseconds
+   */
+  static const void toMilliseconds(int64_t& result, const struct timespec& value) {
+    result =
+      (value.tv_sec * MS_PER_S) +
+      (value.tv_nsec / NS_PER_MS) +
+      (value.tv_nsec % NS_PER_MS >= 500000 ? 1 : 0);
+  }
+
+  /**
+   * Get current time as milliseconds from epoch
+   */
+  static const int64_t currentTime() {
+#if defined(HAVE_CLOCK_GETTIME)
+    struct timespec now;
+    int ret = clock_gettime(CLOCK_REALTIME, &now);
+    assert(ret == 0);
+    return
+      (now.tv_sec * MS_PER_S) +
+      (now.tv_nsec / NS_PER_MS) +
+      (now.tv_nsec % NS_PER_MS >= 500000 ? 1 : 0) ;
+#elif defined(HAVE_GETTIMEOFDAY)
+    struct timeval now;
+    int ret = gettimeofday(&now, NULL);
+    assert(ret == 0);
+    return
+      (((int64_t)now.tv_sec) * MS_PER_S) +
+      (now.tv_usec / MS_PER_S) +
+      (now.tv_usec % MS_PER_S >= 500 ? 1 : 0);
+#endif // defined(HAVE_GETTIMEDAY)
+  }
+
+};
+
+}}} // facebook::thrift::concurrency
+
+#endif // #ifndef _THRIFT_CONCURRENCY_UTIL_H_

+ 260 - 0
src/contrib/hive/metastore/include/thrift/config.h

@@ -0,0 +1,260 @@
+/* config.h.  Generated by configure.  */
+/* config.hin.  Generated from configure.ac by autoheader.  */
+
+/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
+   systems. This function is required for `alloca.c' support on those systems.
+   */
+/* #undef CRAY_STACKSEG_END */
+
+/* Define to 1 if using `alloca.c'. */
+/* #undef C_ALLOCA */
+
+/* Define to 1 if you have `alloca', as a function or macro. */
+#define HAVE_ALLOCA 1
+
+/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
+   */
+#define HAVE_ALLOCA_H 1
+
+/* Define to 1 if you have the <arpa/inet.h> header file. */
+#define HAVE_ARPA_INET_H 1
+
+/* define if the Boost library is available */
+#define HAVE_BOOST 
+
+/* Define to 1 if you have the `bzero' function. */
+#define HAVE_BZERO 1
+
+/* Define to 1 if you have the `clock_gettime' function. */
+#define HAVE_CLOCK_GETTIME 1
+
+/* Define to 1 if you have the declaration of `strerror_r', and to 0 if you
+   don't. */
+#define HAVE_DECL_STRERROR_R 1
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
+/* #undef HAVE_DOPRNT */
+
+/* Define to 1 if you have the <endian.h> header file. */
+#define HAVE_ENDIAN_H 1
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define to 1 if you have the `gethostbyname' function. */
+#define HAVE_GETHOSTBYNAME 1
+
+/* Define to 1 if you have the `gettimeofday' function. */
+#define HAVE_GETTIMEOFDAY 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* define if libevent is available */
+#define HAVE_LIBEVENT 
+
+/* Define to 1 if you have the <libintl.h> header file. */
+#define HAVE_LIBINTL_H 1
+
+/* Define to 1 if you have the `pthread' library (-lpthread). */
+#define HAVE_LIBPTHREAD 1
+
+/* Define to 1 if you have the `rt' library (-lrt). */
+#define HAVE_LIBRT 1
+
+/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
+   to 0 otherwise. */
+#define HAVE_MALLOC 1
+
+/* Define to 1 if you have the <malloc.h> header file. */
+#define HAVE_MALLOC_H 1
+
+/* Define to 1 if you have the `memmove' function. */
+#define HAVE_MEMMOVE 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the `memset' function. */
+#define HAVE_MEMSET 1
+
+/* Define to 1 if you have the `mkdir' function. */
+#define HAVE_MKDIR 1
+
+/* Define to 1 if you have the <netdb.h> header file. */
+#define HAVE_NETDB_H 1
+
+/* Define to 1 if you have the <netinet/in.h> header file. */
+#define HAVE_NETINET_IN_H 1
+
+/* Define to 1 if you have the <pthread.h> header file. */
+#define HAVE_PTHREAD_H 1
+
+/* Define to 1 if your system has a GNU libc compatible `realloc' function,
+   and to 0 otherwise. */
+#define HAVE_REALLOC 1
+
+/* Define to 1 if you have the `realpath' function. */
+#define HAVE_REALPATH 1
+
+/* Define to 1 if you have the `select' function. */
+#define HAVE_SELECT 1
+
+/* Define to 1 if you have the `socket' function. */
+#define HAVE_SOCKET 1
+
+/* Define to 1 if you have the `sqrt' function. */
+#define HAVE_SQRT 1
+
+/* Define to 1 if `stat' has the bug that it succeeds when given the
+   zero-length file name argument. */
+/* #undef HAVE_STAT_EMPTY_STRING_BUG */
+
+/* Define to 1 if stdbool.h conforms to C99. */
+#define HAVE_STDBOOL_H 1
+
+/* Define to 1 if you have the <stddef.h> header file. */
+#define HAVE_STDDEF_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the `strchr' function. */
+#define HAVE_STRCHR 1
+
+/* Define to 1 if you have the `strdup' function. */
+#define HAVE_STRDUP 1
+
+/* Define to 1 if you have the `strerror_r' function. */
+#define HAVE_STRERROR_R 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the `strstr' function. */
+#define HAVE_STRSTR 1
+
+/* Define to 1 if you have the `strtol' function. */
+#define HAVE_STRTOL 1
+
+/* Define to 1 if you have the `strtoul' function. */
+#define HAVE_STRTOUL 1
+
+/* Define to 1 if you have the <sys/select.h> header file. */
+#define HAVE_SYS_SELECT_H 1
+
+/* Define to 1 if you have the <sys/socket.h> header file. */
+#define HAVE_SYS_SOCKET_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#define HAVE_SYS_TIME_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to 1 if you have the `vprintf' function. */
+#define HAVE_VPRINTF 1
+
+/* define if zlib is available */
+/* #undef HAVE_ZLIB */
+
+/* Define to 1 if the system has the type `_Bool'. */
+/* #undef HAVE__BOOL */
+
+/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
+   slash. */
+#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1
+
+/* Name of package */
+#define PACKAGE "thrift"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT ""
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "thrift"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "thrift 20070917"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "thrift"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "20070917"
+
+/* Define to the type of arg 1 for `select'. */
+#define SELECT_TYPE_ARG1 int
+
+/* Define to the type of args 2, 3 and 4 for `select'. */
+#define SELECT_TYPE_ARG234 (fd_set *)
+
+/* Define to the type of arg 5 for `select'. */
+#define SELECT_TYPE_ARG5 (struct timeval *)
+
+/* If using the C implementation of alloca, define if you know the
+   direction of stack growth for your system; otherwise it will be
+   automatically deduced at run-time.
+	STACK_DIRECTION > 0 => grows toward higher addresses
+	STACK_DIRECTION < 0 => grows toward lower addresses
+	STACK_DIRECTION = 0 => direction of growth unknown */
+/* #undef STACK_DIRECTION */
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define to 1 if strerror_r returns char *. */
+#define STRERROR_R_CHAR_P 1
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#define TIME_WITH_SYS_TIME 1
+
+/* Version number of package */
+#define VERSION "20070917"
+
+/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
+   `char[]'. */
+#define YYTEXT_POINTER 1
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef const */
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+   calls it, or to nothing if 'inline' is not supported under any name.  */
+#ifndef __cplusplus
+/* #undef inline */
+#endif
+
+/* Define to rpl_malloc if the replacement function should be used. */
+/* #undef malloc */
+
+/* Define to `int' if <sys/types.h> does not define. */
+/* #undef mode_t */
+
+/* Define to `long' if <sys/types.h> does not define. */
+/* #undef off_t */
+
+/* Define to rpl_realloc if the replacement function should be used. */
+/* #undef realloc */
+
+/* Define to `unsigned' if <sys/types.h> does not define. */
+/* #undef size_t */
+
+/* Define to empty if the keyword `volatile' does not work. Warning: valid
+   code using `volatile' can become incorrect without. Disable with care. */
+/* #undef volatile */

+ 96 - 0
src/contrib/hive/metastore/include/thrift/fb303/FacebookBase.h

@@ -0,0 +1,96 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#ifndef _FACEBOOK_TB303_FACEBOOKBASE_H_
+#define _FACEBOOK_TB303_FACEBOOKBASE_H_ 1
+
+#include "FacebookService.h"
+
+#include "thrift/server/TServer.h"
+#include "thrift/concurrency/Mutex.h"
+
+#include <time.h>
+#include <string>
+#include <map>
+
+namespace facebook { namespace fb303 {
+
+using facebook::thrift::concurrency::Mutex;
+using facebook::thrift::concurrency::ReadWriteMutex;
+using facebook::thrift::server::TServer;
+
+struct ReadWriteInt : ReadWriteMutex {int64_t value;};
+struct ReadWriteCounterMap : ReadWriteMutex,
+                             std::map<std::string, ReadWriteInt> {};
+
+typedef void (*get_static_limref_ptr)(facebook::thrift::reflection::limited::Service &);
+
+/**
+ * Base Facebook service implementation in C++.
+ *
+ * @author Mark Slee <mcslee@facebook.com>
+ */
+class FacebookBase : virtual public FacebookServiceIf {
+ protected:
+  FacebookBase(std::string name, get_static_limref_ptr reflect_lim = NULL);
+  virtual ~FacebookBase() {}
+
+ public:
+  void getName(std::string& _return);
+  virtual void getVersion(std::string& _return) { _return = ""; }
+
+  virtual fb_status getStatus() = 0;
+  virtual void getStatusDetails(std::string& _return) { _return = ""; }
+
+  void setOption(const std::string& key, const std::string& value);
+  void getOption(std::string& _return, const std::string& key);
+  void getOptions(std::map<std::string, std::string> & _return);
+
+  int64_t aliveSince();
+
+  void getLimitedReflection(facebook::thrift::reflection::limited::Service& _return) {
+    _return = reflection_limited_;
+  }
+
+  virtual void reinitialize() {}
+
+  virtual void shutdown() {
+    if (server_.get() != NULL) {
+      server_->stop();
+    }
+  }
+
+  int64_t incrementCounter(const std::string& key, int64_t amount = 1);
+  int64_t setCounter(const std::string& key, int64_t value);
+
+  void getCounters(std::map<std::string, int64_t>& _return);
+  int64_t getCounter(const std::string& key);
+
+  /**
+   * Set server handle for shutdown method
+   */
+  void setServer(boost::shared_ptr<TServer> server) {
+    server_ = server;
+  }
+
+ private:
+
+  std::string name_;
+  facebook::thrift::reflection::limited::Service reflection_limited_;
+  int64_t aliveSince_;
+
+  std::map<std::string, std::string> options_;
+  Mutex optionsLock_;
+
+  ReadWriteCounterMap counters_;
+
+  boost::shared_ptr<TServer> server_;
+
+};
+
+}} // facebook::tb303
+
+#endif // _FACEBOOK_TB303_FACEBOOKBASE_H_

+ 1583 - 0
src/contrib/hive/metastore/include/thrift/fb303/FacebookService.h

@@ -0,0 +1,1583 @@
+/**
+ * Autogenerated by Thrift
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ */
+#ifndef FacebookService_H
+#define FacebookService_H
+
+#include <TProcessor.h>
+#include "fb303_types.h"
+
+namespace facebook { namespace fb303 {
+
+class FacebookServiceIf {
+ public:
+  virtual ~FacebookServiceIf() {}
+  virtual void getName(std::string& _return) = 0;
+  virtual void getVersion(std::string& _return) = 0;
+  virtual fb_status getStatus() = 0;
+  virtual void getStatusDetails(std::string& _return) = 0;
+  virtual void getCounters(std::map<std::string, int64_t> & _return) = 0;
+  virtual int64_t getCounter(const std::string& key) = 0;
+  virtual void setOption(const std::string& key, const std::string& value) = 0;
+  virtual void getOption(std::string& _return, const std::string& key) = 0;
+  virtual void getOptions(std::map<std::string, std::string> & _return) = 0;
+  virtual int64_t aliveSince() = 0;
+  virtual void getLimitedReflection(facebook::thrift::reflection::limited::Service& _return) = 0;
+  virtual void reinitialize() = 0;
+  virtual void shutdown() = 0;
+  virtual void getSingleTimeseries(std::map<int64_t, double> & _return, const std::string& name, const int32_t series_length) = 0;
+  virtual void getTimeseries(std::map<std::string, std::map<int64_t, double> > & _return, const int32_t series_length) = 0;
+};
+
+class FacebookServiceNull : virtual public FacebookServiceIf {
+ public:
+  virtual ~FacebookServiceNull() {}
+  void getName(std::string& /* _return */) {
+    return;
+  }
+  void getVersion(std::string& /* _return */) {
+    return;
+  }
+  fb_status getStatus() {
+    fb_status _return = (fb_status)0;
+    return _return;
+  }
+  void getStatusDetails(std::string& /* _return */) {
+    return;
+  }
+  void getCounters(std::map<std::string, int64_t> & /* _return */) {
+    return;
+  }
+  int64_t getCounter(const std::string& /* key */) {
+    int64_t _return = 0;
+    return _return;
+  }
+  void setOption(const std::string& /* key */, const std::string& /* value */) {
+    return;
+  }
+  void getOption(std::string& /* _return */, const std::string& /* key */) {
+    return;
+  }
+  void getOptions(std::map<std::string, std::string> & /* _return */) {
+    return;
+  }
+  int64_t aliveSince() {
+    int64_t _return = 0;
+    return _return;
+  }
+  void getLimitedReflection(facebook::thrift::reflection::limited::Service& /* _return */) {
+    return;
+  }
+  void reinitialize() {
+    return;
+  }
+  void shutdown() {
+    return;
+  }
+  void getSingleTimeseries(std::map<int64_t, double> & /* _return */, const std::string& /* name */, const int32_t /* series_length */) {
+    return;
+  }
+  void getTimeseries(std::map<std::string, std::map<int64_t, double> > & /* _return */, const int32_t /* series_length */) {
+    return;
+  }
+};
+
+class FacebookService_getName_args {
+ public:
+
+  FacebookService_getName_args() {
+  }
+
+  virtual ~FacebookService_getName_args() throw() {}
+
+
+  bool operator == (const FacebookService_getName_args & /* rhs */) const
+  {
+    return true;
+  }
+  bool operator != (const FacebookService_getName_args &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator < (const FacebookService_getName_args & ) const;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getName_pargs {
+ public:
+
+
+  virtual ~FacebookService_getName_pargs() throw() {}
+
+
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getName_result {
+ public:
+
+  FacebookService_getName_result() : success("") {
+  }
+
+  virtual ~FacebookService_getName_result() throw() {}
+
+  std::string success;
+
+  struct __isset {
+    __isset() : success(false) {}
+    bool success;
+  } __isset;
+
+  bool operator == (const FacebookService_getName_result & rhs) const
+  {
+    if (!(success == rhs.success))
+      return false;
+    return true;
+  }
+  bool operator != (const FacebookService_getName_result &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator < (const FacebookService_getName_result & ) const;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getName_presult {
+ public:
+
+
+  virtual ~FacebookService_getName_presult() throw() {}
+
+  std::string* success;
+
+  struct __isset {
+    __isset() : success(false) {}
+    bool success;
+  } __isset;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+
+};
+
+class FacebookService_getVersion_args {
+ public:
+
+  FacebookService_getVersion_args() {
+  }
+
+  virtual ~FacebookService_getVersion_args() throw() {}
+
+
+  bool operator == (const FacebookService_getVersion_args & /* rhs */) const
+  {
+    return true;
+  }
+  bool operator != (const FacebookService_getVersion_args &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator < (const FacebookService_getVersion_args & ) const;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getVersion_pargs {
+ public:
+
+
+  virtual ~FacebookService_getVersion_pargs() throw() {}
+
+
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getVersion_result {
+ public:
+
+  FacebookService_getVersion_result() : success("") {
+  }
+
+  virtual ~FacebookService_getVersion_result() throw() {}
+
+  std::string success;
+
+  struct __isset {
+    __isset() : success(false) {}
+    bool success;
+  } __isset;
+
+  bool operator == (const FacebookService_getVersion_result & rhs) const
+  {
+    if (!(success == rhs.success))
+      return false;
+    return true;
+  }
+  bool operator != (const FacebookService_getVersion_result &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator < (const FacebookService_getVersion_result & ) const;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getVersion_presult {
+ public:
+
+
+  virtual ~FacebookService_getVersion_presult() throw() {}
+
+  std::string* success;
+
+  struct __isset {
+    __isset() : success(false) {}
+    bool success;
+  } __isset;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+
+};
+
+class FacebookService_getStatus_args {
+ public:
+
+  FacebookService_getStatus_args() {
+  }
+
+  virtual ~FacebookService_getStatus_args() throw() {}
+
+
+  bool operator == (const FacebookService_getStatus_args & /* rhs */) const
+  {
+    return true;
+  }
+  bool operator != (const FacebookService_getStatus_args &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator < (const FacebookService_getStatus_args & ) const;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getStatus_pargs {
+ public:
+
+
+  virtual ~FacebookService_getStatus_pargs() throw() {}
+
+
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getStatus_result {
+ public:
+
+  FacebookService_getStatus_result() {
+  }
+
+  virtual ~FacebookService_getStatus_result() throw() {}
+
+  fb_status success;
+
+  struct __isset {
+    __isset() : success(false) {}
+    bool success;
+  } __isset;
+
+  bool operator == (const FacebookService_getStatus_result & rhs) const
+  {
+    if (!(success == rhs.success))
+      return false;
+    return true;
+  }
+  bool operator != (const FacebookService_getStatus_result &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator < (const FacebookService_getStatus_result & ) const;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getStatus_presult {
+ public:
+
+
+  virtual ~FacebookService_getStatus_presult() throw() {}
+
+  fb_status* success;
+
+  struct __isset {
+    __isset() : success(false) {}
+    bool success;
+  } __isset;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+
+};
+
+class FacebookService_getStatusDetails_args {
+ public:
+
+  FacebookService_getStatusDetails_args() {
+  }
+
+  virtual ~FacebookService_getStatusDetails_args() throw() {}
+
+
+  bool operator == (const FacebookService_getStatusDetails_args & /* rhs */) const
+  {
+    return true;
+  }
+  bool operator != (const FacebookService_getStatusDetails_args &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator < (const FacebookService_getStatusDetails_args & ) const;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getStatusDetails_pargs {
+ public:
+
+
+  virtual ~FacebookService_getStatusDetails_pargs() throw() {}
+
+
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getStatusDetails_result {
+ public:
+
+  FacebookService_getStatusDetails_result() : success("") {
+  }
+
+  virtual ~FacebookService_getStatusDetails_result() throw() {}
+
+  std::string success;
+
+  struct __isset {
+    __isset() : success(false) {}
+    bool success;
+  } __isset;
+
+  bool operator == (const FacebookService_getStatusDetails_result & rhs) const
+  {
+    if (!(success == rhs.success))
+      return false;
+    return true;
+  }
+  bool operator != (const FacebookService_getStatusDetails_result &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator < (const FacebookService_getStatusDetails_result & ) const;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getStatusDetails_presult {
+ public:
+
+
+  virtual ~FacebookService_getStatusDetails_presult() throw() {}
+
+  std::string* success;
+
+  struct __isset {
+    __isset() : success(false) {}
+    bool success;
+  } __isset;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+
+};
+
+class FacebookService_getCounters_args {
+ public:
+
+  FacebookService_getCounters_args() {
+  }
+
+  virtual ~FacebookService_getCounters_args() throw() {}
+
+
+  bool operator == (const FacebookService_getCounters_args & /* rhs */) const
+  {
+    return true;
+  }
+  bool operator != (const FacebookService_getCounters_args &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator < (const FacebookService_getCounters_args & ) const;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getCounters_pargs {
+ public:
+
+
+  virtual ~FacebookService_getCounters_pargs() throw() {}
+
+
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getCounters_result {
+ public:
+
+  FacebookService_getCounters_result() {
+  }
+
+  virtual ~FacebookService_getCounters_result() throw() {}
+
+  std::map<std::string, int64_t>  success;
+
+  struct __isset {
+    __isset() : success(false) {}
+    bool success;
+  } __isset;
+
+  bool operator == (const FacebookService_getCounters_result & rhs) const
+  {
+    if (!(success == rhs.success))
+      return false;
+    return true;
+  }
+  bool operator != (const FacebookService_getCounters_result &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator < (const FacebookService_getCounters_result & ) const;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getCounters_presult {
+ public:
+
+
+  virtual ~FacebookService_getCounters_presult() throw() {}
+
+  std::map<std::string, int64_t> * success;
+
+  struct __isset {
+    __isset() : success(false) {}
+    bool success;
+  } __isset;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+
+};
+
+class FacebookService_getCounter_args {
+ public:
+
+  FacebookService_getCounter_args() : key("") {
+  }
+
+  virtual ~FacebookService_getCounter_args() throw() {}
+
+  std::string key;
+
+  struct __isset {
+    __isset() : key(false) {}
+    bool key;
+  } __isset;
+
+  bool operator == (const FacebookService_getCounter_args & rhs) const
+  {
+    if (!(key == rhs.key))
+      return false;
+    return true;
+  }
+  bool operator != (const FacebookService_getCounter_args &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator < (const FacebookService_getCounter_args & ) const;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getCounter_pargs {
+ public:
+
+
+  virtual ~FacebookService_getCounter_pargs() throw() {}
+
+  const std::string* key;
+
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getCounter_result {
+ public:
+
+  FacebookService_getCounter_result() : success(0) {
+  }
+
+  virtual ~FacebookService_getCounter_result() throw() {}
+
+  int64_t success;
+
+  struct __isset {
+    __isset() : success(false) {}
+    bool success;
+  } __isset;
+
+  bool operator == (const FacebookService_getCounter_result & rhs) const
+  {
+    if (!(success == rhs.success))
+      return false;
+    return true;
+  }
+  bool operator != (const FacebookService_getCounter_result &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator < (const FacebookService_getCounter_result & ) const;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getCounter_presult {
+ public:
+
+
+  virtual ~FacebookService_getCounter_presult() throw() {}
+
+  int64_t* success;
+
+  struct __isset {
+    __isset() : success(false) {}
+    bool success;
+  } __isset;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+
+};
+
+class FacebookService_setOption_args {
+ public:
+
+  FacebookService_setOption_args() : key(""), value("") {
+  }
+
+  virtual ~FacebookService_setOption_args() throw() {}
+
+  std::string key;
+  std::string value;
+
+  struct __isset {
+    __isset() : key(false), value(false) {}
+    bool key;
+    bool value;
+  } __isset;
+
+  bool operator == (const FacebookService_setOption_args & rhs) const
+  {
+    if (!(key == rhs.key))
+      return false;
+    if (!(value == rhs.value))
+      return false;
+    return true;
+  }
+  bool operator != (const FacebookService_setOption_args &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator < (const FacebookService_setOption_args & ) const;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_setOption_pargs {
+ public:
+
+
+  virtual ~FacebookService_setOption_pargs() throw() {}
+
+  const std::string* key;
+  const std::string* value;
+
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_setOption_result {
+ public:
+
+  FacebookService_setOption_result() {
+  }
+
+  virtual ~FacebookService_setOption_result() throw() {}
+
+
+  bool operator == (const FacebookService_setOption_result & /* rhs */) const
+  {
+    return true;
+  }
+  bool operator != (const FacebookService_setOption_result &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator < (const FacebookService_setOption_result & ) const;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_setOption_presult {
+ public:
+
+
+  virtual ~FacebookService_setOption_presult() throw() {}
+
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+
+};
+
+class FacebookService_getOption_args {
+ public:
+
+  FacebookService_getOption_args() : key("") {
+  }
+
+  virtual ~FacebookService_getOption_args() throw() {}
+
+  std::string key;
+
+  struct __isset {
+    __isset() : key(false) {}
+    bool key;
+  } __isset;
+
+  bool operator == (const FacebookService_getOption_args & rhs) const
+  {
+    if (!(key == rhs.key))
+      return false;
+    return true;
+  }
+  bool operator != (const FacebookService_getOption_args &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator < (const FacebookService_getOption_args & ) const;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getOption_pargs {
+ public:
+
+
+  virtual ~FacebookService_getOption_pargs() throw() {}
+
+  const std::string* key;
+
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getOption_result {
+ public:
+
+  FacebookService_getOption_result() : success("") {
+  }
+
+  virtual ~FacebookService_getOption_result() throw() {}
+
+  std::string success;
+
+  struct __isset {
+    __isset() : success(false) {}
+    bool success;
+  } __isset;
+
+  bool operator == (const FacebookService_getOption_result & rhs) const
+  {
+    if (!(success == rhs.success))
+      return false;
+    return true;
+  }
+  bool operator != (const FacebookService_getOption_result &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator < (const FacebookService_getOption_result & ) const;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getOption_presult {
+ public:
+
+
+  virtual ~FacebookService_getOption_presult() throw() {}
+
+  std::string* success;
+
+  struct __isset {
+    __isset() : success(false) {}
+    bool success;
+  } __isset;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+
+};
+
+class FacebookService_getOptions_args {
+ public:
+
+  FacebookService_getOptions_args() {
+  }
+
+  virtual ~FacebookService_getOptions_args() throw() {}
+
+
+  bool operator == (const FacebookService_getOptions_args & /* rhs */) const
+  {
+    return true;
+  }
+  bool operator != (const FacebookService_getOptions_args &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator < (const FacebookService_getOptions_args & ) const;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getOptions_pargs {
+ public:
+
+
+  virtual ~FacebookService_getOptions_pargs() throw() {}
+
+
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getOptions_result {
+ public:
+
+  FacebookService_getOptions_result() {
+  }
+
+  virtual ~FacebookService_getOptions_result() throw() {}
+
+  std::map<std::string, std::string>  success;
+
+  struct __isset {
+    __isset() : success(false) {}
+    bool success;
+  } __isset;
+
+  bool operator == (const FacebookService_getOptions_result & rhs) const
+  {
+    if (!(success == rhs.success))
+      return false;
+    return true;
+  }
+  bool operator != (const FacebookService_getOptions_result &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator < (const FacebookService_getOptions_result & ) const;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getOptions_presult {
+ public:
+
+
+  virtual ~FacebookService_getOptions_presult() throw() {}
+
+  std::map<std::string, std::string> * success;
+
+  struct __isset {
+    __isset() : success(false) {}
+    bool success;
+  } __isset;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+
+};
+
+class FacebookService_aliveSince_args {
+ public:
+
+  FacebookService_aliveSince_args() {
+  }
+
+  virtual ~FacebookService_aliveSince_args() throw() {}
+
+
+  bool operator == (const FacebookService_aliveSince_args & /* rhs */) const
+  {
+    return true;
+  }
+  bool operator != (const FacebookService_aliveSince_args &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator < (const FacebookService_aliveSince_args & ) const;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_aliveSince_pargs {
+ public:
+
+
+  virtual ~FacebookService_aliveSince_pargs() throw() {}
+
+
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_aliveSince_result {
+ public:
+
+  FacebookService_aliveSince_result() : success(0) {
+  }
+
+  virtual ~FacebookService_aliveSince_result() throw() {}
+
+  int64_t success;
+
+  struct __isset {
+    __isset() : success(false) {}
+    bool success;
+  } __isset;
+
+  bool operator == (const FacebookService_aliveSince_result & rhs) const
+  {
+    if (!(success == rhs.success))
+      return false;
+    return true;
+  }
+  bool operator != (const FacebookService_aliveSince_result &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator < (const FacebookService_aliveSince_result & ) const;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_aliveSince_presult {
+ public:
+
+
+  virtual ~FacebookService_aliveSince_presult() throw() {}
+
+  int64_t* success;
+
+  struct __isset {
+    __isset() : success(false) {}
+    bool success;
+  } __isset;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+
+};
+
+class FacebookService_getLimitedReflection_args {
+ public:
+
+  FacebookService_getLimitedReflection_args() {
+  }
+
+  virtual ~FacebookService_getLimitedReflection_args() throw() {}
+
+
+  bool operator == (const FacebookService_getLimitedReflection_args & /* rhs */) const
+  {
+    return true;
+  }
+  bool operator != (const FacebookService_getLimitedReflection_args &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator < (const FacebookService_getLimitedReflection_args & ) const;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getLimitedReflection_pargs {
+ public:
+
+
+  virtual ~FacebookService_getLimitedReflection_pargs() throw() {}
+
+
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getLimitedReflection_result {
+ public:
+
+  FacebookService_getLimitedReflection_result() {
+  }
+
+  virtual ~FacebookService_getLimitedReflection_result() throw() {}
+
+  facebook::thrift::reflection::limited::Service success;
+
+  struct __isset {
+    __isset() : success(false) {}
+    bool success;
+  } __isset;
+
+  bool operator == (const FacebookService_getLimitedReflection_result & rhs) const
+  {
+    if (!(success == rhs.success))
+      return false;
+    return true;
+  }
+  bool operator != (const FacebookService_getLimitedReflection_result &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator < (const FacebookService_getLimitedReflection_result & ) const;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getLimitedReflection_presult {
+ public:
+
+
+  virtual ~FacebookService_getLimitedReflection_presult() throw() {}
+
+  facebook::thrift::reflection::limited::Service* success;
+
+  struct __isset {
+    __isset() : success(false) {}
+    bool success;
+  } __isset;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+
+};
+
+class FacebookService_reinitialize_args {
+ public:
+
+  FacebookService_reinitialize_args() {
+  }
+
+  virtual ~FacebookService_reinitialize_args() throw() {}
+
+
+  bool operator == (const FacebookService_reinitialize_args & /* rhs */) const
+  {
+    return true;
+  }
+  bool operator != (const FacebookService_reinitialize_args &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator < (const FacebookService_reinitialize_args & ) const;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_reinitialize_pargs {
+ public:
+
+
+  virtual ~FacebookService_reinitialize_pargs() throw() {}
+
+
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_shutdown_args {
+ public:
+
+  FacebookService_shutdown_args() {
+  }
+
+  virtual ~FacebookService_shutdown_args() throw() {}
+
+
+  bool operator == (const FacebookService_shutdown_args & /* rhs */) const
+  {
+    return true;
+  }
+  bool operator != (const FacebookService_shutdown_args &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator < (const FacebookService_shutdown_args & ) const;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_shutdown_pargs {
+ public:
+
+
+  virtual ~FacebookService_shutdown_pargs() throw() {}
+
+
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getSingleTimeseries_args {
+ public:
+
+  FacebookService_getSingleTimeseries_args() : name(""), series_length(0) {
+  }
+
+  virtual ~FacebookService_getSingleTimeseries_args() throw() {}
+
+  std::string name;
+  int32_t series_length;
+
+  struct __isset {
+    __isset() : name(false), series_length(false) {}
+    bool name;
+    bool series_length;
+  } __isset;
+
+  bool operator == (const FacebookService_getSingleTimeseries_args & rhs) const
+  {
+    if (!(name == rhs.name))
+      return false;
+    if (!(series_length == rhs.series_length))
+      return false;
+    return true;
+  }
+  bool operator != (const FacebookService_getSingleTimeseries_args &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator < (const FacebookService_getSingleTimeseries_args & ) const;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getSingleTimeseries_pargs {
+ public:
+
+
+  virtual ~FacebookService_getSingleTimeseries_pargs() throw() {}
+
+  const std::string* name;
+  const int32_t* series_length;
+
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getSingleTimeseries_result {
+ public:
+
+  FacebookService_getSingleTimeseries_result() {
+  }
+
+  virtual ~FacebookService_getSingleTimeseries_result() throw() {}
+
+  std::map<int64_t, double>  success;
+
+  struct __isset {
+    __isset() : success(false) {}
+    bool success;
+  } __isset;
+
+  bool operator == (const FacebookService_getSingleTimeseries_result & rhs) const
+  {
+    if (!(success == rhs.success))
+      return false;
+    return true;
+  }
+  bool operator != (const FacebookService_getSingleTimeseries_result &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator < (const FacebookService_getSingleTimeseries_result & ) const;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getSingleTimeseries_presult {
+ public:
+
+
+  virtual ~FacebookService_getSingleTimeseries_presult() throw() {}
+
+  std::map<int64_t, double> * success;
+
+  struct __isset {
+    __isset() : success(false) {}
+    bool success;
+  } __isset;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+
+};
+
+class FacebookService_getTimeseries_args {
+ public:
+
+  FacebookService_getTimeseries_args() : series_length(0) {
+  }
+
+  virtual ~FacebookService_getTimeseries_args() throw() {}
+
+  int32_t series_length;
+
+  struct __isset {
+    __isset() : series_length(false) {}
+    bool series_length;
+  } __isset;
+
+  bool operator == (const FacebookService_getTimeseries_args & rhs) const
+  {
+    if (!(series_length == rhs.series_length))
+      return false;
+    return true;
+  }
+  bool operator != (const FacebookService_getTimeseries_args &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator < (const FacebookService_getTimeseries_args & ) const;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getTimeseries_pargs {
+ public:
+
+
+  virtual ~FacebookService_getTimeseries_pargs() throw() {}
+
+  const int32_t* series_length;
+
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getTimeseries_result {
+ public:
+
+  FacebookService_getTimeseries_result() {
+  }
+
+  virtual ~FacebookService_getTimeseries_result() throw() {}
+
+  std::map<std::string, std::map<int64_t, double> >  success;
+
+  struct __isset {
+    __isset() : success(false) {}
+    bool success;
+  } __isset;
+
+  bool operator == (const FacebookService_getTimeseries_result & rhs) const
+  {
+    if (!(success == rhs.success))
+      return false;
+    return true;
+  }
+  bool operator != (const FacebookService_getTimeseries_result &rhs) const {
+    return !(*this == rhs);
+  }
+
+  bool operator < (const FacebookService_getTimeseries_result & ) const;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class FacebookService_getTimeseries_presult {
+ public:
+
+
+  virtual ~FacebookService_getTimeseries_presult() throw() {}
+
+  std::map<std::string, std::map<int64_t, double> > * success;
+
+  struct __isset {
+    __isset() : success(false) {}
+    bool success;
+  } __isset;
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+
+};
+
+class FacebookServiceClient : virtual public FacebookServiceIf {
+ public:
+  FacebookServiceClient(boost::shared_ptr<facebook::thrift::protocol::TProtocol> prot) :
+    piprot_(prot),
+    poprot_(prot) {
+    iprot_ = prot.get();
+    oprot_ = prot.get();
+  }
+  FacebookServiceClient(boost::shared_ptr<facebook::thrift::protocol::TProtocol> iprot, boost::shared_ptr<facebook::thrift::protocol::TProtocol> oprot) :
+    piprot_(iprot),
+    poprot_(oprot) {
+    iprot_ = iprot.get();
+    oprot_ = oprot.get();
+  }
+  boost::shared_ptr<facebook::thrift::protocol::TProtocol> getInputProtocol() {
+    return piprot_;
+  }
+  boost::shared_ptr<facebook::thrift::protocol::TProtocol> getOutputProtocol() {
+    return poprot_;
+  }
+  void getName(std::string& _return);
+  void send_getName();
+  void recv_getName(std::string& _return);
+  void getVersion(std::string& _return);
+  void send_getVersion();
+  void recv_getVersion(std::string& _return);
+  fb_status getStatus();
+  void send_getStatus();
+  fb_status recv_getStatus();
+  void getStatusDetails(std::string& _return);
+  void send_getStatusDetails();
+  void recv_getStatusDetails(std::string& _return);
+  void getCounters(std::map<std::string, int64_t> & _return);
+  void send_getCounters();
+  void recv_getCounters(std::map<std::string, int64_t> & _return);
+  int64_t getCounter(const std::string& key);
+  void send_getCounter(const std::string& key);
+  int64_t recv_getCounter();
+  void setOption(const std::string& key, const std::string& value);
+  void send_setOption(const std::string& key, const std::string& value);
+  void recv_setOption();
+  void getOption(std::string& _return, const std::string& key);
+  void send_getOption(const std::string& key);
+  void recv_getOption(std::string& _return);
+  void getOptions(std::map<std::string, std::string> & _return);
+  void send_getOptions();
+  void recv_getOptions(std::map<std::string, std::string> & _return);
+  int64_t aliveSince();
+  void send_aliveSince();
+  int64_t recv_aliveSince();
+  void getLimitedReflection(facebook::thrift::reflection::limited::Service& _return);
+  void send_getLimitedReflection();
+  void recv_getLimitedReflection(facebook::thrift::reflection::limited::Service& _return);
+  void reinitialize();
+  void send_reinitialize();
+  void shutdown();
+  void send_shutdown();
+  void getSingleTimeseries(std::map<int64_t, double> & _return, const std::string& name, const int32_t series_length);
+  void send_getSingleTimeseries(const std::string& name, const int32_t series_length);
+  void recv_getSingleTimeseries(std::map<int64_t, double> & _return);
+  void getTimeseries(std::map<std::string, std::map<int64_t, double> > & _return, const int32_t series_length);
+  void send_getTimeseries(const int32_t series_length);
+  void recv_getTimeseries(std::map<std::string, std::map<int64_t, double> > & _return);
+ protected:
+  boost::shared_ptr<facebook::thrift::protocol::TProtocol> piprot_;
+  boost::shared_ptr<facebook::thrift::protocol::TProtocol> poprot_;
+  facebook::thrift::protocol::TProtocol* iprot_;
+  facebook::thrift::protocol::TProtocol* oprot_;
+};
+
+class FacebookServiceProcessor : virtual public facebook::thrift::TProcessor {
+ protected:
+  boost::shared_ptr<FacebookServiceIf> iface_;
+  virtual bool process_fn(facebook::thrift::protocol::TProtocol* iprot, facebook::thrift::protocol::TProtocol* oprot, std::string& fname, int32_t seqid);
+ private:
+  std::map<std::string, void (FacebookServiceProcessor::*)(int32_t, facebook::thrift::protocol::TProtocol*, facebook::thrift::protocol::TProtocol*)> processMap_;
+  void process_getName(int32_t seqid, facebook::thrift::protocol::TProtocol* iprot, facebook::thrift::protocol::TProtocol* oprot);
+  void process_getVersion(int32_t seqid, facebook::thrift::protocol::TProtocol* iprot, facebook::thrift::protocol::TProtocol* oprot);
+  void process_getStatus(int32_t seqid, facebook::thrift::protocol::TProtocol* iprot, facebook::thrift::protocol::TProtocol* oprot);
+  void process_getStatusDetails(int32_t seqid, facebook::thrift::protocol::TProtocol* iprot, facebook::thrift::protocol::TProtocol* oprot);
+  void process_getCounters(int32_t seqid, facebook::thrift::protocol::TProtocol* iprot, facebook::thrift::protocol::TProtocol* oprot);
+  void process_getCounter(int32_t seqid, facebook::thrift::protocol::TProtocol* iprot, facebook::thrift::protocol::TProtocol* oprot);
+  void process_setOption(int32_t seqid, facebook::thrift::protocol::TProtocol* iprot, facebook::thrift::protocol::TProtocol* oprot);
+  void process_getOption(int32_t seqid, facebook::thrift::protocol::TProtocol* iprot, facebook::thrift::protocol::TProtocol* oprot);
+  void process_getOptions(int32_t seqid, facebook::thrift::protocol::TProtocol* iprot, facebook::thrift::protocol::TProtocol* oprot);
+  void process_aliveSince(int32_t seqid, facebook::thrift::protocol::TProtocol* iprot, facebook::thrift::protocol::TProtocol* oprot);
+  void process_getLimitedReflection(int32_t seqid, facebook::thrift::protocol::TProtocol* iprot, facebook::thrift::protocol::TProtocol* oprot);
+  void process_reinitialize(int32_t seqid, facebook::thrift::protocol::TProtocol* iprot, facebook::thrift::protocol::TProtocol* oprot);
+  void process_shutdown(int32_t seqid, facebook::thrift::protocol::TProtocol* iprot, facebook::thrift::protocol::TProtocol* oprot);
+  void process_getSingleTimeseries(int32_t seqid, facebook::thrift::protocol::TProtocol* iprot, facebook::thrift::protocol::TProtocol* oprot);
+  void process_getTimeseries(int32_t seqid, facebook::thrift::protocol::TProtocol* iprot, facebook::thrift::protocol::TProtocol* oprot);
+ public:
+  FacebookServiceProcessor(boost::shared_ptr<FacebookServiceIf> iface) :
+    iface_(iface) {
+    processMap_["getName"] = &FacebookServiceProcessor::process_getName;
+    processMap_["getVersion"] = &FacebookServiceProcessor::process_getVersion;
+    processMap_["getStatus"] = &FacebookServiceProcessor::process_getStatus;
+    processMap_["getStatusDetails"] = &FacebookServiceProcessor::process_getStatusDetails;
+    processMap_["getCounters"] = &FacebookServiceProcessor::process_getCounters;
+    processMap_["getCounter"] = &FacebookServiceProcessor::process_getCounter;
+    processMap_["setOption"] = &FacebookServiceProcessor::process_setOption;
+    processMap_["getOption"] = &FacebookServiceProcessor::process_getOption;
+    processMap_["getOptions"] = &FacebookServiceProcessor::process_getOptions;
+    processMap_["aliveSince"] = &FacebookServiceProcessor::process_aliveSince;
+    processMap_["getLimitedReflection"] = &FacebookServiceProcessor::process_getLimitedReflection;
+    processMap_["reinitialize"] = &FacebookServiceProcessor::process_reinitialize;
+    processMap_["shutdown"] = &FacebookServiceProcessor::process_shutdown;
+    processMap_["getSingleTimeseries"] = &FacebookServiceProcessor::process_getSingleTimeseries;
+    processMap_["getTimeseries"] = &FacebookServiceProcessor::process_getTimeseries;
+  }
+
+  virtual bool process(boost::shared_ptr<facebook::thrift::protocol::TProtocol> piprot, boost::shared_ptr<facebook::thrift::protocol::TProtocol> poprot);
+  virtual ~FacebookServiceProcessor() {}
+};
+
+class FacebookServiceMultiface : virtual public FacebookServiceIf {
+ public:
+  FacebookServiceMultiface(std::vector<boost::shared_ptr<FacebookServiceIf> >& ifaces) : ifaces_(ifaces) {
+  }
+  virtual ~FacebookServiceMultiface() {}
+ protected:
+  std::vector<boost::shared_ptr<FacebookServiceIf> > ifaces_;
+  FacebookServiceMultiface() {}
+  void add(boost::shared_ptr<FacebookServiceIf> iface) {
+    ifaces_.push_back(iface);
+  }
+ public:
+  void getName(std::string& _return) {
+    uint32_t sz = ifaces_.size();
+    for (uint32_t i = 0; i < sz; ++i) {
+      if (i == sz - 1) {
+        ifaces_[i]->getName(_return);
+        return;
+      } else {
+        ifaces_[i]->getName(_return);
+      }
+    }
+  }
+
+  void getVersion(std::string& _return) {
+    uint32_t sz = ifaces_.size();
+    for (uint32_t i = 0; i < sz; ++i) {
+      if (i == sz - 1) {
+        ifaces_[i]->getVersion(_return);
+        return;
+      } else {
+        ifaces_[i]->getVersion(_return);
+      }
+    }
+  }
+
+  fb_status getStatus() {
+    uint32_t sz = ifaces_.size();
+    for (uint32_t i = 0; i < sz; ++i) {
+      if (i == sz - 1) {
+        return ifaces_[i]->getStatus();
+      } else {
+        ifaces_[i]->getStatus();
+      }
+    }
+  }
+
+  void getStatusDetails(std::string& _return) {
+    uint32_t sz = ifaces_.size();
+    for (uint32_t i = 0; i < sz; ++i) {
+      if (i == sz - 1) {
+        ifaces_[i]->getStatusDetails(_return);
+        return;
+      } else {
+        ifaces_[i]->getStatusDetails(_return);
+      }
+    }
+  }
+
+  void getCounters(std::map<std::string, int64_t> & _return) {
+    uint32_t sz = ifaces_.size();
+    for (uint32_t i = 0; i < sz; ++i) {
+      if (i == sz - 1) {
+        ifaces_[i]->getCounters(_return);
+        return;
+      } else {
+        ifaces_[i]->getCounters(_return);
+      }
+    }
+  }
+
+  int64_t getCounter(const std::string& key) {
+    uint32_t sz = ifaces_.size();
+    for (uint32_t i = 0; i < sz; ++i) {
+      if (i == sz - 1) {
+        return ifaces_[i]->getCounter(key);
+      } else {
+        ifaces_[i]->getCounter(key);
+      }
+    }
+  }
+
+  void setOption(const std::string& key, const std::string& value) {
+    uint32_t sz = ifaces_.size();
+    for (uint32_t i = 0; i < sz; ++i) {
+      ifaces_[i]->setOption(key, value);
+    }
+  }
+
+  void getOption(std::string& _return, const std::string& key) {
+    uint32_t sz = ifaces_.size();
+    for (uint32_t i = 0; i < sz; ++i) {
+      if (i == sz - 1) {
+        ifaces_[i]->getOption(_return, key);
+        return;
+      } else {
+        ifaces_[i]->getOption(_return, key);
+      }
+    }
+  }
+
+  void getOptions(std::map<std::string, std::string> & _return) {
+    uint32_t sz = ifaces_.size();
+    for (uint32_t i = 0; i < sz; ++i) {
+      if (i == sz - 1) {
+        ifaces_[i]->getOptions(_return);
+        return;
+      } else {
+        ifaces_[i]->getOptions(_return);
+      }
+    }
+  }
+
+  int64_t aliveSince() {
+    uint32_t sz = ifaces_.size();
+    for (uint32_t i = 0; i < sz; ++i) {
+      if (i == sz - 1) {
+        return ifaces_[i]->aliveSince();
+      } else {
+        ifaces_[i]->aliveSince();
+      }
+    }
+  }
+
+  void getLimitedReflection(facebook::thrift::reflection::limited::Service& _return) {
+    uint32_t sz = ifaces_.size();
+    for (uint32_t i = 0; i < sz; ++i) {
+      if (i == sz - 1) {
+        ifaces_[i]->getLimitedReflection(_return);
+        return;
+      } else {
+        ifaces_[i]->getLimitedReflection(_return);
+      }
+    }
+  }
+
+  void reinitialize() {
+    uint32_t sz = ifaces_.size();
+    for (uint32_t i = 0; i < sz; ++i) {
+      ifaces_[i]->reinitialize();
+    }
+  }
+
+  void shutdown() {
+    uint32_t sz = ifaces_.size();
+    for (uint32_t i = 0; i < sz; ++i) {
+      ifaces_[i]->shutdown();
+    }
+  }
+
+  void getSingleTimeseries(std::map<int64_t, double> & _return, const std::string& name, const int32_t series_length) {
+    uint32_t sz = ifaces_.size();
+    for (uint32_t i = 0; i < sz; ++i) {
+      if (i == sz - 1) {
+        ifaces_[i]->getSingleTimeseries(_return, name, series_length);
+        return;
+      } else {
+        ifaces_[i]->getSingleTimeseries(_return, name, series_length);
+      }
+    }
+  }
+
+  void getTimeseries(std::map<std::string, std::map<int64_t, double> > & _return, const int32_t series_length) {
+    uint32_t sz = ifaces_.size();
+    for (uint32_t i = 0; i < sz; ++i) {
+      if (i == sz - 1) {
+        ifaces_[i]->getTimeseries(_return, series_length);
+        return;
+      } else {
+        ifaces_[i]->getTimeseries(_return, series_length);
+      }
+    }
+  }
+
+};
+
+}} // namespace
+
+#endif

+ 202 - 0
src/contrib/hive/metastore/include/thrift/fb303/ServiceTracker.h

@@ -0,0 +1,202 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+/**
+ * ServiceTracker is a utility class for logging and timing service
+ * calls to a fb303 Thrift server.  Currently, ServiceTracker offers
+ * the following features:
+ *
+ *   . Logging of service method start, end (and duration), and
+ *     optional steps in between.
+ *
+ *   . Automatic check of server status via fb303::getStatus()
+ *     with a ServiceException thrown if server not alive
+ *     (at method start).
+ *
+ *   . A periodic logged checkpoint reporting lifetime time, lifetime
+ *     service count, and per-method statistics since the last checkpoint
+ *     time (at method finish).
+ *
+ *   . Export of fb303 counters for lifetime and checkpoint statistics
+ *     (at method finish).
+ *
+ *   . For TThreadPoolServers, a logged warning when all server threads
+ *     are busy (at method start).  (Must call setThreadManager() after
+ *     ServiceTracker instantiation for this feature to be enabled.)
+ *
+ * Individual features may be enabled or disabled by arguments to the
+ * constructor.  The constructor also accepts a pointer to a logging
+ * method -- if no pointer is passed, the tracker will log to stdout.
+ *
+ * ServiceTracker defines private methods for service start, finish,
+ * and step, which are designed to be accessed by instantiating a
+ * friend ServiceMethod object, as in the following example:
+ *
+ *    #include <ServiceTracker.h>
+ *    class MyServiceHandler : virtual public MyServiceIf,
+ *                             public facebook::fb303::FacebookBase
+ *    {
+ *    public:
+ *      MyServiceHandler::MyServiceHandler() : mServiceTracker(this) {}
+ *      void MyServiceHandler::myServiceMethod(int userId) {
+ *        // note: Instantiating a ServiceMethod object starts a timer
+ *        // and tells the ServiceTracker to log the start.  Might throw
+ *        // a ServiceException.
+ *        ServiceMethod serviceMethod(&mServiceTracker,
+ *                                   "myServiceMethod",
+ *                                   userId);
+ *        ...
+ *        // note: Calling the step method tells the ServiceTracker to
+ *        // log the step, with a time elapsed since start.
+ *        serviceMethod.step("post parsing, begin processing");
+ *        ...
+ *        // note: When the ServiceMethod object goes out of scope, the
+ *        // ServiceTracker will log the total elapsed time of the method.
+ *      }
+ *      ...
+ *    private:
+ *      ServiceTracker mServiceTracker;
+ *    }
+ *
+ * The step() method call is optional; the startService() and
+ * finishService() methods are handled by the object's constructor and
+ * destructor.
+ *
+ * The ServiceTracker is (intended to be) thread-safe.
+ *
+ * Future:
+ *
+ *   . Come up with something better for logging than passing a
+ *     function pointer to the constructor.
+ *
+ *   . Add methods for tracking errors from service methods, e.g.
+ *     ServiceTracker::reportService().
+ */
+
+#ifndef SERVICETRACKER_H
+#define SERVICETRACKER_H
+
+
+#include <iostream>
+#include <string>
+#include <sstream>
+#include <exception>
+#include <map>
+#include <boost/shared_ptr.hpp>
+
+#include "thrift/concurrency/Mutex.h"
+
+
+namespace facebook { namespace thrift { namespace concurrency {
+  class ThreadManager;
+}}}
+
+
+namespace facebook { namespace fb303 {
+
+
+class FacebookBase;
+class ServiceMethod;
+
+
+class Stopwatch
+{
+public:
+  enum Unit { UNIT_SECONDS, UNIT_MILLISECONDS, UNIT_MICROSECONDS };
+  Stopwatch();
+  uint64_t elapsedUnits(Unit unit, std::string *label = NULL) const;
+  void reset();
+private:
+  timeval startTime_;
+};
+
+
+class ServiceTracker
+{
+  friend class ServiceMethod;
+
+public:
+
+  static uint64_t CHECKPOINT_MINIMUM_INTERVAL_SECONDS;
+  static int LOG_LEVEL;
+
+  ServiceTracker(facebook::fb303::FacebookBase *handler,
+                 void (*logMethod)(int, const std::string &)
+                 = &ServiceTracker::defaultLogMethod,
+                 bool featureCheckpoint = true,
+                 bool featureStatusCheck = true,
+                 bool featureThreadCheck = true,
+                 Stopwatch::Unit stopwatchUnit
+                 = Stopwatch::UNIT_MILLISECONDS);
+
+  void setThreadManager(boost::shared_ptr<facebook::thrift::concurrency::ThreadManager> threadManager);
+
+private:
+
+  facebook::fb303::FacebookBase *handler_;
+  void (*logMethod_)(int, const std::string &);
+  boost::shared_ptr<facebook::thrift::concurrency::ThreadManager> threadManager_;
+
+  bool featureCheckpoint_;
+  bool featureStatusCheck_;
+  bool featureThreadCheck_;
+  Stopwatch::Unit stopwatchUnit_;
+
+  facebook::thrift::concurrency::Mutex statisticsMutex_;
+  time_t checkpointTime_;
+  uint64_t checkpointServices_;
+  uint64_t checkpointDuration_;
+  std::map<std::string, std::pair<uint64_t, uint64_t> > checkpointServiceDuration_;
+
+  void startService(const ServiceMethod &serviceMethod);
+  int64_t stepService(const ServiceMethod &serviceMethod,
+                      const std::string &stepName);
+  void finishService(const ServiceMethod &serviceMethod);
+  void reportCheckpoint();
+  static void defaultLogMethod(int level, const std::string &message);
+};
+
+
+class ServiceMethod
+{
+  friend class ServiceTracker;
+public:
+  ServiceMethod(ServiceTracker *tracker,
+                const std::string &name,
+                const std::string &signature,
+                bool featureLogOnly = false);
+  ServiceMethod(ServiceTracker *tracker,
+                const std::string &name,
+                uint64_t id,
+                bool featureLogOnly = false);
+  ~ServiceMethod();
+  uint64_t step(const std::string &stepName);
+private:
+  ServiceTracker *tracker_;
+  std::string name_;
+  std::string signature_;
+  bool featureLogOnly_;
+  Stopwatch timer_;
+};
+
+
+class ServiceException : public std::exception
+{
+public:
+  explicit ServiceException(const std::string &message, int code = 0)
+    : message_(message), code_(code) {}
+  ~ServiceException() throw() {}
+  virtual const char *what() const throw() { return message_.c_str(); }
+  int code() const throw() { return code_; }
+private:
+  std::string message_;
+  int code_;
+};
+
+
+}} // facebook::fb303
+
+#endif

+ 23 - 0
src/contrib/hive/metastore/include/thrift/fb303/fb303_constants.h

@@ -0,0 +1,23 @@
+/**
+ * Autogenerated by Thrift
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ */
+#ifndef fb303_CONSTANTS_H
+#define fb303_CONSTANTS_H
+
+#include "fb303_types.h"
+
+namespace facebook { namespace fb303 {
+
+class fb303Constants {
+ public:
+  fb303Constants();
+
+};
+
+extern const fb303Constants g_fb303_constants;
+
+}} // namespace
+
+#endif

+ 30 - 0
src/contrib/hive/metastore/include/thrift/fb303/fb303_types.h

@@ -0,0 +1,30 @@
+/**
+ * Autogenerated by Thrift
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ */
+#ifndef fb303_TYPES_H
+#define fb303_TYPES_H
+
+#include <Thrift.h>
+#include <reflection_limited_types.h>
+#include <protocol/TProtocol.h>
+#include <transport/TTransport.h>
+
+#include "reflection_limited_types.h"
+
+
+namespace facebook { namespace fb303 {
+
+enum fb_status {
+  DEAD = 0,
+  STARTING = 1,
+  ALIVE = 2,
+  STOPPING = 3,
+  STOPPED = 4,
+  WARNING = 5
+};
+
+}} // namespace
+
+#endif

+ 108 - 0
src/contrib/hive/metastore/include/thrift/fb303/if/fb303.thrift

@@ -0,0 +1,108 @@
+/**
+ * fb303.thrift
+ *
+ * Copyright (c) 2006- Facebook
+ * Distributed under the Thrift Software License
+ *
+ * See accompanying file LICENSE or visit the Thrift site at:
+ * http://developers.facebook.com/thrift/
+ *
+ *
+ * Definition of common Facebook data types and status reporting mechanisms
+ * common to all Facebook services. In some cases, these methods are
+ * provided in the base implementation, and in other cases they simply define
+ * methods that inheriting applications should implement (i.e. status report)
+ *
+ * @author Mark Slee <mcslee@facebook.com>
+ */
+
+include "thrift/if/reflection_limited.thrift"
+
+namespace java com.facebook.fb303
+namespace cpp facebook.fb303
+
+/**
+ * Common status reporting mechanism across all services
+ */
+enum fb_status {
+  DEAD = 0,
+  STARTING = 1,
+  ALIVE = 2,
+  STOPPING = 3,
+  STOPPED = 4,
+  WARNING = 5,
+}
+
+/**
+ * Standard base service
+ */
+service FacebookService {
+
+  /**
+   * Returns a descriptive name of the service
+   */
+  string getName(),
+
+  /**
+   * Returns the version of the service
+   */
+  string getVersion(),
+
+  /**
+   * Gets the status of this service
+   */
+  fb_status getStatus(),
+
+  /**
+   * User friendly description of status, such as why the service is in
+   * the dead or warning state, or what is being started or stopped.
+   */
+  string getStatusDetails(),
+
+  /**
+   * Gets the counters for this service
+   */
+  map<string, i64> getCounters(),
+
+  /**
+   * Gets the value of a single counter
+   */
+  i64 getCounter(1: string key),
+
+  /**
+   * Sets an option
+   */
+  void setOption(1: string key, 2: string value),
+
+  /**
+   * Gets an option
+   */
+  string getOption(1: string key),
+
+  /**
+   * Gets all options
+   */
+  map<string, string> getOptions(),
+
+  /**
+   * Returns the unix time that the server has been running since
+   */
+  i64 aliveSince(),
+
+  /**
+   * Returns a limited description of this service.
+   */
+  reflection_limited.Service
+  getLimitedReflection(),
+
+  /**
+   * Tell the server to reload its configuration, reopen log files, etc
+   */
+  async void reinitialize()
+
+  /**
+   * Suggest a shutdown to the server
+   */
+  async void shutdown()
+
+}

+ 71 - 0
src/contrib/hive/metastore/include/thrift/if/reflection_limited.thrift

@@ -0,0 +1,71 @@
+#!/usr/local/bin/thrift -php -java -cpp -py
+
+// NOTICE!!!
+// DO NOT FORGET to run regen.sh if you change this file
+// (or if you change the compiler).
+
+// This interface is deprecated.
+// There is no replacement yet, but I hate it so much that
+// I'm deprecating it before it's done.
+// @author I'm too ashamed to say.
+
+// dreiss naively thinks he knows how to do this better,
+// so talk to him if you are interested in taking it on,
+// or if you just want someone to make it better for you.
+
+namespace cpp facebook.thrift.reflection.limited
+namespace java com.facebook.thrift.reflection.limited
+py_module thrift.reflection.limited
+
+enum TTypeTag {
+  T_VOID   = 1,
+  T_BOOL   = 2,
+  T_BYTE   = 3,
+  T_I16    = 6,
+  T_I32    = 8,
+  T_I64    = 10,
+  T_DOUBLE = 4,
+  T_STRING = 11,
+  T_STRUCT = 12,
+  T_MAP    = 13,
+  T_SET    = 14,
+  T_LIST   = 15,
+  // This doesn't exist in TBinaryProtocol, but it could be useful for reflection.
+  T_ENUM   = 101,
+  T_NOT_REFLECTED = 102,
+}
+
+struct SimpleType {
+  1: TTypeTag ttype,
+  2: string name,  // For structs and emums.
+}
+
+struct ContainerType {
+  1: TTypeTag ttype,
+  2:          SimpleType subtype1,
+  3: optional SimpleType subtype2,
+}
+
+struct ThriftType {
+  1: bool is_container,
+  2: optional SimpleType simple_type,
+  3: optional ContainerType container_type,
+}
+
+struct Argument {
+  1: i16 key,
+  2: string name,
+  3: ThriftType type,
+}
+
+struct Method {
+  1: string name,
+  2: ThriftType return_type,
+  3: list<Argument> arguments,
+}
+
+struct Service {
+  1: string name,
+  2: list<Method> methods,
+  3: bool fully_reflected,
+}

+ 64 - 0
src/contrib/hive/metastore/include/thrift/processor/PeekProcessor.h

@@ -0,0 +1,64 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#ifndef PEEKPROCESSOR_H
+#define PEEKPROCESSOR_H
+
+#include <string>
+#include <TProcessor.h>
+#include <transport/TTransport.h>
+#include <transport/TTransportUtils.h>
+#include <boost/shared_ptr.hpp>
+
+namespace facebook { namespace thrift { namespace processor { 
+
+/*
+ * Class for peeking at the raw data that is being processed by another processor
+ * and gives the derived class a chance to change behavior accordingly
+ *
+ * @author James Wang <jwang@facebook.com>
+ */
+class PeekProcessor : public facebook::thrift::TProcessor {
+  
+ public:
+  PeekProcessor();
+  virtual ~PeekProcessor();
+
+  // Input here: actualProcessor  - the underlying processor
+  //             protocolFactory  - the protocol factory used to wrap the memory buffer
+  //             transportFactory - this TPipedTransportFactory is used to wrap the source transport
+  //                                via a call to getPipedTransport
+  void initialize(boost::shared_ptr<facebook::thrift::TProcessor> actualProcessor,
+                  boost::shared_ptr<facebook::thrift::protocol::TProtocolFactory> protocolFactory,
+                  boost::shared_ptr<facebook::thrift::transport::TPipedTransportFactory> transportFactory);
+
+  boost::shared_ptr<facebook::thrift::transport::TTransport> getPipedTransport(boost::shared_ptr<facebook::thrift::transport::TTransport> in);
+
+  void setTargetTransport(boost::shared_ptr<facebook::thrift::transport::TTransport> targetTransport);
+
+  virtual bool process(boost::shared_ptr<facebook::thrift::protocol::TProtocol> in, 
+                       boost::shared_ptr<facebook::thrift::protocol::TProtocol> out);
+
+  // The following three functions can be overloaded by child classes to
+  // achieve desired peeking behavior
+  virtual void peekName(const std::string& fname);
+  virtual void peekBuffer(uint8_t* buffer, uint32_t size);
+  virtual void peek(boost::shared_ptr<facebook::thrift::protocol::TProtocol> in, 
+                    facebook::thrift::protocol::TType ftype,
+                    int16_t fid);
+  virtual void peekEnd();
+
+ private:
+  boost::shared_ptr<facebook::thrift::TProcessor> actualProcessor_;
+  boost::shared_ptr<facebook::thrift::protocol::TProtocol> pipedProtocol_;
+  boost::shared_ptr<facebook::thrift::transport::TPipedTransportFactory> transportFactory_;
+  boost::shared_ptr<facebook::thrift::transport::TMemoryBuffer> memoryBuffer_;
+  boost::shared_ptr<facebook::thrift::transport::TTransport> targetTransport_;
+};
+
+}}} // facebook::thrift::processor
+
+#endif

+ 252 - 0
src/contrib/hive/metastore/include/thrift/processor/StatsProcessor.h

@@ -0,0 +1,252 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#ifndef STATSPROCESSOR_H
+#define STATSPROCESSOR_H
+
+#include <boost/shared_ptr.hpp>
+#include <transport/TTransport.h>
+#include <protocol/TProtocol.h>
+#include <TProcessor.h>
+
+namespace facebook { namespace thrift { namespace processor { 
+
+/*
+ * Class for keeping track of function call statistics and printing them if desired
+ *
+ * @author James Wang <jwang@facebook.com>
+ */
+class StatsProcessor : public facebook::thrift::TProcessor {
+public:
+  StatsProcessor(bool print, bool frequency) 
+    : print_(print),
+      frequency_(frequency)
+  {}
+  virtual ~StatsProcessor() {};
+
+  virtual bool process(boost::shared_ptr<facebook::thrift::protocol::TProtocol> piprot, boost::shared_ptr<facebook::thrift::protocol::TProtocol> poprot) {
+
+    piprot_ = piprot;
+
+    std::string fname;
+    facebook::thrift::protocol::TMessageType mtype;
+    int32_t seqid;
+
+    piprot_->readMessageBegin(fname, mtype, seqid);
+    if (mtype != facebook::thrift::protocol::T_CALL) {
+      if (print_) {
+        printf("Unknown message type\n");
+      }
+      throw facebook::thrift::TException("Unexpected message type");
+    }
+    if (print_) {
+      printf("%s (", fname.c_str());
+    }
+    if (frequency_) {
+      if (frequency_map_.find(fname) != frequency_map_.end()) {
+        frequency_map_[fname]++;
+      } else {
+        frequency_map_[fname] = 1;
+      }
+    }
+
+    facebook::thrift::protocol::TType ftype;
+    int16_t fid;
+
+    while (true) {
+      piprot_->readFieldBegin(fname, ftype, fid);
+      if (ftype == facebook::thrift::protocol::T_STOP) {
+        break;
+      }
+
+      printAndPassToBuffer(ftype);
+      if (print_) {
+        printf(", ");
+      }
+    }
+
+    if (print_) {
+      printf("\b\b)\n");
+    }
+    return true;
+  }
+
+  const std::map<std::string, int64_t>& get_frequency_map() {
+    return frequency_map_;
+  }
+
+protected:
+  void printAndPassToBuffer(facebook::thrift::protocol::TType ftype) {
+    switch (ftype) {
+      case facebook::thrift::protocol::T_BOOL:
+        {
+          bool boolv;
+          piprot_->readBool(boolv);
+          if (print_) {
+            printf("%d", boolv);
+          }
+        }
+        break;
+      case facebook::thrift::protocol::T_BYTE:
+        {
+          int8_t bytev;
+          piprot_->readByte(bytev);
+          if (print_) {
+            printf("%d", bytev);
+          }
+        }
+        break;
+      case facebook::thrift::protocol::T_I16:
+        {
+          int16_t i16;
+          piprot_->readI16(i16);
+          if (print_) {
+            printf("%d", i16);
+          }
+        }
+        break;
+      case facebook::thrift::protocol::T_I32:
+        {
+          int32_t i32;
+          piprot_->readI32(i32);
+          if (print_) {
+            printf("%d", i32);
+          }
+        }
+        break;
+      case facebook::thrift::protocol::T_I64:
+        {
+          int64_t i64;
+          piprot_->readI64(i64);
+          if (print_) {
+            printf("%ld", i64);
+          }
+        }
+        break;
+      case facebook::thrift::protocol::T_DOUBLE:
+        {
+          double dub; 
+          piprot_->readDouble(dub);
+          if (print_) {
+            printf("%f", dub);
+          }
+        }
+        break;
+      case facebook::thrift::protocol::T_STRING: 
+        {
+          std::string str;
+          piprot_->readString(str);
+          if (print_) {
+            printf("%s", str.c_str());
+          }
+        }
+        break;
+      case facebook::thrift::protocol::T_STRUCT: 
+        {
+          std::string name;
+          int16_t fid;
+          facebook::thrift::protocol::TType ftype;
+          piprot_->readStructBegin(name);
+          if (print_) {
+            printf("<");
+          }
+          while (true) {
+            piprot_->readFieldBegin(name, ftype, fid);
+            if (ftype == facebook::thrift::protocol::T_STOP) {
+              break;
+            }
+            printAndPassToBuffer(ftype);
+            if (print_) {
+              printf(",");
+            }
+            piprot_->readFieldEnd();
+          }
+          piprot_->readStructEnd();
+          if (print_) {
+            printf("\b>");
+          }
+        }
+        break;
+      case facebook::thrift::protocol::T_MAP:
+        {
+          facebook::thrift::protocol::TType keyType;
+          facebook::thrift::protocol::TType valType;
+          uint32_t i, size;
+          piprot_->readMapBegin(keyType, valType, size);
+          if (print_) {
+            printf("{");
+          }
+          for (i = 0; i < size; i++) {
+            printAndPassToBuffer(keyType);
+            if (print_) {
+              printf("=>");
+            }
+            printAndPassToBuffer(valType);
+            if (print_) {
+              printf(",");
+            }
+          }
+          piprot_->readMapEnd();
+          if (print_) {
+            printf("\b}");
+          }
+        }
+        break;
+      case facebook::thrift::protocol::T_SET:
+        {
+          facebook::thrift::protocol::TType elemType;
+          uint32_t i, size;
+          piprot_->readSetBegin(elemType, size);
+          if (print_) {
+            printf("{");
+          }
+          for (i = 0; i < size; i++) {
+            printAndPassToBuffer(elemType);
+            if (print_) {
+              printf(",");
+            }
+          }
+          piprot_->readSetEnd();
+          if (print_) {
+            printf("\b}");
+          }
+        }
+        break;
+      case facebook::thrift::protocol::T_LIST:
+        {
+          facebook::thrift::protocol::TType elemType;
+          uint32_t i, size;
+          piprot_->readListBegin(elemType, size);
+          if (print_) {
+            printf("[");
+          }
+          for (i = 0; i < size; i++) {
+            printAndPassToBuffer(elemType);
+            if (print_) {
+              printf(",");
+            }
+          }
+          piprot_->readListEnd();
+          if (print_) {
+            printf("\b]");
+          }
+        }
+        break;
+      default:
+        break;
+    }
+  }
+
+  boost::shared_ptr<facebook::thrift::protocol::TProtocol> piprot_;
+  std::map<std::string, int64_t> frequency_map_;
+
+  bool print_;
+  bool frequency_;
+};
+
+}}} // facebook::thrift::processor
+
+#endif

+ 239 - 0
src/contrib/hive/metastore/include/thrift/protocol/TBinaryProtocol.h

@@ -0,0 +1,239 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#ifndef _THRIFT_PROTOCOL_TBINARYPROTOCOL_H_
+#define _THRIFT_PROTOCOL_TBINARYPROTOCOL_H_ 1
+
+#include "TProtocol.h"
+
+#include <boost/shared_ptr.hpp>
+
+namespace facebook { namespace thrift { namespace protocol { 
+
+/**
+ * The default binary protocol for thrift. Writes all data in a very basic
+ * binary format, essentially just spitting out the raw bytes.
+ *
+ * @author Mark Slee <mcslee@facebook.com>
+ */
+class TBinaryProtocol : public TProtocol {
+ protected:
+  static const int32_t VERSION_MASK = 0xffff0000;
+  static const int32_t VERSION_1 = 0x80010000;
+  // VERSION_2 (0x80020000)  is taken by TDenseProtocol.
+
+ public:
+  TBinaryProtocol(boost::shared_ptr<TTransport> trans) :
+    TProtocol(trans),
+    string_limit_(0),
+    container_limit_(0),
+    strict_read_(false),
+    strict_write_(true),
+    string_buf_(NULL),
+    string_buf_size_(0) {}
+
+  TBinaryProtocol(boost::shared_ptr<TTransport> trans,
+                  int32_t string_limit,
+                  int32_t container_limit,
+                  bool strict_read,
+                  bool strict_write) :
+    TProtocol(trans),
+    string_limit_(string_limit),
+    container_limit_(container_limit),
+    strict_read_(strict_read),
+    strict_write_(strict_write),
+    string_buf_(NULL),
+    string_buf_size_(0) {}
+
+  ~TBinaryProtocol() {
+    if (string_buf_ != NULL) {
+      free(string_buf_);
+      string_buf_size_ = 0;
+    }
+  }
+
+  void setStringSizeLimit(int32_t string_limit) {
+    string_limit_ = string_limit;
+  }
+
+  void setContainerSizeLimit(int32_t container_limit) {
+    container_limit_ = container_limit;
+  }
+
+  void setStrict(bool strict_read, bool strict_write) {
+    strict_read_ = strict_read;
+    strict_write_ = strict_write;
+  }
+
+  /**
+   * Writing functions.
+   */
+
+  virtual uint32_t writeMessageBegin(const std::string& name,
+                                     const TMessageType messageType,
+                                     const int32_t seqid);
+
+  virtual uint32_t writeMessageEnd();
+
+
+  uint32_t writeStructBegin(const std::string& name);
+
+  uint32_t writeStructEnd();
+
+  uint32_t writeFieldBegin(const std::string& name,
+                           const TType fieldType,
+                           const int16_t fieldId);
+
+  uint32_t writeFieldEnd();
+
+  uint32_t writeFieldStop();
+                                       
+  uint32_t writeMapBegin(const TType keyType,
+                         const TType valType,
+                         const uint32_t size);
+
+  uint32_t writeMapEnd();
+
+  uint32_t writeListBegin(const TType elemType,
+                          const uint32_t size);
+
+  uint32_t writeListEnd();
+
+  uint32_t writeSetBegin(const TType elemType,
+                         const uint32_t size);
+
+  uint32_t writeSetEnd();
+
+  uint32_t writeBool(const bool value);
+
+  uint32_t writeByte(const int8_t byte);
+
+  uint32_t writeI16(const int16_t i16);
+
+  uint32_t writeI32(const int32_t i32);
+
+  uint32_t writeI64(const int64_t i64);
+
+  uint32_t writeDouble(const double dub);
+
+
+  uint32_t writeString(const std::string& str);
+
+  /**
+   * Reading functions
+   */
+
+
+  uint32_t readMessageBegin(std::string& name,
+                            TMessageType& messageType,
+                            int32_t& seqid);
+
+  uint32_t readMessageEnd();
+
+  uint32_t readStructBegin(std::string& name);
+
+  uint32_t readStructEnd();
+
+  uint32_t readFieldBegin(std::string& name,
+                          TType& fieldType,
+                          int16_t& fieldId);
+  
+  uint32_t readFieldEnd();
+ 
+  uint32_t readMapBegin(TType& keyType,
+                        TType& valType,
+                        uint32_t& size);
+
+  uint32_t readMapEnd();
+
+  uint32_t readListBegin(TType& elemType,
+                         uint32_t& size);
+  
+  uint32_t readListEnd();
+
+  uint32_t readSetBegin(TType& elemType,
+                        uint32_t& size);
+
+  uint32_t readSetEnd();
+
+  uint32_t readBool(bool& value);
+
+  uint32_t readByte(int8_t& byte);
+
+  uint32_t readI16(int16_t& i16);
+
+  uint32_t readI32(int32_t& i32);
+
+  uint32_t readI64(int64_t& i64);
+
+  uint32_t readDouble(double& dub);
+
+  uint32_t readString(std::string& str);
+
+ protected:
+  uint32_t readStringBody(std::string& str, int32_t sz);
+
+  int32_t string_limit_;
+  int32_t container_limit_;
+
+  // Enforce presence of version identifier
+  bool strict_read_;
+  bool strict_write_;
+
+  // Buffer for reading strings, save for the lifetime of the protocol to
+  // avoid memory churn allocating memory on every string read
+  uint8_t* string_buf_;
+  int32_t string_buf_size_;
+
+};
+
+/**
+ * Constructs binary protocol handlers
+ */
+class TBinaryProtocolFactory : public TProtocolFactory {
+ public:
+  TBinaryProtocolFactory() :
+    string_limit_(0),
+    container_limit_(0),
+    strict_read_(false),
+    strict_write_(true) {}
+
+  TBinaryProtocolFactory(int32_t string_limit, int32_t container_limit, bool strict_read, bool strict_write) :
+    string_limit_(string_limit),
+    container_limit_(container_limit),
+    strict_read_(strict_read),
+    strict_write_(strict_write) {}
+
+  virtual ~TBinaryProtocolFactory() {}
+
+  void setStringSizeLimit(int32_t string_limit) {
+    string_limit_ = string_limit;
+  }
+
+  void setContainerSizeLimit(int32_t container_limit) {
+    container_limit_ = container_limit;
+  }
+
+  void setStrict(bool strict_read, bool strict_write) {
+    strict_read_ = strict_read;
+    strict_write_ = strict_write;
+  }
+
+  boost::shared_ptr<TProtocol> getProtocol(boost::shared_ptr<TTransport> trans) {
+    return boost::shared_ptr<TProtocol>(new TBinaryProtocol(trans, string_limit_, container_limit_, strict_read_, strict_write_));
+  }
+
+ private:
+  int32_t string_limit_;
+  int32_t container_limit_;
+  bool strict_read_;
+  bool strict_write_;
+
+};
+
+}}} // facebook::thrift::protocol
+
+#endif // #ifndef _THRIFT_PROTOCOL_TBINARYPROTOCOL_H_

+ 194 - 0
src/contrib/hive/metastore/include/thrift/protocol/TDebugProtocol.h

@@ -0,0 +1,194 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#ifndef _THRIFT_PROTOCOL_TDEBUGPROTOCOL_H_
+#define _THRIFT_PROTOCOL_TDEBUGPROTOCOL_H_ 1
+
+#include "TProtocol.h"
+#include "TOneWayProtocol.h"
+
+#include <boost/shared_ptr.hpp>
+
+#include <transport/TTransportUtils.h>
+
+namespace facebook { namespace thrift { namespace protocol { 
+
+/*
+
+!!! EXPERIMENTAL CODE !!!
+
+This protocol is very much a work in progress.
+It doesn't handle many cases properly.
+It throws exceptions in many cases.
+It probably segfaults in many cases.
+Bug reports and feature requests are welcome.
+Complaints are not. :R
+
+*/
+
+
+/**
+ * Protocol that prints the payload in a nice human-readable format.
+ * Reading from this protocol is not supported.
+ *
+ * @author David Reiss <dreiss@facebook.com>
+ */
+class TDebugProtocol : public TWriteOnlyProtocol {
+ private:
+  enum write_state_t {
+    UNINIT,
+    STRUCT,
+    LIST,
+    SET,
+    MAP_KEY,
+    MAP_VALUE,
+  };
+
+ public:
+  TDebugProtocol(boost::shared_ptr<TTransport> trans)
+    : TWriteOnlyProtocol(trans, "TDebugProtocol")
+  {
+    write_state_.push_back(UNINIT);
+  }
+
+
+  virtual uint32_t writeMessageBegin(const std::string& name,
+                                     const TMessageType messageType,
+                                     const int32_t seqid);
+
+  virtual uint32_t writeMessageEnd();
+
+
+  uint32_t writeStructBegin(const std::string& name);
+
+  uint32_t writeStructEnd();
+
+  uint32_t writeFieldBegin(const std::string& name,
+                           const TType fieldType,
+                           const int16_t fieldId);
+
+  uint32_t writeFieldEnd();
+
+  uint32_t writeFieldStop();
+                                       
+  uint32_t writeMapBegin(const TType keyType,
+                         const TType valType,
+                         const uint32_t size);
+
+  uint32_t writeMapEnd();
+
+  uint32_t writeListBegin(const TType elemType,
+                          const uint32_t size);
+
+  uint32_t writeListEnd();
+
+  uint32_t writeSetBegin(const TType elemType,
+                         const uint32_t size);
+
+  uint32_t writeSetEnd();
+
+  uint32_t writeBool(const bool value);
+
+  uint32_t writeByte(const int8_t byte);
+
+  uint32_t writeI16(const int16_t i16);
+
+  uint32_t writeI32(const int32_t i32);
+
+  uint32_t writeI64(const int64_t i64);
+
+  uint32_t writeDouble(const double dub);
+
+  uint32_t writeString(const std::string& str);
+
+
+ private:
+  void indentUp();
+  void indentDown();
+  uint32_t writePlain(const std::string& str);
+  uint32_t writeIndented(const std::string& str);
+  uint32_t startItem();
+  uint32_t endItem();
+  uint32_t writeItem(const std::string& str);
+
+  static std::string fieldTypeName(TType type);
+
+  std::string indent_str_;
+  static const int indent_inc = 2;
+
+  std::vector<write_state_t> write_state_;
+  std::vector<int> list_idx_;
+};
+
+/**
+ * Constructs debug protocol handlers
+ */
+class TDebugProtocolFactory : public TProtocolFactory {
+ public:
+  TDebugProtocolFactory() {}
+  virtual ~TDebugProtocolFactory() {}
+
+  boost::shared_ptr<TProtocol> getProtocol(boost::shared_ptr<TTransport> trans) {
+    return boost::shared_ptr<TProtocol>(new TDebugProtocol(trans));
+  }
+
+};
+
+}}} // facebook::thrift::protocol
+
+
+namespace facebook { namespace thrift { 
+
+template<typename ThriftStruct>
+std::string ThriftDebugString(const ThriftStruct& ts) {
+  using namespace facebook::thrift::transport;
+  using namespace facebook::thrift::protocol;
+  TMemoryBuffer* buffer = new TMemoryBuffer;
+  boost::shared_ptr<TTransport> trans(buffer);
+  TDebugProtocol protocol(trans);
+
+  ts.write(&protocol);
+
+  uint8_t* buf;
+  uint32_t size;
+  buffer->getBuffer(&buf, &size);
+  return std::string((char*)buf, (unsigned int)size);
+}
+
+// TODO(dreiss): This is badly broken.  Don't use it unless you are me.
+#if 0
+template<typename Object>
+std::string DebugString(const std::vector<Object>& vec) {
+  using namespace facebook::thrift::transport;
+  using namespace facebook::thrift::protocol;
+  TMemoryBuffer* buffer = new TMemoryBuffer;
+  boost::shared_ptr<TTransport> trans(buffer);
+  TDebugProtocol protocol(trans);
+
+  // I am gross!
+  protocol.writeStructBegin("SomeRandomVector");
+
+  // TODO: Fix this with a trait.
+  protocol.writeListBegin((TType)99, vec.size());
+  typename std::vector<Object>::const_iterator it;
+  for (it = vec.begin(); it != vec.end(); ++it) {
+    it->write(&protocol);
+  }
+  protocol.writeListEnd();
+
+  uint8_t* buf;
+  uint32_t size;
+  buffer->getBuffer(&buf, &size);
+  return std::string((char*)buf, (unsigned int)size);
+}
+#endif // 0
+
+}} // facebook::thrift
+
+
+#endif // #ifndef _THRIFT_PROTOCOL_TDEBUGPROTOCOL_H_
+
+

+ 238 - 0
src/contrib/hive/metastore/include/thrift/protocol/TDenseProtocol.h

@@ -0,0 +1,238 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#ifndef _THRIFT_PROTOCOL_TDENSEPROTOCOL_H_
+#define _THRIFT_PROTOCOL_TDENSEPROTOCOL_H_ 1
+
+#include "TBinaryProtocol.h"
+
+namespace facebook { namespace thrift { namespace protocol {
+
+/**
+ * !!!WARNING!!!
+ * This class is still highly experimental.  Incompatible changes
+ * WILL be made to it without notice.  DO NOT USE IT YET unless
+ * you are coordinating your testing with the author.
+ *
+ * The dense protocol is designed to use as little space as possible.
+ *
+ * There are two types of dense protocol instances.  Standalone instances
+ * are not used for RPC and just encoded and decode structures of 
+ * a predetermined type.  Non-standalone instances are used for RPC.
+ * Currently, only standalone instances exist.
+ *
+ * To use a standalone dense protocol object, you must set the type_spec
+ * property (either in the constructor, or with setTypeSpec) to the local
+ * reflection TypeSpec of the structures you will write to (or read from) the
+ * protocol instance.
+ *
+ * BEST PRACTICES:
+ * - Never use optional for primitives or containers.
+ * - Only use optional for structures if they are very big and very rarely set.
+ * - All integers are variable-length, so you can use i64 without bloating.
+ * - NEVER EVER change the struct definitions IN ANY WAY without either
+ *   changing your cache keys or talking to dreiss.
+ *
+ * TODO(dreiss): New class write with old meta.
+ *
+ * We override all of TBinaryProtocol's methods.
+ * We inherit so that we can can explicitly call TBPs's primitive-writing
+ * methods within our versions.
+ *
+ * @author David Reiss <dreiss@facebook.com>
+ */
+class TDenseProtocol : public TBinaryProtocol {
+ protected:
+  static const int32_t VERSION_MASK = 0xffff0000;
+  // VERSION_1 (0x80010000)  is taken by TBinaryProtocol.
+  static const int32_t VERSION_2 = 0x80020000;
+
+ public:
+  typedef facebook::thrift::reflection::local::TypeSpec TypeSpec;
+  static const int FP_PREFIX_LEN;
+
+  /**
+   * @param tran       The transport to use.
+   * @param type_spec  The TypeSpec of the structures using this protocol.
+   */
+  TDenseProtocol(boost::shared_ptr<TTransport> trans,
+                 TypeSpec* type_spec = NULL) :
+    TBinaryProtocol(trans),
+    type_spec_(type_spec),
+    standalone_(true)
+  {}
+
+  void setTypeSpec(TypeSpec* type_spec) {
+    type_spec_ = type_spec;
+  }
+  TypeSpec* getTypeSpec() {
+    return type_spec_;
+  }
+
+
+  /*
+   * Writing functions.
+   */
+
+  virtual uint32_t writeMessageBegin(const std::string& name,
+                                     const TMessageType messageType,
+                                     const int32_t seqid);
+
+  virtual uint32_t writeMessageEnd();
+
+
+  virtual uint32_t writeStructBegin(const std::string& name);
+
+  virtual uint32_t writeStructEnd();
+
+  virtual uint32_t writeFieldBegin(const std::string& name,
+                                   const TType fieldType,
+                                   const int16_t fieldId);
+
+  virtual uint32_t writeFieldEnd();
+
+  virtual uint32_t writeFieldStop();
+
+  virtual uint32_t writeMapBegin(const TType keyType,
+                                 const TType valType,
+                                 const uint32_t size);
+
+  virtual uint32_t writeMapEnd();
+
+  virtual uint32_t writeListBegin(const TType elemType,
+                                  const uint32_t size);
+
+  virtual uint32_t writeListEnd();
+
+  virtual uint32_t writeSetBegin(const TType elemType,
+                                 const uint32_t size);
+
+  virtual uint32_t writeSetEnd();
+
+  virtual uint32_t writeBool(const bool value);
+
+  virtual uint32_t writeByte(const int8_t byte);
+
+  virtual uint32_t writeI16(const int16_t i16);
+
+  virtual uint32_t writeI32(const int32_t i32);
+
+  virtual uint32_t writeI64(const int64_t i64);
+
+  virtual uint32_t writeDouble(const double dub);
+
+  virtual uint32_t writeString(const std::string& str);
+
+
+  /*
+   * Helper writing functions (don't do state transitions).
+   */
+  inline uint32_t subWriteI32(const int32_t i32);
+
+  inline uint32_t subWriteString(const std::string& str);
+
+  uint32_t subWriteBool(const bool value) {
+    return TBinaryProtocol::writeBool(value);
+  }
+
+
+  /*
+   * Reading functions
+   */
+
+  uint32_t readMessageBegin(std::string& name,
+                            TMessageType& messageType,
+                            int32_t& seqid);
+
+  uint32_t readMessageEnd();
+
+  uint32_t readStructBegin(std::string& name);
+
+  uint32_t readStructEnd();
+
+  uint32_t readFieldBegin(std::string& name,
+                          TType& fieldType,
+                          int16_t& fieldId);
+
+  uint32_t readFieldEnd();
+
+  uint32_t readMapBegin(TType& keyType,
+                        TType& valType,
+                        uint32_t& size);
+
+  uint32_t readMapEnd();
+
+  uint32_t readListBegin(TType& elemType,
+                         uint32_t& size);
+
+  uint32_t readListEnd();
+
+  uint32_t readSetBegin(TType& elemType,
+                        uint32_t& size);
+
+  uint32_t readSetEnd();
+
+  uint32_t readBool(bool& value);
+
+  uint32_t readByte(int8_t& byte);
+
+  uint32_t readI16(int16_t& i16);
+
+  uint32_t readI32(int32_t& i32);
+
+  uint32_t readI64(int64_t& i64);
+
+  uint32_t readDouble(double& dub);
+
+  uint32_t readString(std::string& str);
+
+
+  /*
+   * Helper reading functions (don't do state transitions).
+   */
+  inline uint32_t subReadI32(int32_t& i32);
+
+  inline uint32_t subReadString(std::string& str);
+
+  uint32_t subReadBool(bool& value) {
+    return TBinaryProtocol::readBool(value);
+  }
+
+
+ private:
+
+  // Implementation functions, documented in the .cpp.
+  inline void checkTType(const TType ttype);
+  inline void stateTransition();
+
+  // Read and write variable-length integers.
+  // Uses the same technique as the MIDI file format.
+  inline uint32_t vlqRead(uint64_t& vlq);
+  inline uint32_t vlqWrite(uint64_t vlq);
+
+  // Called before throwing an exception to make the object reusable.
+  void resetState() {
+    ts_stack_.clear();
+    idx_stack_.clear();
+    mkv_stack_.clear();
+  }
+
+  // TypeSpec of the top-level structure to write,
+  // for standalone protocol objects.
+  TypeSpec* type_spec_;
+
+  std::vector<TypeSpec*> ts_stack_;   // TypeSpec stack.
+  std::vector<int>       idx_stack_;  // InDeX stack.
+  std::vector<bool>      mkv_stack_;  // Map Key/Vlue stack.
+                                      // True = key, False = value.
+
+  // True iff this is a standalone instance (no RPC).
+  bool standalone_;
+};
+
+}}} // facebook::thrift::protocol
+
+#endif // #ifndef _THRIFT_PROTOCOL_TDENSEPROTOCOL_H_

+ 147 - 0
src/contrib/hive/metastore/include/thrift/protocol/TOneWayProtocol.h

@@ -0,0 +1,147 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#ifndef _THRIFT_PROTOCOL_TONEWAYPROTOCOL_H_
+#define _THRIFT_PROTOCOL_TONEWAYPROTOCOL_H_ 1
+
+#include "TProtocol.h"
+
+namespace facebook { namespace thrift { namespace protocol { 
+
+/**
+ * Abstract class for implementing a protocol that can only be written,
+ * not read.
+ *
+ * @author David Reiss <dreiss@facebook.com>
+ */
+class TWriteOnlyProtocol : public TProtocol {
+ public:
+  /**
+   * @param subclass_name  The name of the concrete subclass.
+   */
+  TWriteOnlyProtocol(boost::shared_ptr<TTransport> trans,
+                     const std::string& subclass_name)
+    : TProtocol(trans)
+    , subclass_(subclass_name)
+  {}
+
+  // All writing functions remain abstract.
+
+  /**
+   * Reading functions all throw an exception.
+   */
+
+  uint32_t readMessageBegin(std::string& name,
+                            TMessageType& messageType,
+                            int32_t& seqid) {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+        subclass_ + " does not support reading (yet).");
+  }
+
+  uint32_t readMessageEnd() {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+        subclass_ + " does not support reading (yet).");
+  }
+
+  uint32_t readStructBegin(std::string& name) {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+        subclass_ + " does not support reading (yet).");
+  }
+
+  uint32_t readStructEnd() {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+        subclass_ + " does not support reading (yet).");
+  }
+
+  uint32_t readFieldBegin(std::string& name,
+                          TType& fieldType,
+                          int16_t& fieldId) {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+        subclass_ + " does not support reading (yet).");
+  }
+  
+  uint32_t readFieldEnd() {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+        subclass_ + " does not support reading (yet).");
+  }
+ 
+  uint32_t readMapBegin(TType& keyType,
+                        TType& valType,
+                        uint32_t& size) {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+        subclass_ + " does not support reading (yet).");
+  }
+
+  uint32_t readMapEnd() {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+        subclass_ + " does not support reading (yet).");
+  }
+
+  uint32_t readListBegin(TType& elemType,
+                         uint32_t& size) {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+        subclass_ + " does not support reading (yet).");
+  }
+  
+  uint32_t readListEnd() {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+        subclass_ + " does not support reading (yet).");
+  }
+
+  uint32_t readSetBegin(TType& elemType,
+                        uint32_t& size) {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+        subclass_ + " does not support reading (yet).");
+  }
+
+  uint32_t readSetEnd() {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+        subclass_ + " does not support reading (yet).");
+  }
+
+  uint32_t readBool(bool& value) {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+        subclass_ + " does not support reading (yet).");
+  }
+
+  uint32_t readByte(int8_t& byte) {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+        subclass_ + " does not support reading (yet).");
+  }
+
+  uint32_t readI16(int16_t& i16) {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+        subclass_ + " does not support reading (yet).");
+  }
+
+  uint32_t readI32(int32_t& i32) {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+        subclass_ + " does not support reading (yet).");
+  }
+
+  uint32_t readI64(int64_t& i64) {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+        subclass_ + " does not support reading (yet).");
+  }
+
+  uint32_t readDouble(double& dub) {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+        subclass_ + " does not support reading (yet).");
+  }
+
+  uint32_t readString(std::string& str) {
+    throw TProtocolException(TProtocolException::NOT_IMPLEMENTED,
+        subclass_ + " does not support reading (yet).");
+  }
+
+
+ private:
+  std::string subclass_;
+};
+
+}}} // facebook::thrift::protocol
+
+#endif // #ifndef _THRIFT_PROTOCOL_TBINARYPROTOCOL_H_

+ 353 - 0
src/contrib/hive/metastore/include/thrift/protocol/TProtocol.h

@@ -0,0 +1,353 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#ifndef _THRIFT_PROTOCOL_TPROTOCOL_H_
+#define _THRIFT_PROTOCOL_TPROTOCOL_H_ 1
+
+#include <transport/TTransport.h>
+#include <protocol/TProtocolException.h>
+
+#include <boost/shared_ptr.hpp>
+
+#include <netinet/in.h>
+#include <sys/types.h>
+#include <string>
+#include <map>
+
+namespace facebook { namespace thrift { namespace protocol { 
+
+using facebook::thrift::transport::TTransport;
+
+#ifdef HAVE_ENDIAN_H
+#include <endian.h>
+#endif
+
+#ifndef __BYTE_ORDER
+# if defined(BYTE_ORDER) && defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN)
+#  define __BYTE_ORDER BYTE_ORDER
+#  define __LITTLE_ENDIAN LITTLE_ENDIAN
+#  define __BIG_ENDIAN BIG_ENDIAN
+# else
+#  error "Cannot determine endianness"
+# endif
+#endif
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+# define ntohll(n) (n)
+# define htonll(n) (n)
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
+# if defined(__GNUC__) && defined(__GLIBC__)
+#  include <byteswap.h>
+#  define ntohll(n) bswap_64(n)
+#  define htonll(n) bswap_64(n)
+# else /* GNUC & GLIBC */
+#  define ntohll(n) ( (((unsigned long long)ntohl(n)) << 32) + ntohl(n >> 32) )
+#  define htonll(n) ( (((unsigned long long)htonl(n)) << 32) + htonl(n >> 32) )
+# endif /* GNUC & GLIBC */
+#else /* __BYTE_ORDER */
+# error "Can't define htonll or ntohll!"
+#endif
+
+/**
+ * Enumerated definition of the types that the Thrift protocol supports.
+ * Take special note of the T_END type which is used specifically to mark
+ * the end of a sequence of fields.
+ */
+enum TType {
+  T_STOP       = 0,
+  T_VOID       = 1,
+  T_BOOL       = 2,
+  T_BYTE       = 3,
+  T_I08        = 3,
+  T_I16        = 6,
+  T_I32        = 8,
+  T_U64        = 9,
+  T_I64        = 10,
+  T_DOUBLE     = 4,
+  T_STRING     = 11,
+  T_UTF7       = 11,
+  T_STRUCT     = 12,
+  T_MAP        = 13,
+  T_SET        = 14,
+  T_LIST       = 15,
+  T_UTF8       = 16,
+  T_UTF16      = 17
+};
+
+/**
+ * Enumerated definition of the message types that the Thrift protocol
+ * supports.
+ */
+enum TMessageType {
+  T_CALL       = 1,
+  T_REPLY      = 2,
+  T_EXCEPTION  = 3
+};
+
+/**
+ * Abstract class for a thrift protocol driver. These are all the methods that
+ * a protocol must implement. Essentially, there must be some way of reading
+ * and writing all the base types, plus a mechanism for writing out structs
+ * with indexed fields.
+ *
+ * TProtocol objects should not be shared across multiple encoding contexts,
+ * as they may need to maintain internal state in some protocols (i.e. XML).
+ * Note that is is acceptable for the TProtocol module to do its own internal
+ * buffered reads/writes to the underlying TTransport where appropriate (i.e.
+ * when parsing an input XML stream, reading should be batched rather than
+ * looking ahead character by character for a close tag).
+ *
+ * @author Mark Slee <mcslee@facebook.com>
+ */
+class TProtocol {
+ public:
+  virtual ~TProtocol() {}
+
+  /**
+   * Writing functions.
+   */
+
+  virtual uint32_t writeMessageBegin(const std::string& name,
+                                     const TMessageType messageType,
+                                     const int32_t seqid) = 0;
+
+  virtual uint32_t writeMessageEnd() = 0;
+
+
+  virtual uint32_t writeStructBegin(const std::string& name) = 0;
+  
+  virtual uint32_t writeStructEnd() = 0;
+  
+  virtual uint32_t writeFieldBegin(const std::string& name,
+                                   const TType fieldType,
+                                   const int16_t fieldId) = 0;
+
+  virtual uint32_t writeFieldEnd() = 0;
+
+  virtual uint32_t writeFieldStop() = 0;
+                                      
+  virtual uint32_t writeMapBegin(const TType keyType,
+                                 const TType valType,
+                                 const uint32_t size) = 0;
+
+  virtual uint32_t writeMapEnd() = 0;
+  
+  virtual uint32_t writeListBegin(const TType elemType,
+                                  const uint32_t size) = 0;
+
+  virtual uint32_t writeListEnd() = 0;
+
+  virtual uint32_t writeSetBegin(const TType elemType,
+                                 const uint32_t size) = 0;
+
+  virtual uint32_t writeSetEnd() = 0;
+
+  virtual uint32_t writeBool(const bool value) = 0;
+
+  virtual uint32_t writeByte(const int8_t byte) = 0;
+
+  virtual uint32_t writeI16(const int16_t i16) = 0;
+
+  virtual uint32_t writeI32(const int32_t i32) = 0;
+
+  virtual uint32_t writeI64(const int64_t i64) = 0;
+
+  virtual uint32_t writeDouble(const double dub) = 0;
+
+  virtual uint32_t writeString(const std::string& str) = 0;
+
+  /**
+   * Reading functions
+   */
+
+  virtual uint32_t readMessageBegin(std::string& name,
+                                    TMessageType& messageType,
+                                    int32_t& seqid) = 0;
+  
+  virtual uint32_t readMessageEnd() = 0;
+
+  virtual uint32_t readStructBegin(std::string& name) = 0;
+
+  virtual uint32_t readStructEnd() = 0;
+
+  virtual uint32_t readFieldBegin(std::string& name,
+                                  TType& fieldType,
+                                  int16_t& fieldId) = 0;
+  
+  virtual uint32_t readFieldEnd() = 0;
+ 
+  virtual uint32_t readMapBegin(TType& keyType,
+                                TType& valType,
+                                uint32_t& size) = 0;
+
+  virtual uint32_t readMapEnd() = 0;
+
+  virtual uint32_t readListBegin(TType& elemType,
+                                 uint32_t& size) = 0;
+
+  virtual uint32_t readListEnd() = 0;
+
+  virtual uint32_t readSetBegin(TType& elemType,
+                                uint32_t& size) = 0;
+
+  virtual uint32_t readSetEnd() = 0;
+
+  virtual uint32_t readBool(bool& value) = 0;
+
+  virtual uint32_t readByte(int8_t& byte) = 0;
+
+  virtual uint32_t readI16(int16_t& i16) = 0;
+
+  virtual uint32_t readI32(int32_t& i32) = 0;
+
+  virtual uint32_t readI64(int64_t& i64) = 0;
+
+  virtual uint32_t readDouble(double& dub) = 0;
+
+  virtual uint32_t readString(std::string& str) = 0;
+
+  /**
+   * Method to arbitrarily skip over data.
+   */
+  uint32_t skip(TType type) {
+    switch (type) {
+    case T_BOOL:
+      {
+        bool boolv;
+        return readBool(boolv);
+      }
+    case T_BYTE:
+      {
+        int8_t bytev;
+        return readByte(bytev);
+      }
+    case T_I16:
+      {
+        int16_t i16;
+        return readI16(i16);
+      }
+    case T_I32:
+      {
+        int32_t i32;
+        return readI32(i32);
+      }
+    case T_I64:
+      {
+        int64_t i64;
+        return readI64(i64);
+      }
+    case T_DOUBLE:
+      {
+        double dub;
+        return readDouble(dub);
+      }
+    case T_STRING:
+      {
+        std::string str;
+        return readString(str);
+      }
+    case T_STRUCT:
+      {
+        uint32_t result = 0;
+        std::string name;
+        int16_t fid;
+        TType ftype;
+        result += readStructBegin(name);
+        while (true) {
+          result += readFieldBegin(name, ftype, fid);
+          if (ftype == T_STOP) {
+            break;
+          }
+          result += skip(ftype);
+          result += readFieldEnd();
+        }
+        result += readStructEnd();
+        return result;
+      }
+    case T_MAP:
+      {
+        uint32_t result = 0;
+        TType keyType;
+        TType valType;
+        uint32_t i, size;
+        result += readMapBegin(keyType, valType, size);
+        for (i = 0; i < size; i++) {
+          result += skip(keyType);
+          result += skip(valType);
+        }
+        result += readMapEnd();
+        return result;
+      }
+    case T_SET:
+      {
+        uint32_t result = 0;
+        TType elemType;
+        uint32_t i, size;
+        result += readSetBegin(elemType, size);
+        for (i = 0; i < size; i++) {
+          result += skip(elemType);
+        }
+        result += readSetEnd();
+        return result;
+      }
+    case T_LIST:
+      {
+        uint32_t result = 0;
+        TType elemType;
+        uint32_t i, size;
+        result += readListBegin(elemType, size);
+        for (i = 0; i < size; i++) {
+          result += skip(elemType);
+        }
+        result += readListEnd();
+        return result;
+      }
+    default:
+      return 0;
+    }
+  }
+
+  inline boost::shared_ptr<TTransport> getTransport() {
+    return ptrans_;
+  }
+
+  // TODO: remove these two calls, they are for backwards
+  // compatibility
+  inline boost::shared_ptr<TTransport> getInputTransport() {
+    return ptrans_;
+  }
+  inline boost::shared_ptr<TTransport> getOutputTransport() {
+    return ptrans_;
+  }
+
+ protected:
+  TProtocol(boost::shared_ptr<TTransport> ptrans):
+    ptrans_(ptrans) {
+    trans_ = ptrans.get();
+  }
+    
+  boost::shared_ptr<TTransport> ptrans_;
+  TTransport* trans_;
+
+ private:
+  TProtocol() {}
+};
+
+/**
+ * Constructs input and output protocol objects given transports.
+ */
+class TProtocolFactory {
+ public:
+  TProtocolFactory() {}
+
+  virtual ~TProtocolFactory() {}
+
+  virtual boost::shared_ptr<TProtocol> getProtocol(boost::shared_ptr<TTransport> trans) = 0;
+};
+
+}}} // facebook::thrift::protocol
+
+#endif // #define _THRIFT_PROTOCOL_TPROTOCOL_H_ 1

+ 93 - 0
src/contrib/hive/metastore/include/thrift/protocol/TProtocolException.h

@@ -0,0 +1,93 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#ifndef _THRIFT_PROTOCOL_TPROTOCOLEXCEPTION_H_
+#define _THRIFT_PROTOCOL_TPROTOCOLEXCEPTION_H_ 1
+
+#include <boost/lexical_cast.hpp>
+#include <string>
+
+namespace facebook { namespace thrift { namespace protocol { 
+
+/**
+ * Class to encapsulate all the possible types of protocol errors that may
+ * occur in various protocol systems. This provides a sort of generic
+ * wrapper around the shitty UNIX E_ error codes that lets a common code
+ * base of error handling to be used for various types of protocols, i.e.
+ * pipes etc.
+ *
+ * @author Mark Slee <mcslee@facebook.com>
+ */
+class TProtocolException : public facebook::thrift::TException {
+ public:
+
+  /**
+   * Error codes for the various types of exceptions.
+   */
+  enum TProtocolExceptionType {
+    UNKNOWN = 0,
+    INVALID_DATA = 1,
+    NEGATIVE_SIZE = 2,
+    SIZE_LIMIT = 3,
+    BAD_VERSION = 4,
+    NOT_IMPLEMENTED = 5,
+  };
+
+  TProtocolException() :
+    facebook::thrift::TException(),
+    type_(UNKNOWN) {}
+
+  TProtocolException(TProtocolExceptionType type) :
+    facebook::thrift::TException(), 
+    type_(type) {}
+
+  TProtocolException(const std::string& message) :
+    facebook::thrift::TException(message),
+    type_(UNKNOWN) {}
+
+  TProtocolException(TProtocolExceptionType type, const std::string& message) :
+    facebook::thrift::TException(message),
+    type_(type) {}
+
+  virtual ~TProtocolException() throw() {}
+
+  /**
+   * Returns an error code that provides information about the type of error
+   * that has occurred.
+   *
+   * @return Error code
+   */
+  TProtocolExceptionType getType() {
+    return type_;
+  }
+
+  virtual const char* what() const throw() {
+    if (message_.empty()) {
+      switch (type_) {
+        case UNKNOWN         : return "TProtocolException: Unknown protocol exception";
+        case INVALID_DATA    : return "TProtocolException: Invalid data";
+        case NEGATIVE_SIZE   : return "TProtocolException: Negative size";
+        case SIZE_LIMIT      : return "TProtocolException: Exceeded size limit";
+        case BAD_VERSION     : return "TProtocolException: Invalid version";
+        case NOT_IMPLEMENTED : return "TProtocolException: Not implemented";
+        default              : return "TProtocolException: (Invalid exception type)";
+      }
+    } else {
+      return message_.c_str();
+    }
+  }
+
+ protected:
+  /** 
+   * Error code
+   */
+  TProtocolExceptionType type_;
+ 
+};
+
+}}} // facebook::thrift::protocol
+
+#endif // #ifndef _THRIFT_PROTOCOL_TPROTOCOLEXCEPTION_H_

+ 285 - 0
src/contrib/hive/metastore/include/thrift/reflection_limited_types.h

@@ -0,0 +1,285 @@
+/**
+ * Autogenerated by Thrift
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ */
+#ifndef reflection_limited_TYPES_H
+#define reflection_limited_TYPES_H
+
+#include <Thrift.h>
+#include <reflection_limited_types.h>
+#include <protocol/TProtocol.h>
+#include <transport/TTransport.h>
+
+
+
+namespace facebook { namespace thrift { namespace reflection { namespace limited {
+
+enum TTypeTag {
+  T_VOID = 1,
+  T_BOOL = 2,
+  T_BYTE = 3,
+  T_I16 = 6,
+  T_I32 = 8,
+  T_I64 = 10,
+  T_DOUBLE = 4,
+  T_STRING = 11,
+  T_STRUCT = 12,
+  T_MAP = 13,
+  T_SET = 14,
+  T_LIST = 15,
+  T_ENUM = 101,
+  T_NOT_REFLECTED = 102
+};
+
+class SimpleType {
+ public:
+
+  static char* ascii_fingerprint; // = "19B5240589E680301A7E32DF3971EFBE";
+  static char binary_fingerprint[16]; // = {0x19,0xB5,0x24,0x05,0x89,0xE6,0x80,0x30,0x1A,0x7E,0x32,0xDF,0x39,0x71,0xEF,0xBE};
+
+  SimpleType() : name("") {
+  }
+
+  virtual ~SimpleType() throw() {}
+
+  TTypeTag ttype;
+  std::string name;
+
+  struct __isset {
+    __isset() : ttype(false), name(false) {}
+    bool ttype;
+    bool name;
+  } __isset;
+
+  bool operator == (const SimpleType & rhs) const
+  {
+    if (!(ttype == rhs.ttype))
+      return false;
+    if (!(name == rhs.name))
+      return false;
+    return true;
+  }
+  bool operator != (const SimpleType &rhs) const {
+    return !(*this == rhs);
+  }
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class ContainerType {
+ public:
+
+  static char* ascii_fingerprint; // = "654FA6EFFF8242F4C2A604B970686634";
+  static char binary_fingerprint[16]; // = {0x65,0x4F,0xA6,0xEF,0xFF,0x82,0x42,0xF4,0xC2,0xA6,0x04,0xB9,0x70,0x68,0x66,0x34};
+
+  ContainerType() {
+  }
+
+  virtual ~ContainerType() throw() {}
+
+  TTypeTag ttype;
+  SimpleType subtype1;
+  SimpleType subtype2;
+
+  struct __isset {
+    __isset() : ttype(false), subtype1(false), subtype2(false) {}
+    bool ttype;
+    bool subtype1;
+    bool subtype2;
+  } __isset;
+
+  bool operator == (const ContainerType & rhs) const
+  {
+    if (!(ttype == rhs.ttype))
+      return false;
+    if (!(subtype1 == rhs.subtype1))
+      return false;
+    if (__isset.subtype2 != rhs.__isset.subtype2)
+      return false;
+    else if (__isset.subtype2 && !(subtype2 == rhs.subtype2))
+      return false;
+    return true;
+  }
+  bool operator != (const ContainerType &rhs) const {
+    return !(*this == rhs);
+  }
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class ThriftType {
+ public:
+
+  static char* ascii_fingerprint; // = "76BC1CC759001D7D85FEE75C4F183062";
+  static char binary_fingerprint[16]; // = {0x76,0xBC,0x1C,0xC7,0x59,0x00,0x1D,0x7D,0x85,0xFE,0xE7,0x5C,0x4F,0x18,0x30,0x62};
+
+  ThriftType() : is_container(0) {
+  }
+
+  virtual ~ThriftType() throw() {}
+
+  bool is_container;
+  SimpleType simple_type;
+  ContainerType container_type;
+
+  struct __isset {
+    __isset() : is_container(false), simple_type(false), container_type(false) {}
+    bool is_container;
+    bool simple_type;
+    bool container_type;
+  } __isset;
+
+  bool operator == (const ThriftType & rhs) const
+  {
+    if (!(is_container == rhs.is_container))
+      return false;
+    if (__isset.simple_type != rhs.__isset.simple_type)
+      return false;
+    else if (__isset.simple_type && !(simple_type == rhs.simple_type))
+      return false;
+    if (__isset.container_type != rhs.__isset.container_type)
+      return false;
+    else if (__isset.container_type && !(container_type == rhs.container_type))
+      return false;
+    return true;
+  }
+  bool operator != (const ThriftType &rhs) const {
+    return !(*this == rhs);
+  }
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class Argument {
+ public:
+
+  static char* ascii_fingerprint; // = "8C45506BE0EFBB22FB19FA40DDCECB3F";
+  static char binary_fingerprint[16]; // = {0x8C,0x45,0x50,0x6B,0xE0,0xEF,0xBB,0x22,0xFB,0x19,0xFA,0x40,0xDD,0xCE,0xCB,0x3F};
+
+  Argument() : key(0), name("") {
+  }
+
+  virtual ~Argument() throw() {}
+
+  int16_t key;
+  std::string name;
+  ThriftType type;
+
+  struct __isset {
+    __isset() : key(false), name(false), type(false) {}
+    bool key;
+    bool name;
+    bool type;
+  } __isset;
+
+  bool operator == (const Argument & rhs) const
+  {
+    if (!(key == rhs.key))
+      return false;
+    if (!(name == rhs.name))
+      return false;
+    if (!(type == rhs.type))
+      return false;
+    return true;
+  }
+  bool operator != (const Argument &rhs) const {
+    return !(*this == rhs);
+  }
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class Method {
+ public:
+
+  static char* ascii_fingerprint; // = "E6573428C492D24C84A19432D39A17B0";
+  static char binary_fingerprint[16]; // = {0xE6,0x57,0x34,0x28,0xC4,0x92,0xD2,0x4C,0x84,0xA1,0x94,0x32,0xD3,0x9A,0x17,0xB0};
+
+  Method() : name("") {
+  }
+
+  virtual ~Method() throw() {}
+
+  std::string name;
+  ThriftType return_type;
+  std::vector<Argument>  arguments;
+
+  struct __isset {
+    __isset() : name(false), return_type(false), arguments(false) {}
+    bool name;
+    bool return_type;
+    bool arguments;
+  } __isset;
+
+  bool operator == (const Method & rhs) const
+  {
+    if (!(name == rhs.name))
+      return false;
+    if (!(return_type == rhs.return_type))
+      return false;
+    if (!(arguments == rhs.arguments))
+      return false;
+    return true;
+  }
+  bool operator != (const Method &rhs) const {
+    return !(*this == rhs);
+  }
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+class Service {
+ public:
+
+  static char* ascii_fingerprint; // = "4673B0777B701D9B02A7A74CEC7908A7";
+  static char binary_fingerprint[16]; // = {0x46,0x73,0xB0,0x77,0x7B,0x70,0x1D,0x9B,0x02,0xA7,0xA7,0x4C,0xEC,0x79,0x08,0xA7};
+
+  Service() : name(""), fully_reflected(0) {
+  }
+
+  virtual ~Service() throw() {}
+
+  std::string name;
+  std::vector<Method>  methods;
+  bool fully_reflected;
+
+  struct __isset {
+    __isset() : name(false), methods(false), fully_reflected(false) {}
+    bool name;
+    bool methods;
+    bool fully_reflected;
+  } __isset;
+
+  bool operator == (const Service & rhs) const
+  {
+    if (!(name == rhs.name))
+      return false;
+    if (!(methods == rhs.methods))
+      return false;
+    if (!(fully_reflected == rhs.fully_reflected))
+      return false;
+    return true;
+  }
+  bool operator != (const Service &rhs) const {
+    return !(*this == rhs);
+  }
+
+  uint32_t read(facebook::thrift::protocol::TProtocol* iprot);
+  uint32_t write(facebook::thrift::protocol::TProtocol* oprot) const;
+
+};
+
+}}}} // namespace
+
+#endif

+ 331 - 0
src/contrib/hive/metastore/include/thrift/server/TNonblockingServer.h

@@ -0,0 +1,331 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#ifndef _THRIFT_SERVER_TNONBLOCKINGSERVER_H_
+#define _THRIFT_SERVER_TNONBLOCKINGSERVER_H_ 1
+
+#include <Thrift.h>
+#include <server/TServer.h>
+#include <transport/TTransportUtils.h>
+#include <concurrency/ThreadManager.h>
+#include <stack>
+#include <event.h>
+
+namespace facebook { namespace thrift { namespace server {
+
+using facebook::thrift::transport::TMemoryBuffer;
+using facebook::thrift::protocol::TProtocol;
+using facebook::thrift::concurrency::Runnable;
+using facebook::thrift::concurrency::ThreadManager;
+
+// Forward declaration of class
+class TConnection;
+
+/**
+ * This is a non-blocking server in C++ for high performance that operates a
+ * single IO thread. It assumes that all incoming requests are framed with a
+ * 4 byte length indicator and writes out responses using the same framing.
+ *
+ * It does not use the TServerTransport framework, but rather has socket
+ * operations hardcoded for use with select.
+ *
+ * @author Mark Slee <mcslee@facebook.com>
+ */
+class TNonblockingServer : public TServer {
+ private:
+
+  // Listen backlog
+  static const int LISTEN_BACKLOG = 1024;
+
+  // Server socket file descriptor
+  int serverSocket_;
+
+  // Port server runs on
+  int port_;
+
+  // Whether to frame responses
+  bool frameResponses_;
+
+  // For processing via thread pool, may be NULL
+  boost::shared_ptr<ThreadManager> threadManager_;
+
+  // Is thread pool processing?
+  bool threadPoolProcessing_;
+
+  // The event base for libevent
+  event_base* eventBase_;
+
+  // Event struct, for use with eventBase_
+  struct event serverEvent_;
+
+  /**
+   * This is a stack of all the objects that have been created but that
+   * are NOT currently in use. When we close a connection, we place it on this
+   * stack so that the object can be reused later, rather than freeing the
+   * memory and reallocating a new object later.
+   */
+  std::stack<TConnection*> connectionStack_;
+
+  void handleEvent(int fd, short which);
+
+ public:
+  TNonblockingServer(boost::shared_ptr<TProcessor> processor,
+                     int port) :
+    TServer(processor),
+    serverSocket_(-1),
+    port_(port),
+    frameResponses_(true),
+    threadPoolProcessing_(false),
+    eventBase_(NULL) {}
+
+  TNonblockingServer(boost::shared_ptr<TProcessor> processor,
+                     boost::shared_ptr<TProtocolFactory> protocolFactory,
+                     int port,
+                     boost::shared_ptr<ThreadManager> threadManager = boost::shared_ptr<ThreadManager>()) :
+    TServer(processor),
+    serverSocket_(-1),
+    port_(port),
+    frameResponses_(true),
+    threadManager_(threadManager),
+    eventBase_(NULL) {
+    setInputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
+    setOutputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
+    setInputProtocolFactory(protocolFactory);
+    setOutputProtocolFactory(protocolFactory);
+    setThreadManager(threadManager);
+  }
+
+  TNonblockingServer(boost::shared_ptr<TProcessor> processor,
+                     boost::shared_ptr<TTransportFactory> inputTransportFactory,
+                     boost::shared_ptr<TTransportFactory> outputTransportFactory,
+                     boost::shared_ptr<TProtocolFactory> inputProtocolFactory,
+                     boost::shared_ptr<TProtocolFactory> outputProtocolFactory,
+                     int port,
+                     boost::shared_ptr<ThreadManager> threadManager = boost::shared_ptr<ThreadManager>()) :
+    TServer(processor),
+    serverSocket_(0),
+    port_(port),
+    frameResponses_(true),
+    threadManager_(threadManager),
+    eventBase_(NULL) {
+    setInputTransportFactory(inputTransportFactory);
+    setOutputTransportFactory(outputTransportFactory);
+    setInputProtocolFactory(inputProtocolFactory);
+    setOutputProtocolFactory(outputProtocolFactory);
+    setThreadManager(threadManager);
+  }
+
+  ~TNonblockingServer() {}
+
+  void setThreadManager(boost::shared_ptr<ThreadManager> threadManager) {
+    threadManager_ = threadManager;
+    threadPoolProcessing_ = (threadManager != NULL);
+  }
+
+  bool isThreadPoolProcessing() const {
+    return threadPoolProcessing_;
+  }
+
+  void addTask(boost::shared_ptr<Runnable> task) {
+    threadManager_->add(task);
+  }
+
+  void setFrameResponses(bool frameResponses) {
+    frameResponses_ = frameResponses;
+  }
+
+  bool getFrameResponses() const {
+    return frameResponses_;
+  }
+
+  event_base* getEventBase() const {
+    return eventBase_;
+  }
+
+  TConnection* createConnection(int socket, short flags);
+
+  void returnConnection(TConnection* connection);
+
+  static void eventHandler(int fd, short which, void* v) {
+    ((TNonblockingServer*)v)->handleEvent(fd, which);
+  }
+
+  void listenSocket();
+
+  void listenSocket(int fd);
+
+  void registerEvents(event_base* base);
+
+  void serve();
+
+};
+
+/**
+ * Two states for sockets, recv and send mode
+ */
+enum TSocketState {
+  SOCKET_RECV,
+  SOCKET_SEND
+};
+
+/**
+ * Four states for the nonblocking servr:
+ *  1) initialize
+ *  2) read 4 byte frame size
+ *  3) read frame of data
+ *  4) send back data (if any)
+ */
+enum TAppState {
+  APP_INIT,
+  APP_READ_FRAME_SIZE,
+  APP_READ_REQUEST,
+  APP_WAIT_TASK,
+  APP_SEND_FRAME_SIZE,
+  APP_SEND_RESULT
+};
+
+/**
+ * Represents a connection that is handled via libevent. This connection
+ * essentially encapsulates a socket that has some associated libevent state.
+ */
+class TConnection {
+ private:
+
+  class Task;
+
+  // Server handle
+  TNonblockingServer* server_;
+
+  // Socket handle
+  int socket_;
+
+  // Libevent object
+  struct event event_;
+
+  // Libevent flags
+  short eventFlags_;
+
+  // Socket mode
+  TSocketState socketState_;
+
+  // Application state
+  TAppState appState_;
+
+  // How much data needed to read
+  uint32_t readWant_;
+
+  // Where in the read buffer are we
+  uint32_t readBufferPos_;
+
+  // Read buffer
+  uint8_t* readBuffer_;
+
+  // Read buffer size
+  uint32_t readBufferSize_;
+
+  // Write buffer
+  uint8_t* writeBuffer_;
+
+  // Write buffer size
+  uint32_t writeBufferSize_;
+
+  // How far through writing are we?
+  uint32_t writeBufferPos_;
+
+  // Frame size
+  int32_t frameSize_;
+
+  // Task handle
+  int taskHandle_;
+
+  // Task event
+  struct event taskEvent_;
+
+  // Transport to read from
+  boost::shared_ptr<TMemoryBuffer> inputTransport_;
+
+  // Transport that processor writes to
+  boost::shared_ptr<TMemoryBuffer> outputTransport_;
+
+  // extra transport generated by transport factory (e.g. BufferedRouterTransport)
+  boost::shared_ptr<TTransport> factoryInputTransport_;
+  boost::shared_ptr<TTransport> factoryOutputTransport_;
+
+  // Protocol decoder
+  boost::shared_ptr<TProtocol> inputProtocol_;
+
+  // Protocol encoder
+  boost::shared_ptr<TProtocol> outputProtocol_;
+
+  // Go into read mode
+  void setRead() {
+    setFlags(EV_READ | EV_PERSIST);
+  }
+
+  // Go into write mode
+  void setWrite() {
+    setFlags(EV_WRITE | EV_PERSIST);
+  }
+
+  // Set socket idle
+  void setIdle() {
+    setFlags(0);
+  }
+
+  // Set event flags
+  void setFlags(short eventFlags);
+
+  // Libevent handlers
+  void workSocket();
+
+  // Close this client and reset
+  void close();
+
+ public:
+
+  // Constructor
+  TConnection(int socket, short eventFlags, TNonblockingServer *s) {
+    readBuffer_ = (uint8_t*)malloc(1024);
+    if (readBuffer_ == NULL) {
+      throw new facebook::thrift::TException("Out of memory.");
+    }
+    readBufferSize_ = 1024;
+
+    // Allocate input and output tranpsorts
+    // these only need to be allocated once per TConnection (they don't need to be
+    // reallocated on init() call)
+    inputTransport_ = boost::shared_ptr<TMemoryBuffer>(new TMemoryBuffer(readBuffer_, readBufferSize_));
+    outputTransport_ = boost::shared_ptr<TMemoryBuffer>(new TMemoryBuffer());
+
+    init(socket, eventFlags, s);
+  }
+
+  // Initialize
+  void init(int socket, short eventFlags, TNonblockingServer *s);
+
+  // Transition into a new state
+  void transition();
+
+  // Handler wrapper
+  static void eventHandler(int fd, short which, void* v) {
+    assert(fd == ((TConnection*)v)->socket_);
+    ((TConnection*)v)->workSocket();
+  }
+
+  // Handler wrapper for task block
+  static void taskHandler(int fd, short which, void* v) {
+    assert(fd == ((TConnection*)v)->taskHandle_);
+    if (-1 == ::close(((TConnection*)v)->taskHandle_)) {
+      GlobalOutput("TConnection::taskHandler close handle failed, resource leak");
+    }
+    ((TConnection*)v)->transition();
+  }
+
+};
+
+}}} // facebook::thrift::server
+
+#endif // #ifndef _THRIFT_SERVER_TSIMPLESERVER_H_

+ 193 - 0
src/contrib/hive/metastore/include/thrift/server/TServer.h

@@ -0,0 +1,193 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#ifndef _THRIFT_SERVER_TSERVER_H_
+#define _THRIFT_SERVER_TSERVER_H_ 1
+
+#include <TProcessor.h>
+#include <transport/TServerTransport.h>
+#include <protocol/TBinaryProtocol.h>
+#include <concurrency/Thread.h>
+
+#include <boost/shared_ptr.hpp>
+
+namespace facebook { namespace thrift { namespace server {
+
+using facebook::thrift::TProcessor;
+using facebook::thrift::protocol::TBinaryProtocolFactory;
+using facebook::thrift::protocol::TProtocol;
+using facebook::thrift::protocol::TProtocolFactory;
+using facebook::thrift::transport::TServerTransport;
+using facebook::thrift::transport::TTransport;
+using facebook::thrift::transport::TTransportFactory;
+
+/**
+ * Virtual interface class that can handle events from the server core. To
+ * use this you should subclass it and implement the methods that you care
+ * about. Your subclass can also store local data that you may care about,
+ * such as additional "arguments" to these methods (stored in the object
+ * instance's state).
+ */
+class TServerEventHandler {
+ public:
+
+  virtual ~TServerEventHandler() {}
+
+  /**
+   * Called before the server begins.
+   */
+  virtual void preServe() {}
+
+  /**
+   * Called when a new client has connected and is about to being processing.
+   */
+  virtual void clientBegin(boost::shared_ptr<TProtocol> input,
+                           boost::shared_ptr<TProtocol> output) {}
+
+  /**
+   * Called when a client has finished making requests.
+   */
+  virtual void clientEnd(boost::shared_ptr<TProtocol> input,
+                         boost::shared_ptr<TProtocol> output) {}
+
+ protected:
+
+  /**
+   * Prevent direct instantiation.
+   */
+  TServerEventHandler() {}
+
+};
+
+/**
+ * Thrift server.
+ *
+ * @author Mark Slee <mcslee@facebook.com>
+ */
+class TServer : public concurrency::Runnable {
+ public:
+
+  virtual ~TServer() {}
+
+  virtual void serve() = 0;
+
+  virtual void stop() {}
+
+  // Allows running the server as a Runnable thread
+  virtual void run() {
+    serve();
+  }
+
+  boost::shared_ptr<TProcessor> getProcessor() {
+    return processor_;
+  }
+
+  boost::shared_ptr<TServerTransport> getServerTransport() {
+    return serverTransport_;
+  }
+
+  boost::shared_ptr<TTransportFactory> getInputTransportFactory() {
+    return inputTransportFactory_;
+  }
+
+  boost::shared_ptr<TTransportFactory> getOutputTransportFactory() {
+    return outputTransportFactory_;
+  }
+
+  boost::shared_ptr<TProtocolFactory> getInputProtocolFactory() {
+    return inputProtocolFactory_;
+  }
+
+  boost::shared_ptr<TProtocolFactory> getOutputProtocolFactory() {
+    return outputProtocolFactory_;
+  }
+
+  boost::shared_ptr<TServerEventHandler> getEventHandler() {
+    return eventHandler_;
+  }
+
+protected:
+  TServer(boost::shared_ptr<TProcessor> processor):
+    processor_(processor) {
+    setInputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
+    setOutputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
+    setInputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
+    setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
+  }
+
+  TServer(boost::shared_ptr<TProcessor> processor,
+          boost::shared_ptr<TServerTransport> serverTransport):
+    processor_(processor),
+    serverTransport_(serverTransport) {
+    setInputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
+    setOutputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory()));
+    setInputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
+    setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory()));
+  }
+
+  TServer(boost::shared_ptr<TProcessor> processor,
+          boost::shared_ptr<TServerTransport> serverTransport,
+          boost::shared_ptr<TTransportFactory> transportFactory,
+          boost::shared_ptr<TProtocolFactory> protocolFactory):
+    processor_(processor),
+    serverTransport_(serverTransport),
+    inputTransportFactory_(transportFactory),
+    outputTransportFactory_(transportFactory),
+    inputProtocolFactory_(protocolFactory),
+    outputProtocolFactory_(protocolFactory) {}
+
+  TServer(boost::shared_ptr<TProcessor> processor,
+          boost::shared_ptr<TServerTransport> serverTransport,
+          boost::shared_ptr<TTransportFactory> inputTransportFactory,
+          boost::shared_ptr<TTransportFactory> outputTransportFactory,
+          boost::shared_ptr<TProtocolFactory> inputProtocolFactory,
+          boost::shared_ptr<TProtocolFactory> outputProtocolFactory):
+    processor_(processor),
+    serverTransport_(serverTransport),
+    inputTransportFactory_(inputTransportFactory),
+    outputTransportFactory_(outputTransportFactory),
+    inputProtocolFactory_(inputProtocolFactory),
+    outputProtocolFactory_(outputProtocolFactory) {}
+
+
+  // Class variables
+  boost::shared_ptr<TProcessor> processor_;
+  boost::shared_ptr<TServerTransport> serverTransport_;
+
+  boost::shared_ptr<TTransportFactory> inputTransportFactory_;
+  boost::shared_ptr<TTransportFactory> outputTransportFactory_;
+
+  boost::shared_ptr<TProtocolFactory> inputProtocolFactory_;
+  boost::shared_ptr<TProtocolFactory> outputProtocolFactory_;
+
+  boost::shared_ptr<TServerEventHandler> eventHandler_;
+
+public:
+  void setInputTransportFactory(boost::shared_ptr<TTransportFactory> inputTransportFactory) {
+    inputTransportFactory_ = inputTransportFactory;
+  }
+
+  void setOutputTransportFactory(boost::shared_ptr<TTransportFactory> outputTransportFactory) {
+    outputTransportFactory_ = outputTransportFactory;
+  }
+
+  void setInputProtocolFactory(boost::shared_ptr<TProtocolFactory> inputProtocolFactory) {
+    inputProtocolFactory_ = inputProtocolFactory;
+  }
+
+  void setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory> outputProtocolFactory) {
+    outputProtocolFactory_ = outputProtocolFactory;
+  }
+
+  void setServerEventHandler(boost::shared_ptr<TServerEventHandler> eventHandler) {
+    eventHandler_ = eventHandler;
+  }
+
+};
+
+}}} // facebook::thrift::server
+
+#endif // #ifndef _THRIFT_SERVER_TSERVER_H_

+ 58 - 0
src/contrib/hive/metastore/include/thrift/server/TSimpleServer.h

@@ -0,0 +1,58 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#ifndef _THRIFT_SERVER_TSIMPLESERVER_H_
+#define _THRIFT_SERVER_TSIMPLESERVER_H_ 1
+
+#include "server/TServer.h"
+#include "transport/TServerTransport.h"
+
+namespace facebook { namespace thrift { namespace server {
+
+/**
+ * This is the most basic simple server. It is single-threaded and runs a
+ * continuous loop of accepting a single connection, processing requests on
+ * that connection until it closes, and then repeating. It is a good example
+ * of how to extend the TServer interface.
+ *
+ * @author Mark Slee <mcslee@facebook.com>
+ */
+class TSimpleServer : public TServer {
+ public:
+  TSimpleServer(boost::shared_ptr<TProcessor> processor,
+                boost::shared_ptr<TServerTransport> serverTransport,
+                boost::shared_ptr<TTransportFactory> transportFactory,
+                boost::shared_ptr<TProtocolFactory> protocolFactory) :
+    TServer(processor, serverTransport, transportFactory, protocolFactory),
+    stop_(false) {}
+
+  TSimpleServer(boost::shared_ptr<TProcessor> processor,
+                boost::shared_ptr<TServerTransport> serverTransport,
+                boost::shared_ptr<TTransportFactory> inputTransportFactory,
+                boost::shared_ptr<TTransportFactory> outputTransportFactory,
+                boost::shared_ptr<TProtocolFactory> inputProtocolFactory,
+                boost::shared_ptr<TProtocolFactory> outputProtocolFactory):
+    TServer(processor, serverTransport,
+            inputTransportFactory, outputTransportFactory,
+            inputProtocolFactory, outputProtocolFactory),
+    stop_(false) {}
+
+  ~TSimpleServer() {}
+
+  void serve();
+
+  void stop() {
+    stop_ = true;
+  }
+
+ protected:
+  bool stop_;
+
+};
+
+}}} // facebook::thrift::server
+
+#endif // #ifndef _THRIFT_SERVER_TSIMPLESERVER_H_

+ 66 - 0
src/contrib/hive/metastore/include/thrift/server/TThreadPoolServer.h

@@ -0,0 +1,66 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#ifndef _THRIFT_SERVER_TTHREADPOOLSERVER_H_
+#define _THRIFT_SERVER_TTHREADPOOLSERVER_H_ 1
+
+#include <concurrency/ThreadManager.h>
+#include <server/TServer.h>
+#include <transport/TServerTransport.h>
+
+#include <boost/shared_ptr.hpp>
+
+namespace facebook { namespace thrift { namespace server {
+
+using facebook::thrift::concurrency::ThreadManager;
+using facebook::thrift::protocol::TProtocolFactory;
+using facebook::thrift::transport::TServerTransport;
+using facebook::thrift::transport::TTransportFactory;
+
+class TThreadPoolServer : public TServer {
+ public:
+  class Task;
+
+  TThreadPoolServer(boost::shared_ptr<TProcessor> processor,
+                    boost::shared_ptr<TServerTransport> serverTransport,
+                    boost::shared_ptr<TTransportFactory> transportFactory,
+                    boost::shared_ptr<TProtocolFactory> protocolFactory,
+                    boost::shared_ptr<ThreadManager> threadManager);
+
+  TThreadPoolServer(boost::shared_ptr<TProcessor> processor,
+                    boost::shared_ptr<TServerTransport> serverTransport,
+                    boost::shared_ptr<TTransportFactory> inputTransportFactory,
+                    boost::shared_ptr<TTransportFactory> outputTransportFactory,
+                    boost::shared_ptr<TProtocolFactory> inputProtocolFactory,
+                    boost::shared_ptr<TProtocolFactory> outputProtocolFactory,
+                    boost::shared_ptr<ThreadManager> threadManager);
+
+  virtual ~TThreadPoolServer();
+
+  virtual void serve();
+
+  virtual int64_t getTimeout() const;
+
+  virtual void setTimeout(int64_t value);
+
+  virtual void stop() {
+    stop_ = true;
+    serverTransport_->interrupt();
+  }
+
+ protected:
+
+  boost::shared_ptr<ThreadManager> threadManager_;
+
+  volatile bool stop_;
+
+  volatile int64_t timeout_;
+
+};
+
+}}} // facebook::thrift::server
+
+#endif // #ifndef _THRIFT_SERVER_TTHREADPOOLSERVER_H_

+ 55 - 0
src/contrib/hive/metastore/include/thrift/server/TThreadedServer.h

@@ -0,0 +1,55 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#ifndef _THRIFT_SERVER_TTHREADEDSERVER_H_
+#define _THRIFT_SERVER_TTHREADEDSERVER_H_ 1
+
+#include <server/TServer.h>
+#include <transport/TServerTransport.h>
+#include <concurrency/Monitor.h>
+#include <concurrency/Thread.h>
+
+#include <boost/shared_ptr.hpp>
+
+namespace facebook { namespace thrift { namespace server {
+
+using facebook::thrift::TProcessor;
+using facebook::thrift::transport::TServerTransport;
+using facebook::thrift::transport::TTransportFactory;
+using facebook::thrift::concurrency::Monitor;
+using facebook::thrift::concurrency::ThreadFactory;
+
+class TThreadedServer : public TServer {
+
+ public:
+  class Task;
+
+  TThreadedServer(boost::shared_ptr<TProcessor> processor,
+                  boost::shared_ptr<TServerTransport> serverTransport,
+                  boost::shared_ptr<TTransportFactory> transportFactory,
+                  boost::shared_ptr<TProtocolFactory> protocolFactory);
+
+  virtual ~TThreadedServer();
+
+  virtual void serve();
+
+  void stop() {
+    stop_ = true;
+    serverTransport_->interrupt();
+  }
+
+ protected:
+  boost::shared_ptr<ThreadFactory> threadFactory_;
+  volatile bool stop_;
+
+  Monitor tasksMonitor_;
+  std::set<Task*> tasks_;
+
+};
+
+}}} // facebook::thrift::server
+
+#endif // #ifndef _THRIFT_SERVER_TTHREADEDSERVER_H_

+ 429 - 0
src/contrib/hive/metastore/include/thrift/transport/TFileTransport.h

@@ -0,0 +1,429 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#ifndef _THRIFT_TRANSPORT_TFILETRANSPORT_H_
+#define _THRIFT_TRANSPORT_TFILETRANSPORT_H_ 1
+
+#include "TTransport.h"
+#include "Thrift.h"
+#include "TProcessor.h"
+
+#include <string>
+#include <stdio.h>
+
+#include <boost/shared_ptr.hpp>
+
+namespace facebook { namespace thrift { namespace transport { 
+
+using facebook::thrift::TProcessor;
+using facebook::thrift::protocol::TProtocolFactory;
+
+// Data pertaining to a single event
+typedef struct eventInfo {
+  uint8_t* eventBuff_;
+  uint32_t eventSize_;
+  uint32_t eventBuffPos_;
+
+  eventInfo():eventBuff_(NULL), eventSize_(0), eventBuffPos_(0){};
+  ~eventInfo() {
+    if (eventBuff_) {
+      delete[] eventBuff_;
+    }
+  }
+} eventInfo;
+
+// information about current read state
+typedef struct readState {
+  eventInfo* event_;
+
+  // keep track of event size
+  uint8_t   eventSizeBuff_[4];
+  uint8_t   eventSizeBuffPos_;
+  bool      readingSize_;
+
+  // read buffer variables
+  int32_t  bufferPtr_;
+  int32_t  bufferLen_;
+
+  // last successful dispatch point
+  int32_t lastDispatchPtr_;
+  
+  void resetState(uint32_t lastDispatchPtr) {
+    readingSize_ = true;
+    eventSizeBuffPos_ = 0;
+    lastDispatchPtr_ = lastDispatchPtr;
+  }
+
+  void resetAllValues() {
+    resetState(0);
+    bufferPtr_ = 0;
+    bufferLen_ = 0;
+    if (event_) {
+      delete(event_);
+    }
+    event_ = 0;
+  }
+
+  readState() {
+    event_ = 0;
+   resetAllValues();
+  }
+
+  ~readState() {
+    if (event_) {
+      delete(event_);
+    }
+  }
+
+} readState;
+ 
+/**
+ * TFileTransportBuffer - buffer class used by TFileTransport for queueing up events
+ * to be written to disk.  Should be used in the following way:
+ *  1) Buffer created
+ *  2) Buffer written to (addEvent)
+ *  3) Buffer read from (getNext)
+ *  4) Buffer reset (reset)
+ *  5) Go back to 2, or destroy buffer
+ *
+ * The buffer should never be written to after it is read from, unless it is reset first.
+ * Note: The above rules are enforced mainly for debugging its sole client TFileTransport 
+ *       which uses the buffer in this way.
+ * 
+ * @author James Wang <jwang@facebook.com>
+ */
+class TFileTransportBuffer {
+  public:
+    TFileTransportBuffer(uint32_t size);
+    ~TFileTransportBuffer();
+
+    bool addEvent(eventInfo *event);
+    eventInfo* getNext();
+    void reset();
+    bool isFull();
+    bool isEmpty();
+    
+  private:
+    TFileTransportBuffer(); // should not be used
+
+    enum mode {
+      WRITE,
+      READ
+    };
+    mode bufferMode_;
+
+    uint32_t writePoint_;
+    uint32_t readPoint_;
+    uint32_t size_;
+    eventInfo** buffer_;
+};
+
+/**
+ * Abstract interface for transports used to read files
+ */
+class TFileReaderTransport : virtual public TTransport {
+ public:
+  virtual int32_t getReadTimeout() = 0;
+  virtual void setReadTimeout(int32_t readTimeout) = 0;
+
+  virtual uint32_t getNumChunks() = 0;
+  virtual uint32_t getCurChunk() = 0;
+  virtual void seekToChunk(int32_t chunk) = 0;
+  virtual void seekToEnd() = 0;
+};
+
+/**
+ * Abstract interface for transports used to write files
+ */
+class TFileWriterTransport : virtual public TTransport {
+ public:
+  virtual uint32_t getChunkSize() = 0;
+  virtual void setChunkSize(uint32_t chunkSize) = 0;
+};
+
+/**
+ * File implementation of a transport. Reads and writes are done to a 
+ * file on disk.
+ *
+ * @author Aditya Agarwal <aditya@facebook.com>
+ */
+class TFileTransport : public TFileReaderTransport,
+                       public TFileWriterTransport {
+ public:
+  TFileTransport(std::string path, bool readOnly=false);
+  ~TFileTransport();
+
+  // TODO: what is the correct behaviour for this?
+  // the log file is generally always open
+  bool isOpen() {
+    return true;
+  }
+  
+  void write(const uint8_t* buf, uint32_t len);
+  void flush();
+
+  uint32_t readAll(uint8_t* buf, uint32_t len);
+  uint32_t read(uint8_t* buf, uint32_t len);
+
+  // log-file specific functions
+  void seekToChunk(int32_t chunk);
+  void seekToEnd();
+  uint32_t getNumChunks();
+  uint32_t getCurChunk();
+
+  // for changing the output file
+  void resetOutputFile(int fd, std::string filename, int64_t offset);
+
+  // Setter/Getter functions for user-controllable options
+  void setReadBuffSize(uint32_t readBuffSize) {
+    if (readBuffSize) {
+      readBuffSize_ = readBuffSize;
+    }
+  }
+  uint32_t getReadBuffSize() {
+    return readBuffSize_;
+  }
+
+  static const int32_t TAIL_READ_TIMEOUT = -1;
+  static const int32_t NO_TAIL_READ_TIMEOUT = 0;
+  void setReadTimeout(int32_t readTimeout) {
+    readTimeout_ = readTimeout;
+  }
+  int32_t getReadTimeout() {
+    return readTimeout_;
+  }
+
+  void setChunkSize(uint32_t chunkSize) {
+    if (chunkSize) {
+      chunkSize_ = chunkSize;
+    }
+  }
+  uint32_t getChunkSize() {
+    return chunkSize_;
+  }
+
+  void setEventBufferSize(uint32_t bufferSize) {    
+    if (bufferAndThreadInitialized_) {
+      GlobalOutput("Cannot change the buffer size after writer thread started");
+      return;
+    }
+    eventBufferSize_ = bufferSize;
+  }
+
+  uint32_t getEventBufferSize() {
+    return eventBufferSize_;
+  }
+
+  void setFlushMaxUs(uint32_t flushMaxUs) {
+    if (flushMaxUs) {
+      flushMaxUs_ = flushMaxUs;
+    }
+  }
+  uint32_t getFlushMaxUs() {
+    return flushMaxUs_;
+  }
+
+  void setFlushMaxBytes(uint32_t flushMaxBytes) {
+    if (flushMaxBytes) {
+      flushMaxBytes_ = flushMaxBytes;
+    }
+  }
+  uint32_t getFlushMaxBytes() {
+    return flushMaxBytes_;
+  }
+
+  void setMaxEventSize(uint32_t maxEventSize) {
+    maxEventSize_ = maxEventSize;
+  }
+  uint32_t getMaxEventSize() {
+    return maxEventSize_;
+  }
+
+  void setMaxCorruptedEvents(uint32_t maxCorruptedEvents) {
+    maxCorruptedEvents_ = maxCorruptedEvents;
+  }
+  uint32_t getMaxCorruptedEvents() {
+    return maxCorruptedEvents_;
+  }
+
+  void setEofSleepTimeUs(uint32_t eofSleepTime) {
+    if (eofSleepTime) {
+      eofSleepTime_ = eofSleepTime;
+    }
+  }
+  uint32_t getEofSleepTimeUs() {
+    return eofSleepTime_;
+  }
+
+ private:
+  // helper functions for writing to a file
+  void enqueueEvent(const uint8_t* buf, uint32_t eventLen, bool blockUntilFlush);
+  bool swapEventBuffers(struct timespec* deadline);
+  bool initBufferAndWriteThread();
+
+  // control for writer thread
+  static void* startWriterThread(void* ptr) {
+    (((TFileTransport*)ptr)->writerThread());
+    return 0;
+  }
+  void writerThread();
+
+  // helper functions for reading from a file
+  eventInfo* readEvent();
+
+  // event corruption-related functions
+  bool isEventCorrupted();
+  void performRecovery();
+
+  // Utility functions
+  void openLogFile();
+  void getNextFlushTime(struct timespec* ts_next_flush);
+
+  // Class variables
+  readState readState_;
+  uint8_t* readBuff_;
+  eventInfo* currentEvent_;
+
+  uint32_t readBuffSize_;
+  static const uint32_t DEFAULT_READ_BUFF_SIZE = 1 * 1024 * 1024;
+
+  int32_t readTimeout_;
+  static const int32_t DEFAULT_READ_TIMEOUT_MS = 200;
+
+  // size of chunks that file will be split up into
+  uint32_t chunkSize_;
+  static const uint32_t DEFAULT_CHUNK_SIZE = 16 * 1024 * 1024;
+
+  // size of event buffers
+  uint32_t eventBufferSize_;
+  static const uint32_t DEFAULT_EVENT_BUFFER_SIZE = 10000;
+
+  // max number of microseconds that can pass without flushing
+  uint32_t flushMaxUs_;
+  static const uint32_t DEFAULT_FLUSH_MAX_US = 3000000;
+
+  // max number of bytes that can be written without flushing
+  uint32_t flushMaxBytes_;
+  static const uint32_t DEFAULT_FLUSH_MAX_BYTES = 1000 * 1024;
+
+  // max event size
+  uint32_t maxEventSize_;
+  static const uint32_t DEFAULT_MAX_EVENT_SIZE = 0;
+
+  // max number of corrupted events per chunk
+  uint32_t maxCorruptedEvents_;
+  static const uint32_t DEFAULT_MAX_CORRUPTED_EVENTS = 0;
+  
+  // sleep duration when EOF is hit
+  uint32_t eofSleepTime_;
+  static const uint32_t DEFAULT_EOF_SLEEP_TIME_US = 500 * 1000;
+
+  // sleep duration when a corrupted event is encountered
+  uint32_t corruptedEventSleepTime_;
+  static const uint32_t DEFAULT_CORRUPTED_SLEEP_TIME_US = 1 * 1000 * 1000;
+    
+  // writer thread id
+  pthread_t writerThreadId_;
+
+  // buffers to hold data before it is flushed. Each element of the buffer stores a msg that 
+  // needs to be written to the file.  The buffers are swapped by the writer thread.
+  TFileTransportBuffer *dequeueBuffer_;
+  TFileTransportBuffer *enqueueBuffer_;
+  
+  // conditions used to block when the buffer is full or empty
+  pthread_cond_t notFull_, notEmpty_;
+  volatile bool closing_;
+
+  // To keep track of whether the buffer has been flushed
+  pthread_cond_t flushed_;
+  volatile bool forceFlush_;
+
+  // Mutex that is grabbed when enqueueing and swapping the read/write buffers
+  pthread_mutex_t mutex_;
+
+  // File information
+  std::string filename_;
+  int fd_;
+
+  // Whether the writer thread and buffers have been initialized
+  bool bufferAndThreadInitialized_;
+
+  // Offset within the file
+  off_t offset_;
+
+  // event corruption information
+  uint32_t lastBadChunk_;
+  uint32_t numCorruptedEventsInChunk_;
+
+  bool readOnly_;
+};
+
+// Exception thrown when EOF is hit
+class TEOFException : public TTransportException {
+ public:
+  TEOFException():
+    TTransportException(TTransportException::END_OF_FILE) {};
+};
+
+
+// wrapper class to process events from a file containing thrift events
+class TFileProcessor {
+ public:
+  /** 
+   * Constructor that defaults output transport to null transport
+   * 
+   * @param processor processes log-file events
+   * @param protocolFactory protocol factory
+   * @param inputTransport file transport
+   */
+  TFileProcessor(boost::shared_ptr<TProcessor> processor,
+                 boost::shared_ptr<TProtocolFactory> protocolFactory,
+                 boost::shared_ptr<TFileReaderTransport> inputTransport);
+
+  TFileProcessor(boost::shared_ptr<TProcessor> processor,
+                 boost::shared_ptr<TProtocolFactory> inputProtocolFactory,
+                 boost::shared_ptr<TProtocolFactory> outputProtocolFactory,
+                 boost::shared_ptr<TFileReaderTransport> inputTransport);
+
+  /** 
+   * Constructor
+   * 
+   * @param processor processes log-file events
+   * @param protocolFactory protocol factory
+   * @param inputTransport input file transport
+   * @param output output transport
+   */    
+  TFileProcessor(boost::shared_ptr<TProcessor> processor,
+                 boost::shared_ptr<TProtocolFactory> protocolFactory,
+                 boost::shared_ptr<TFileReaderTransport> inputTransport,
+                 boost::shared_ptr<TTransport> outputTransport);
+
+  /**
+   * processes events from the file
+   *
+   * @param numEvents number of events to process (0 for unlimited)
+   * @param tail tails the file if true
+   */
+  void process(uint32_t numEvents, bool tail);
+
+  /**
+   * process events until the end of the chunk
+   *
+   */
+  void processChunk();
+  
+ private:
+  boost::shared_ptr<TProcessor> processor_;
+  boost::shared_ptr<TProtocolFactory> inputProtocolFactory_;
+  boost::shared_ptr<TProtocolFactory> outputProtocolFactory_;
+  boost::shared_ptr<TFileReaderTransport> inputTransport_;
+  boost::shared_ptr<TTransport> outputTransport_;
+};
+
+ 
+}}} // facebook::thrift::transport
+
+#endif // _THRIFT_TRANSPORT_TFILETRANSPORT_H_

+ 99 - 0
src/contrib/hive/metastore/include/thrift/transport/THttpClient.h

@@ -0,0 +1,99 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#ifndef _THRIFT_TRANSPORT_THTTPCLIENT_H_
+#define _THRIFT_TRANSPORT_THTTPCLIENT_H_ 1
+
+#include <transport/TTransportUtils.h>
+
+namespace facebook { namespace thrift { namespace transport { 
+
+/**
+ * HTTP client implementation of the thrift transport. This was irritating
+ * to write, but the alternatives in C++ land are daunting. Linking CURL
+ * requires 23 dynamic libraries last time I checked (WTF?!?). All we have
+ * here is a VERY basic HTTP/1.1 client which supports HTTP 100 Continue,
+ * chunked transfer encoding, keepalive, etc. Tested against Apache.
+ *
+ * @author Mark Slee <mcslee@facebook.com>
+ */
+class THttpClient : public TTransport {
+ public:
+  THttpClient(boost::shared_ptr<TTransport> transport, std::string host, std::string path="");
+
+  THttpClient(std::string host, int port, std::string path="");
+
+  virtual ~THttpClient();
+
+  void open() {
+    transport_->open();
+  }
+
+  bool isOpen() {
+    return transport_->isOpen();
+  }
+  
+  bool peek() {    
+    return transport_->peek();
+  }
+
+  void close() {
+    transport_->close();
+  }
+
+  uint32_t read(uint8_t* buf, uint32_t len);
+
+  void readEnd();
+
+  void write(const uint8_t* buf, uint32_t len);
+  
+  void flush();
+
+ private:
+  void init();
+
+ protected:
+
+  boost::shared_ptr<TTransport> transport_;
+
+  TMemoryBuffer writeBuffer_;
+  TMemoryBuffer readBuffer_;
+
+  std::string host_;
+  std::string path_;
+
+  bool readHeaders_;
+  bool chunked_;
+  bool chunkedDone_;
+  uint32_t chunkSize_;
+  uint32_t contentLength_;
+
+  char* httpBuf_;
+  uint32_t httpPos_;
+  uint32_t httpBufLen_;
+  uint32_t httpBufSize_;
+
+  uint32_t readMoreData();
+  char* readLine();
+
+  void readHeaders();
+  void parseHeader(char* header);
+  bool parseStatusLine(char* status);
+
+  uint32_t readChunked();
+  void readChunkedFooters();
+  uint32_t parseChunkSize(char* line);
+
+  uint32_t readContent(uint32_t size);
+
+  void refill();
+  void shift();
+
+};
+
+}}} // facebook::thrift::transport
+
+#endif // #ifndef _THRIFT_TRANSPORT_THTTPCLIENT_H_

+ 59 - 0
src/contrib/hive/metastore/include/thrift/transport/TServerSocket.h

@@ -0,0 +1,59 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#ifndef _THRIFT_TRANSPORT_TSERVERSOCKET_H_
+#define _THRIFT_TRANSPORT_TSERVERSOCKET_H_ 1
+
+#include "TServerTransport.h"
+#include <boost/shared_ptr.hpp>
+
+namespace facebook { namespace thrift { namespace transport { 
+
+class TSocket;
+
+/**
+ * Server socket implementation of TServerTransport. Wrapper around a unix
+ * socket listen and accept calls.
+ *
+ * @author Mark Slee <mcslee@facebook.com>
+ */
+class TServerSocket : public TServerTransport {
+ public:
+  TServerSocket(int port);
+  TServerSocket(int port, int sendTimeout, int recvTimeout);
+
+  ~TServerSocket();
+
+  void setSendTimeout(int sendTimeout);
+  void setRecvTimeout(int recvTimeout);
+
+  void setRetryLimit(int retryLimit);
+  void setRetryDelay(int retryDelay);
+
+  void listen();
+  void close();
+
+  void interrupt();
+
+ protected:
+  boost::shared_ptr<TTransport> acceptImpl();
+
+ private:
+  int port_;
+  int serverSocket_;
+  int acceptBacklog_;
+  int sendTimeout_;
+  int recvTimeout_;
+  int retryLimit_;
+  int retryDelay_;
+
+  int intSock1_;
+  int intSock2_;
+};
+
+}}} // facebook::thrift::transport
+
+#endif // #ifndef _THRIFT_TRANSPORT_TSERVERSOCKET_H_

+ 80 - 0
src/contrib/hive/metastore/include/thrift/transport/TServerTransport.h

@@ -0,0 +1,80 @@
+// Copyright (c) 2006- Facebook
+// Distributed under the Thrift Software License
+//
+// See accompanying file LICENSE or visit the Thrift site at:
+// http://developers.facebook.com/thrift/
+
+#ifndef _THRIFT_TRANSPORT_TSERVERTRANSPORT_H_
+#define _THRIFT_TRANSPORT_TSERVERTRANSPORT_H_ 1
+
+#include "TTransport.h"
+#include "TTransportException.h"
+#include <boost/shared_ptr.hpp>
+
+namespace facebook { namespace thrift { namespace transport { 
+
+/**
+ * Server transport framework. A server needs to have some facility for
+ * creating base transports to read/write from.
+ *
+ * @author Mark Slee <mcslee@facebook.com>
+ */
+class TServerTransport {
+ public:
+  virtual ~TServerTransport() {}
+
+  /**
+   * Starts the server transport listening for new connections. Prior to this
+   * call most transports will not return anything when accept is called.
+   *
+   * @throws TTransportException if we were unable to listen
+   */
+  virtual void listen() {}
+
+  /**
+   * Gets a new dynamically allocated transport object and passes it to the
+   * caller. Note that it is the explicit duty of the caller to free the
+   * allocated object. The returned TTransport object must always be in the
+   * opened state. NULL should never be returned, instead an Exception should
+   * always be thrown.
+   *
+   * @return A new TTransport object
+   * @throws TTransportException if there is an error
+   */
+  boost::shared_ptr<TTransport> accept() {
+    boost::shared_ptr<TTransport> result = acceptImpl();
+    if (result == NULL) {
+      throw TTransportException("accept() may not return NULL");
+    }
+    return result;
+  }
+
+  /**
+   * For "smart" TServerTransport implementations that work in a multi
+   * threaded context this can be used to break out of an accept() call.
+   * It is expected that the transport will throw a TTransportException
+   * with the interrupted error code.
+   */
+  virtual void interrupt() {}
+
+  /**
+   * Closes this transport such that future calls to accept will do nothing.
+   */
+  virtual void close() = 0;
+
+ protected:
+  TServerTransport() {}
+
+  /**
+   * Subclasses should implement this function for accept.
+   *
+   * @return A newly allocated TTransport object
+   * @throw TTransportException If an error occurs
+   */
+  virtual boost::shared_ptr<TTransport> acceptImpl() = 0;
+
+};
+
+}}} // facebook::thrift::transport
+
+#endif // #ifndef _THRIFT_TRANSPORT_TSERVERTRANSPORT_H_

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott