 ****************************
* Vertica Analytic Database
*
* HCatalog Java UDL 
*
* Copyright (c) 2005 - 2013 Vertica, an HP company
****************************

This directory contains Java UDSources and UDParsers that are part of
Vertica HCatalog integration package.  It is intended to replace the
HCatalogSource UDSource that is implemented in C++.

These UDLs are provided:  

1) com.vertica.hcatalogudl.NoOpSourceFactory
- A dummy UDSource. Does nothing except fill the 'SOURCE ...' phrase
in a vertica COPY statement, so that the HCatalogParserFactory and
HCatalogSplitsParserFactory can be used in conjunction with it.

2) com.vertica.hcatalogudl.HCatalogSplitsNoOpSourceFactory 
- Another dummy UDSource but send out splits information, so that
multiple sources can be created on a multi-node Vertica
cluster. Intented to work with HCatalogSplitsParserFactory.  Needs the
hcatalog server/table parameters (hive_server_host, hive_server_port,
schema_name, table_name) to know how many splits a table has.

3) com.vertica.hcatalogudl.HCatalogTableDelimSourceFactory 
- A UDSource that gets the HCatalog table records and output a record
stream using the Vertica default pipe-delimitered text format. 
Same parameters as above.

4) com.vertica.hcatalogudl.HCatalogTableSplitsDelimSourceFactory 
- Like the above HCatalogTableDelimSourceFactory source, but handles
the hcatalog splits, so multinode Vertica cluster can parallel-process
the splits. Same parameters as above.

5) com.vertica.hcatalogudl.HCatalogParserFactory
- A UD Parser that fetches record for a HCatalog table. To be used together
with NoOpSource. Does not parallel-process table splits. Same parameters as above, 
plus an additional one: break_size, to indicate a 'break' after reading every break_size
number of table records. Default is 100,000.

6) com.vertica.hcatalogudl.HCatalogSplitsParserFactory
- Similar to above, but handle the splits. If worked together with 
HCatalogSplitsNoOpSourceFactory, the splits can be parallel-processed in
a multinode Vertica cluster. Same parameters as above.

Directory structure:
  ./lib       The jars needed to compile and run
  ./ddl       Sql scripts to install and uninstall Vertica's HCatalog integrated
              UDSource library. Run install ('vsql -f install.sql') before
              running example, and run uninstall after done with the library
  ./examples  Examples using the parsers and sources
  ./src/java  Source code of the UDL 

Installation
============

Compilation pre-requisites:

1. Java 1.6 or higher needed. Check shell variables JAVA_HOME.

2. Following environmental variables should be set, if Vertica database is not
installed under /opt/vertica

    SDK_JAR : location of VerticaSDK.jar. e.g. /opt/vertica/bin/VerticaSDK.jar
    SDK_SRC : Path to VerticaSDK folder e.g. /opt/vertica/sdk - need the java-UDx jar.
    VSQL: Path to vsql executable e.g. /opt/vertica/bin/vsql (for test only)

3. cd to udx/supported/HCatalogJavaUDL (current dir), and do a "make" to compile. The output jar (vertica-hcatalogudl.jar) will be in build/ directory.
Check SDK_JAR and SDK_SRC if build fails.

4. Do "make fix_udx_vertica_jar" to change the Class-Path value in vertica-udx-Java.jar so jars in lib/ can be loaded when the Java UDx process starts.
Use "make revert_udx_vertica_jar" to revert the Class-Path value in vertica-udx-Java.jar when needed. Need to do this for all vertica nodes.


Runtime pre-requisites
======================

1. Java runtime environment (JRE)
2. Vertica database
3. Hadoop components installed and accessible to current node (Mapreduce, HDFS, 
zookeeper, hive and hcatalog)
4. Templeton web services (needed for end-to-end testing), the sources themselves do not need them.
5. Hive server (Version 1) up and running


Using HCatalogJavaUDL
=======================
Examples are shown in examples/example.sql

copy nation SOURCE SplitsNoOp(hive_server_host='localhost.localdomain',table_name='nation') parser HSplitsParser(hive_server_host='localhost.localdomain',table_name='nation');

Parameter description (**Required parameter): 

*Note that except table_name, you only have to specify a parameter value if 
default value is not applicable to your environment.

**table_name    = Name of the Hive table, required.

schema_name     = Name of the Hive schema, default schema is 'default'

**hive_server_host = Host name of HiveServer, required.

hive_server_port = Port number of Hive Metastore service, default is '9083'

break_size = an integer indicate the number of records to write before the UD parser temporarily yield itself. Applies to parsers only. Default is 100000.


