You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by go...@apache.org on 2016/03/18 20:02:19 UTC
[2/3] hive git commit: HIVE-13234: Remove dead ODBC driver from Hive
(Gopal V, reviewed by Thejas Nair)
http://git-wip-us.apache.org/repos/asf/hive/blob/3468a666/odbc/src/cpp/HiveRowSet.h
----------------------------------------------------------------------
diff --git a/odbc/src/cpp/HiveRowSet.h b/odbc/src/cpp/HiveRowSet.h
deleted file mode 100644
index ca6e6af..0000000
--- a/odbc/src/cpp/HiveRowSet.h
+++ /dev/null
@@ -1,168 +0,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.
- *
- ******************************************************************************
- *
- * @file HiveRowSet.h
- * @brief Provides the HiveRowSet interface and subclasses.
- *
- *****************************************************************************/
-
-
-#ifndef __hive_rowset_h__
-#define __hive_rowset_h__
-
-#include <iostream>
-
-#include "hive_metastore_types.h"
-
-#include "hiveconstants.h"
-#include "thriftserverconstants.h"
-
-using namespace std;
-
-
-/*************************************************************************************************
- * Base HiveRowSet Class Abstract Declaration
- ************************************************************************************************/
-
-/**
- * @brief HiveRowSet interface definition.
- *
- * Abstract base class for Hive rowsets. Provides the logic to extract fields as various
- * data types, allowing subclasses to focus on the storage and field parsing of the data.
- */
-class HiveRowSet {
- public:
- /// Cannot be called directly, but should be called automatically from subclass constructors
- HiveRowSet();
- virtual ~HiveRowSet();
- void reset(); ///< Not overrideable, implement specialized_reset() instead
- HiveReturn getFieldDataLen(size_t column_idx, size_t* col_len, char* err_buf, size_t err_buf_len);
- HiveReturn getFieldAsCString(size_t column_idx, char* buffer, size_t buffer_len,
- size_t* data_byte_size, int* is_null_value, char* err_buf,
- size_t err_buf_len);
- HiveReturn getFieldAsDouble(size_t column_idx, double* buffer, int* is_null_value, char* err_buf,
- size_t err_buf_len);
- HiveReturn getFieldAsInt(size_t column_idx, int* buffer, int* is_null_value, char* err_buf,
- size_t err_buf_len);
- HiveReturn getFieldAsLong(size_t column_idx, long* buffer, int* is_null_value, char* err_buf,
- size_t err_buf_len);
- HiveReturn getFieldAsULong(size_t column_idx, unsigned long* buffer, int* is_null_value,
- char* err_buf, size_t err_buf_len);
- HiveReturn getFieldAsI64(size_t column_idx, int64_t* buffer, int* is_null_value, char* err_buf,
- size_t err_buf_len);
- HiveReturn getFieldAsI64U(size_t column_idx, uint64_t* buffer, int* is_null_value, char* err_buf,
- size_t err_buf_len);
-
- protected:
- /// Forces all data retrieved to be no more than MAX_BYTE_LENGTH
- char m_field_buffer[MAX_BYTE_LENGTH + 1];
-
- /**
- * @brief Initializes m_field_buffer with the field indicated by m_last_column_fetched.
- *
- * Not overrideable, used by subclasses to synchronize m_field_buffer and m_last_column_fetched;
- * should be called by every subclass immediately after initialization. This is necessary at
- * the beginning to make sure that m_field_buffer will always have the field data indicated
- * by m_last_column_fetched.
- */
- void initFieldBuffer();
-
- private:
- bool m_is_completely_read;
- size_t m_last_column_fetched;
- /// Number of bytes read out of m_last_column_fetched since the last consecutive call
- size_t m_bytes_read;
-
- virtual void specialized_reset() =0; ///< Called by HiveRowSet::reset()
- virtual size_t getColumnCount() =0; ///< Only used within this class hierarchy for error checking
- virtual const char* getNullFormat() =0; ///< Should return a pointer to a locally stored C string
- virtual size_t getFieldLen(size_t column_idx) =0;
- /// Should copy the field data as a C string to m_field_buffer
- virtual void extractField(size_t column_idx) =0;
-};
-
-
-/*************************************************************************************************
- * HiveSerializedRowSet Subclass Declaration
- ************************************************************************************************/
-
-/**
- * @brief Container class for a fetched row from a HiveResultSet where each row is a serialized string.
- *
- * Container class for a fetched row from a HiveResultSet where each row is a serialized string.
- * - HiveSerializedRowSet is completely dependent on associated HiveResultSet and should not
- * be used independently; must always remain bound to associated HiveResultSet.
- * - Assumes the associated HiveResultSet manages the memory of all weak pointer members
- * - Constructed within the HiveResultSet by calling DBFetch
- * - All errors messages will be written to err_buf if err_buf and err_buf_len are provided
- */
-class HiveSerializedRowSet: public HiveRowSet {
- public:
- HiveSerializedRowSet();
- virtual ~HiveSerializedRowSet();
- void initialize(Apache::Hadoop::Hive::Schema& schema, string& serialized_row);
-
- private:
- string* m_row_weak_ptr; ///< Weak pointer to the row string associated with m_field_offsets
- vector<size_t> m_field_offsets; ///< Indexes into the serialized row string of column starting points
- string* m_null_format_weak_ptr; ///< Weak pointer to NULL format representation for this row
-
- void specialized_reset();
- void initializeOffsets(Apache::Hadoop::Hive::Schema& schema, string& serialized_row);
- size_t getColumnCount();
- const char* getNullFormat();
- size_t getFieldLen(size_t column_idx);
- void extractField(size_t column_idx);
-};
-
-
-/*************************************************************************************************
- * HiveStringVectorRowSet Subclass Declaration
- ************************************************************************************************/
-
-/**
- * @brief Container class for a fetched row from a HiveResultSet where each row is vector of string fields.
- *
- * Container class for a fetched row from a HiveResultSet where each row is vector of string fields
- * - HiveStringVectorRowSet is completely dependent on associated HiveResultSet and should not
- * be used independently; must always remain bound to associated HiveResultSet.
- * - Assumes the associated HiveResultSet manages the memory of all weak pointer members
- * - Constructed within the HiveResultSet by calling DBFetch
- * - All errors messages will be written to err_buf if err_buf and err_buf_len are provided
- */
-class HiveStringVectorRowSet: public HiveRowSet {
- public:
- HiveStringVectorRowSet();
- virtual ~HiveStringVectorRowSet();
- void initialize(Apache::Hadoop::Hive::Schema& schema, vector<string>* fields);
-
- private:
- vector<string>* m_fields_weak_ptr; ///< Weak pointer to a vector of fields represented as strings
- string* m_null_format_weak_ptr; ///< Weak pointer to NULL format representation for this row
-
- void specialized_reset();
- size_t getColumnCount();
- const char* getNullFormat();
- size_t getFieldLen(size_t column_idx);
- void extractField(size_t column_idx);
-};
-
-
-#endif // __hive_rowset_h__
http://git-wip-us.apache.org/repos/asf/hive/blob/3468a666/odbc/src/cpp/hiveclient.cpp
----------------------------------------------------------------------
diff --git a/odbc/src/cpp/hiveclient.cpp b/odbc/src/cpp/hiveclient.cpp
deleted file mode 100644
index 450eb0b..0000000
--- a/odbc/src/cpp/hiveclient.cpp
+++ /dev/null
@@ -1,294 +0,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.
- */
-
-#include <assert.h>
-#include <iostream>
-#include <boost/shared_ptr.hpp>
-#include <boost/algorithm/string.hpp>
-
-#include "ThriftHive.h"
-#include <protocol/TBinaryProtocol.h>
-#include <transport/TTransportUtils.h>
-#include <transport/TTransport.h>
-#include <transport/TSocket.h>
-
-#include "hiveclient.h"
-#include "hiveclienthelper.h"
-#include "HiveColumnDesc.h"
-#include "HiveConnection.h"
-#include "HiveResultSet.h"
-#include "HiveRowSet.h"
-
-
-using namespace std;
-using namespace boost;
-using namespace apache::thrift::protocol;
-using namespace apache::thrift::transport;
-
-
-/*****************************************************************
- * Global Hive Client Functions (usable as C callback functions)
- *****************************************************************/
-
-HiveConnection* DBOpenConnection(const char* database, const char* host, int port, int framed,
- char* err_buf, size_t err_buf_len) {
- // TODO: add in database selection when Hive supports this feature
- shared_ptr<TSocket> socket(new TSocket(host, port));
- shared_ptr<TTransport> transport;
-
- if (framed) {
- shared_ptr<TFramedTransport> framedSocket(new TFramedTransport(socket));
- transport = framedSocket;
- } else {
- shared_ptr<TBufferedTransport> bufferedSocket(new TBufferedTransport(socket));
- transport = bufferedSocket;
- }
-
- shared_ptr<TBinaryProtocol> protocol(new TBinaryProtocol(transport));
- shared_ptr<Apache::Hadoop::Hive::ThriftHiveClient> client(new Apache::Hadoop::Hive::ThriftHiveClient(protocol));
- try {
- transport->open();
- } catch (TTransportException& ttx) {
- RETURN_FAILURE(__FUNCTION__, ttx.what(), err_buf, err_buf_len, NULL);
- } catch (...) {
- RETURN_FAILURE(__FUNCTION__,
- "Unable to connect to Hive server.", err_buf, err_buf_len, NULL);
- }
-
- HiveConnection* conn = new HiveConnection(client, transport);
- return conn;
-}
-
-HiveReturn DBCloseConnection(HiveConnection* connection, char* err_buf, size_t err_buf_len) {
- RETURN_ON_ASSERT(connection == NULL, __FUNCTION__,
- "Hive connection cannot be NULL.", err_buf, err_buf_len, HIVE_ERROR);
- RETURN_ON_ASSERT(connection->transport == NULL, __FUNCTION__,
- "Hive connection transport cannot be NULL.", err_buf, err_buf_len, HIVE_ERROR);
- try {
- connection->transport->close();
- } catch (...) {
- /* Ignore the exception, we just want to clean up everything... */
- }
- delete connection;
- return HIVE_SUCCESS;
-}
-
-HiveReturn DBExecute(HiveConnection* connection, const char* query, HiveResultSet** resultset_ptr,
- int max_buf_rows, char* err_buf, size_t err_buf_len) {
- RETURN_ON_ASSERT(connection == NULL, __FUNCTION__,
- "Hive connection cannot be NULL.", err_buf, err_buf_len, HIVE_ERROR);
- RETURN_ON_ASSERT(connection->client == NULL, __FUNCTION__,
- "Hive connection client cannot be NULL.", err_buf, err_buf_len, HIVE_ERROR);
- RETURN_ON_ASSERT(query == NULL, __FUNCTION__,
- "Query string cannot be NULL.", err_buf, err_buf_len, HIVE_ERROR);
-
- // TODO: remove
- string query_str(query);
- // TODO: this may not need to happen if Hive allows for multiple successive queries in
- // one execute statement (and permits a terminating semicolon).
- /* Strip off a query's terminating semicolon if it exists */
- trim(query_str); /* Trim white space from string to check if last character is semicolon */
- if (query_str.length() > 0 && query_str[query_str.length() - 1] == ';') {
- query_str.erase(query_str.length() - 1);
- }
-
- /* Pass the query onto the Hive server for execution */
- /* Query execution is kept separate from the resultset b/c results may not always be needed (i.e. DML) */
- try {
- connection->client->execute(query_str); /* This is currently implemented as a blocking operation */
- } catch (Apache::Hadoop::Hive::HiveServerException& ex) {
- RETURN_FAILURE(__FUNCTION__, ex.what(), err_buf, err_buf_len, HIVE_ERROR);
- } catch (...) {
- RETURN_FAILURE(__FUNCTION__,
- "Unknown Hive query execution error.", err_buf, err_buf_len, HIVE_ERROR);
- }
-
- /* resultset_ptr may be NULL if the caller does not care about the result */
- if (resultset_ptr != NULL) {
- HiveQueryResultSet* query_resultset = new HiveQueryResultSet(max_buf_rows);
- *resultset_ptr = query_resultset; /* Store into generic HiveResultSet pointer */
- return query_resultset->initialize(connection, err_buf, err_buf_len);
- }
- return HIVE_SUCCESS;
-}
-
-HiveReturn DBTables(HiveConnection* connection, const char* tbl_search_pattern,
- HiveResultSet** resultset_ptr, char* err_buf, size_t err_buf_len) {
- RETURN_ON_ASSERT(resultset_ptr == NULL, __FUNCTION__,
- "Resultset pointer cannot be NULL.", err_buf, err_buf_len, HIVE_ERROR);
-
- HiveTablesResultSet* tables_resultset = new HiveTablesResultSet();
- *resultset_ptr = tables_resultset; /* Store into generic HiveResultSet pointer */
- return tables_resultset->initialize(connection, tbl_search_pattern, err_buf, err_buf_len);
-}
-
-HiveReturn DBColumns(HiveConnection* connection, int(*fpHiveToSQLType)(HiveType),
- const char* tbl_search_pattern, const char* col_search_pattern,
- HiveResultSet** resultset_ptr, char* err_buf, size_t err_buf_len) {
- RETURN_ON_ASSERT(resultset_ptr == NULL, __FUNCTION__,
- "Resultset pointer cannot be NULL.", err_buf, err_buf_len, HIVE_ERROR);
-
- HiveColumnsResultSet* columns_resultset = new HiveColumnsResultSet(fpHiveToSQLType);
- *resultset_ptr = columns_resultset; /* Store into generic HiveResultSet pointer */
- return columns_resultset->initialize(connection, tbl_search_pattern, col_search_pattern, err_buf,
- err_buf_len);
-}
-
-HiveReturn DBCloseResultSet(HiveResultSet* resultset, char* err_buf, size_t err_buf_len) {
- RETURN_ON_ASSERT(resultset == NULL, __FUNCTION__,
- "Hive resultset cannot be NULL.", err_buf, err_buf_len, HIVE_ERROR);
- delete resultset;
- return HIVE_SUCCESS;
-}
-
-HiveReturn DBFetch(HiveResultSet* resultset, char* err_buf, size_t err_buf_len) {
- RETURN_ON_ASSERT(resultset == NULL, __FUNCTION__,
- "Hive resultset cannot be NULL.", err_buf, err_buf_len, HIVE_ERROR);
- return resultset->fetchNext(err_buf, err_buf_len);
-}
-
-HiveReturn DBHasResults(HiveResultSet* resultset, int* has_results, char* err_buf,
- size_t err_buf_len) {
- RETURN_ON_ASSERT(resultset == NULL, __FUNCTION__,
- "Hive resultset cannot be NULL.", err_buf, err_buf_len, HIVE_ERROR);
- return resultset->hasResults(has_results, err_buf, err_buf_len);
-}
-
-HiveReturn DBGetColumnCount(HiveResultSet* resultset, size_t* col_count, char* err_buf,
- size_t err_buf_len) {
- RETURN_ON_ASSERT(resultset == NULL, __FUNCTION__,
- "Hive resultset cannot be NULL.", err_buf, err_buf_len, HIVE_ERROR);
- return resultset->getColumnCount(col_count, err_buf, err_buf_len);
-}
-
-HiveReturn DBCreateColumnDesc(HiveResultSet* resultset, size_t column_idx,
- HiveColumnDesc** column_desc_ptr, char* err_buf, size_t err_buf_len) {
- RETURN_ON_ASSERT(resultset == NULL, __FUNCTION__,
- "Hive resultset cannot be NULL.", err_buf, err_buf_len, HIVE_ERROR);
- return resultset->createColumnDesc(column_idx, column_desc_ptr, err_buf, err_buf_len);
-}
-
-HiveReturn DBGetFieldDataLen(HiveResultSet* resultset, size_t column_idx, size_t* col_len,
- char* err_buf, size_t err_buf_len) {
- RETURN_ON_ASSERT(resultset == NULL, __FUNCTION__,
- "Hive resultset cannot be NULL.", err_buf, err_buf_len, HIVE_ERROR);
- return resultset->getRowSet().getFieldDataLen(column_idx, col_len, err_buf, err_buf_len);
-}
-
-HiveReturn DBGetFieldAsCString(HiveResultSet* resultset, size_t column_idx, char* buffer,
- size_t buffer_len, size_t* data_byte_size, int* is_null_value,
- char* err_buf, size_t err_buf_len) {
- RETURN_ON_ASSERT(resultset == NULL, __FUNCTION__,
- "Hive resultset cannot be NULL.", err_buf, err_buf_len, HIVE_ERROR);
- return resultset->getRowSet().getFieldAsCString(column_idx, buffer, buffer_len, data_byte_size,
- is_null_value, err_buf, err_buf_len);
-}
-
-HiveReturn DBGetFieldAsDouble(HiveResultSet* resultset, size_t column_idx, double* buffer,
- int* is_null_value, char* err_buf, size_t err_buf_len) {
- RETURN_ON_ASSERT(resultset == NULL, __FUNCTION__,
- "Hive resultset cannot be NULL.", err_buf, err_buf_len, HIVE_ERROR);
- return resultset->getRowSet().getFieldAsDouble(column_idx, buffer, is_null_value, err_buf,
- err_buf_len);
-}
-
-HiveReturn DBGetFieldAsInt(HiveResultSet* resultset, size_t column_idx, int* buffer,
- int* is_null_value, char* err_buf, size_t err_buf_len) {
- RETURN_ON_ASSERT(resultset == NULL, __FUNCTION__,
- "Hive resultset cannot be NULL.", err_buf, err_buf_len, HIVE_ERROR);
- return resultset->getRowSet().getFieldAsInt(column_idx, buffer, is_null_value, err_buf,
- err_buf_len);
-}
-
-HiveReturn DBGetFieldAsLong(HiveResultSet* resultset, size_t column_idx, long* buffer,
- int* is_null_value, char* err_buf, size_t err_buf_len) {
- RETURN_ON_ASSERT(resultset == NULL, __FUNCTION__,
- "Hive resultset cannot be NULL.", err_buf, err_buf_len, HIVE_ERROR);
- return resultset->getRowSet().getFieldAsLong(column_idx, buffer, is_null_value, err_buf,
- err_buf_len);
-}
-
-HiveReturn DBGetFieldAsULong(HiveResultSet* resultset, size_t column_idx, unsigned long* buffer,
- int* is_null_value, char* err_buf, size_t err_buf_len) {
- RETURN_ON_ASSERT(resultset == NULL, __FUNCTION__,
- "Hive resultset cannot be NULL.", err_buf, err_buf_len, HIVE_ERROR);
- return resultset->getRowSet().getFieldAsULong(column_idx, buffer, is_null_value, err_buf,
- err_buf_len);
-}
-
-HiveReturn DBGetFieldAsI64(HiveResultSet* resultset, size_t column_idx, int64_t* buffer,
- int* is_null_value, char* err_buf, size_t err_buf_len) {
- RETURN_ON_ASSERT(resultset == NULL, __FUNCTION__,
- "Hive resultset cannot be NULL.", err_buf, err_buf_len, HIVE_ERROR);
- return resultset->getRowSet().getFieldAsI64(column_idx, buffer, is_null_value, err_buf,
- err_buf_len);
-}
-
-HiveReturn DBGetFieldAsI64U(HiveResultSet* resultset, size_t column_idx, uint64_t* buffer,
- int* is_null_value, char* err_buf, size_t err_buf_len) {
- RETURN_ON_ASSERT(resultset == NULL, __FUNCTION__,
- "Hive resultset cannot be NULL.", err_buf, err_buf_len, HIVE_ERROR);
- return resultset->getRowSet().getFieldAsI64U(column_idx, buffer, is_null_value, err_buf,
- err_buf_len);
-}
-
-HiveReturn DBCloseColumnDesc(HiveColumnDesc* column_desc, char* err_buf, size_t err_buf_len) {
- RETURN_ON_ASSERT(column_desc == NULL, __FUNCTION__,
- "Hive column descriptor cannot be NULL.", err_buf, err_buf_len, HIVE_ERROR);
- delete column_desc;
- return HIVE_SUCCESS;
-}
-
-/* Forego the error message handling in these accessor functions b/c of trivial implementations */
-void DBGetColumnName(HiveColumnDesc* column_desc, char* buffer, size_t buffer_len) {
- assert(column_desc != NULL);
- assert(buffer != NULL);
- column_desc->getColumnName(buffer, buffer_len);
-}
-
-void DBGetColumnType(HiveColumnDesc* column_desc, char* buffer, size_t buffer_len) {
- assert(column_desc != NULL);
- assert(buffer != NULL);
- column_desc->getColumnType(buffer, buffer_len);
-}
-
-HiveType DBGetHiveType(HiveColumnDesc* column_desc) {
- assert(column_desc != NULL);
- return column_desc->getHiveType();
-}
-
-int DBGetIsNullable(HiveColumnDesc* column_desc) {
- assert(column_desc != NULL);
- return column_desc->getIsNullable();
-}
-
-int DBGetIsCaseSensitive(HiveColumnDesc* column_desc) {
- assert(column_desc != NULL);
- return column_desc->getIsCaseSensitive();
-}
-
-size_t DBGetMaxDisplaySize(HiveColumnDesc* column_desc) {
- assert(column_desc != NULL);
- return column_desc->getMaxDisplaySize();
-}
-
-size_t DBGetFieldByteSize(HiveColumnDesc* column_desc) {
- assert(column_desc != NULL);
- return column_desc->getFieldByteSize();
-}
-
http://git-wip-us.apache.org/repos/asf/hive/blob/3468a666/odbc/src/cpp/hiveclient.h
----------------------------------------------------------------------
diff --git a/odbc/src/cpp/hiveclient.h b/odbc/src/cpp/hiveclient.h
deleted file mode 100644
index f1af670..0000000
--- a/odbc/src/cpp/hiveclient.h
+++ /dev/null
@@ -1,598 +0,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.
- *
- ******************************************************************************
- *
- * @file hiveclient.h
- * @brief Hive client library interface.
- *
- * This header file defines the Hive client library interface (C compatible).
- * All interactions with Hive client should be directed through the following
- * declared functions.
- *
- * Here is an example of a typical order with which to call these functions:
- *
- * DBOpenConnection
- * ..-> DBExecute or DBTables or DBColumns
- * ..-> DBCreateColumnDesc
- * ....-> DBGetColumnName
- * ....-> DBGetColumnType
- * ....-> DBGetHiveType
- * ....-> DBGetIsNullable
- * ....-> DBGetIsCaseSensitive
- * ....-> DBGetMaxDisplaySize
- * ....-> DBGetFieldByteSize
- * ....-> DBCloseColumnDesc
- * ..-> DBHasResults
- * ..-> DBGetColumnCount
- * ..-> DBFetch
- * ....-> DBGetFieldDataLen
- * ....-> DBGetFieldAsCString
- * ....-> DBGetFieldAsDouble
- * ....-> DBGetFieldAsInt
- * ....-> DBGetFieldAsLong
- * ....-> DBGetFieldAsULong
- * ....-> DBGetFieldAsI64
- * ....-> DBGetFieldAsI64U
- * ..-> DBCloseResultSet
- * ..-> DBCloseConnection
- *
- *****************************************************************************/
-
-
-#ifndef __hive_client_h__
-#define __hive_client_h__
-
-#ifndef __STDC_FORMAT_MACROS
-#define __STDC_FORMAT_MACROS
-#endif
-#include <inttypes.h>
-#include <stdint.h>
-
-#include "hiveconstants.h"
-
-
-/******************************************************************************
- * Hive Client C++ Class Placeholders
- *****************************************************************************/
-
-typedef enum HiveReturn HiveReturn;
-typedef enum HiveType HiveType;
-typedef struct HiveConnection HiveConnection;
-typedef struct HiveResultSet HiveResultSet;
-typedef struct HiveColumnDesc HiveColumnDesc;
-
-#ifdef __cplusplus
-extern "C" {
-#endif // __cplusplus
-
-
-/******************************************************************************
- * Global Hive Client Functions (usable as C callback functions)
- *****************************************************************************/
-
-/**
- * @brief Connect to a Hive database.
- *
- * Connects to a Hive database on the specified Hive server. The caller takes
- * ownership of the returned HiveConnection and is responsible for deallocating
- * the memory and connection by calling DBCloseConnection.
- *
- * @see DBCloseConnection()
- *
- * @param database Name of the Hive database on the Hive server to which to connect.
- * @param host Host address of the Hive server.
- * @param port Host port of the Hive server.
- * @param framed Set as 1 to use a framed socket, or 0 to use a buffered socket.
- * @param err_buf Buffer to receive an error message if HIVE_ERROR is returned.
- * NULL can be used if the caller does not care about the error message.
- * @param err_buf_len Size of the err_buf buffer.
- *
- * @return A HiveConnection object representing the established database connection,
- * or NULL if an error occurred. Error messages will be stored in err_buf.
- */
-HiveConnection* DBOpenConnection(const char* database, const char* host, int port, int framed,
- char* err_buf, size_t err_buf_len);
-
-/**
- * @brief Disconnects from a Hive database.
- *
- * Disconnects from a Hive database and destroys the supplied HiveConnection object.
- * This function should eventually be called for every HiveConnection created by
- * DBOpenConnection.
- *
- * @see DBOpenConnection()
- *
- * @param connection A HiveConnection object associated a database connection.
- * @param err_buf Buffer to receive an error message if HIVE_ERROR is returned.
- * NULL can be used if the caller does not care about the error message.
- * @param err_buf_len Size of the err_buf buffer.
- *
- * @return HIVE_SUCCESS if successful, or HIVE_ERROR if an error occurred
- * (error messages will be stored in err_buf)
- */
-HiveReturn DBCloseConnection(HiveConnection* connection, char* err_buf, size_t err_buf_len);
-
-/**
- * @brief Execute a query.
- *
- * Executes a query on a Hive connection and associates a HiveResultSet with the result.
- * Caller takes ownership of returned HiveResultSet and is responsible for deallocating
- * the object by calling DBCloseResultSet.
- *
- * @see DBCloseResultSet()
- *
- * @param connection A HiveConnection object associated a database connection.
- * @param query The Hive query string to be executed.
- * @param resultset_ptr A pointer to a HiveResultSet pointer which will be associated with the
- * result, or NULL if the result is not needed.
- * @param max_buf_rows Maximum number of rows to buffer in the new HiveResultSet for the query
- * results
- * @param err_buf Buffer to receive an error message if HIVE_ERROR is returned.
- * NULL can be used if the caller does not care about the error message.
- * @param err_buf_len Size of the err_buf buffer.
- *
- * @return HIVE_SUCCESS if successful, or HIVE_ERROR if an error occurred
- * (error messages will be stored in err_buf)
- */
-HiveReturn DBExecute(HiveConnection* connection, const char* query, HiveResultSet** resultset_ptr,
- int max_buf_rows, char* err_buf, size_t err_buf_len);
-
-/**
- * @brief Query for database tables.
- *
- * Gets a resultset containing the set of tables in the database matching a regex pattern.
- * Caller takes ownership of returned HiveResultSet and is responsible for deallocating
- * the object by calling DBCloseResultSet.
- *
- * @see DBCloseResultSet()
- *
- * @param connection A HiveConnection object associated a database connection.
- * @param tbl_search_pattern A regex pattern used to match with table names (use '*' to match all).
- * @param resultset_ptr A pointer to a HiveResultSet pointer which will be associated with the
- * result.
- * @param err_buf Buffer to receive an error message if HIVE_ERROR is returned.
- * NULL can be used if the caller does not care about the error message.
- * @param err_buf_len Size of the err_buf buffer.
- *
- * @return HIVE_SUCCESS if successful, or HIVE_ERROR if an error occurred
- * (error messages will be stored in err_buf)
- */
-HiveReturn DBTables(HiveConnection* connection, const char* tbl_search_pattern,
- HiveResultSet** resultset_ptr, char* err_buf, size_t err_buf_len);
-
-/**
- * @brief Query for columns in table(s).
- *
- * Gets a resultset containing the set of columns in the database matching a regex pattern
- * from a set of tables matching another regex pattern. Caller takes ownership of returned
- * HiveResultSet and is responsible for deallocating the object by calling DBCloseResultSet.
- *
- * @see DBCloseResultSet()
- *
- * @param connection A HiveConnection object associated with a database connection.
- * @param fpHiveToSQLType Pointer to a function that takes a HiveType argument and returns a
- * corresponding int value (possibly a SQL type).
- * @param tbl_search_pattern A regex pattern used to match with table names (use '*' to match all).
- * @param col_search_pattern A regex pattern used to match with column names (use '*' to match all).
- * @param resultset_ptr A pointer to a HiveResultSet pointer which will be associated with the
- * result.
- * @param err_buf Buffer to receive an error message if HIVE_ERROR is returned.
- * NULL can be used if the caller does not care about the error message.
- * @param err_buf_len Size of the err_buf buffer.
- *
- * @return HIVE_SUCCESS if successful, or HIVE_ERROR if an error occurred
- * (error messages will be stored in err_buf)
- */
-HiveReturn DBColumns(HiveConnection* connection, int (*fpHiveToSQLType)(HiveType),
- const char* tbl_search_pattern, const char* col_search_pattern,
- HiveResultSet** resultset_ptr, char* err_buf, size_t err_buf_len);
-
-/**
- * @brief Destroys any specified HiveResultSet object.
- *
- * Destroys any specified HiveResultSet object. The HiveResultSet may have been
- * created by a number of other functions.
- *
- * @param resultset A HiveResultSet object to be removed from memory.
- * @param err_buf Buffer to receive an error message if HIVE_ERROR is returned.
- * NULL can be used if the caller does not care about the error message.
- * @param err_buf_len Size of the err_buf buffer.
- *
- * @return HIVE_SUCCESS if successful, or HIVE_ERROR if an error occurred
- * (error messages will be stored in err_buf)
- */
-HiveReturn DBCloseResultSet(HiveResultSet* resultset, char* err_buf, size_t err_buf_len);
-
-/**
- * @brief Fetches the next unfetched row in a HiveResultSet.
- *
- * Fetches the next unfetched row in a HiveResultSet. The fetched row will be stored
- * internally within the resultset and may be accessed through other DB functions.
- *
- * @param resultset A HiveResultSet from which to fetch rows.
- * @param err_buf Buffer to receive an error message if HIVE_ERROR is returned.
- * NULL can be used if the caller does not care about the error message.
- * @param err_buf_len Size of the err_buf buffer.
- *
- * @return HIVE_SUCCESS if successful,
- * HIVE_ERROR if an error occurred,
- * HIVE_NO_MORE_DATA if there are no more rows to fetch.
- * (error messages will be stored in err_buf)
- */
-HiveReturn DBFetch(HiveResultSet* resultset, char* err_buf, size_t err_buf_len);
-
-/**
- * @brief Check for results.
- *
- * Determines whether the HiveResultSet has ever had any result rows.
- *
- * @param resultset A HiveResultSet from which to check for results.
- * @param has_results Pointer to an int which will be set to 1 if results, 0 if no results.
- * @param err_buf Buffer to receive an error message if HIVE_ERROR is returned.
- * NULL can be used if the caller does not care about the error message.
- * @param err_buf_len Size of the err_buf buffer.
- *
- * @return HIVE_SUCCESS if successful, or HIVE_ERROR if an error occurred
- * (error messages will be stored in err_buf)
- */
-HiveReturn DBHasResults(HiveResultSet* resultset, int* has_results, char* err_buf,
- size_t err_buf_len);
-
-/**
- * @brief Determines the number of columns in the HiveResultSet.
- *
- * @param resultset A HiveResultSet from which to retrieve the column count.
- * @param col_count Pointer to a size_t which will be set to the number of columns in the result.
- * @param err_buf Buffer to receive an error message if HIVE_ERROR is returned.
- * NULL can be used if the caller does not care about the error message.
- * @param err_buf_len Size of the err_buf buffer.
- *
- * @return HIVE_SUCCESS if successful, or HIVE_ERROR if an error occurred
- * (error messages will be stored in err_buf)
- */
-HiveReturn DBGetColumnCount(HiveResultSet* resultset, size_t* col_count, char* err_buf,
- size_t err_buf_len);
-
-/**
- * @brief Construct a HiveColumnDesc.
- *
- * Constructs a HiveColumnDesc with information about a specified column in the resultset.
- * Caller takes ownership of returned HiveColumnDesc and is responsible for deallocating
- * the object by calling DBCloseColumnDesc.
- *
- * @see DBCloseColumnDesc()
- *
- * @param resultset A HiveResultSet context from which to construct the HiveColumnDesc.
- * @param column_idx Zero offset index of a column.
- * @param column_desc_ptr A pointer to a HiveColumnDesc pointer which will receive the new
- * HiveColumnDesc.
- * @param err_buf Buffer to receive an error message if HIVE_ERROR is returned.
- * NULL can be used if the caller does not care about the error message.
- * @param err_buf_len Size of the err_buf buffer.
- *
- * @return HIVE_SUCCESS if successful, or HIVE_ERROR if an error occurred
- * (error messages will be stored in err_buf)
- */
-HiveReturn DBCreateColumnDesc(HiveResultSet* resultset, size_t column_idx,
- HiveColumnDesc** column_desc_ptr, char* err_buf, size_t err_buf_len);
-
-/**
- * @brief Find the size of a field as a string.
- *
- * Determines the number of characters needed to display a field stored in the fetched row
- * of a HiveResultSet.
- *
- * @param resultset An initialized HiveResultSet.
- * @param column_idx Zero offset index of a column.
- * @param col_len Pointer to an size_t which will be set to the byte length of the specified field.
- * @param err_buf Buffer to receive an error message if HIVE_ERROR is returned.
- * NULL can be used if the caller does not care about the error message.
- * @param err_buf_len Size of the err_buf buffer.
- *
- * @return HIVE_SUCCESS if successful, or HIVE_ERROR if an error occurred
- * (error messages will be stored in err_buf)
- */
-HiveReturn DBGetFieldDataLen(HiveResultSet* resultset, size_t column_idx, size_t* col_len,
- char* err_buf, size_t err_buf_len);
-
-/**
- * @brief Get a field as a C string.
- *
- * Reads out a field from the currently fetched rowset in a resultset as a C String.
- *
- * @param resultset An initialized HiveResultSet.
- * @param column_idx Zero offset index of a column.
- * @param buffer Pointer to a buffer that will receive the data.
- * @param buffer_len Number of bytes allocated to buffer.
- * @param data_byte_size Pointer to an size_t which will contain the length of the data available
- * to return before calling this function. Can be set to NULL if this
- * information is not needed.
- * @param is_null_value Pointer to an int which will be set to 1 if the field contains a NULL value,
- * or 0 otherwise.
- * @param err_buf Buffer to receive an error message if HIVE_ERROR is returned.
- * NULL can be used if the caller does not care about the error message.
- * @param err_buf_len Size of the err_buf buffer.
- *
- * @return HIVE_SUCCESS if successful and there is no more data to fetch
- * HIVE_ERROR if an error occurred (error messages will be stored in err_buf)
- * HIVE_SUCCESS_WITH_MORE_DATA if data has been successfully fetched, but there is still
- * more data to get
- * HIVE_NO_MORE_DATA if this field has already been completely fetched
- */
-HiveReturn DBGetFieldAsCString(HiveResultSet* resultset, size_t column_idx, char* buffer,
- size_t buffer_len, size_t* data_byte_size, int* is_null_value,
- char* err_buf, size_t err_buf_len);
-
-/**
- * @brief Get a field as a double.
- *
- * Reads out a field from the currently fetched rowset in a resultset as a double
- * (platform specific).
- *
- * @param resultset An initialized HiveResultSet.
- * @param column_idx Zero offset index of a column.
- * @param buffer Pointer to a double that will receive the data.
- * @param is_null_value Pointer to an int which will be set to 1 if the field contains a NULL value,
- * or 0 otherwise
- * @param err_buf Buffer to receive an error message if HIVE_ERROR is returned.
- * NULL can be used if the caller does not care about the error message.
- * @param err_buf_len Size of the err_buf buffer.
- *
- * @return HIVE_SUCCESS if successful.
- * HIVE_ERROR if an error occurred (error messages will be stored in err_buf)
- * HIVE_NO_MORE_DATA if this field has already been fetched
- */
-HiveReturn DBGetFieldAsDouble(HiveResultSet* resultset, size_t column_idx, double* buffer,
- int* is_null_value, char* err_buf, size_t err_buf_len);
-
-/**
- * @brief Get a field as an int.
- *
- * Reads out a field from the currently fetched rowset in a resultset as an int
- * (platform specific).
- *
- * @param resultset An initialized HiveResultSet.
- * @param column_idx Zero offset index of a column.
- * @param buffer Pointer to an int that will receive the data.
- * @param is_null_value Pointer to an int which will be set to 1 if the field contains a NULL value,
- * or 0 otherwise
- * @param err_buf Buffer to receive an error message if HIVE_ERROR is returned.
- * NULL can be used if the caller does not care about the error message.
- * @param err_buf_len Size of the err_buf buffer.
- *
- * @return HIVE_SUCCESS if successful.
- * HIVE_ERROR if an error occurred (error messages will be stored in err_buf)
- * HIVE_NO_MORE_DATA if this field has already been fetched
- */
-HiveReturn DBGetFieldAsInt(HiveResultSet* resultset, size_t column_idx, int* buffer,
- int* is_null_value, char* err_buf, size_t err_buf_len);
-
-/**
- * @brief Get a field as a long int.
- *
- * Reads out a field from the currently fetched rowset in a resultset as a long int
- * (platform specific).
- *
- * @param resultset An initialized HiveResultSet.
- * @param column_idx Zero offset index of a column.
- * @param buffer Pointer to a long int that will receive the data.
- * @param is_null_value Pointer to an int which will be set to 1 if the field contains a NULL value,
- * or 0 otherwise
- * @param err_buf Buffer to receive an error message if HIVE_ERROR is returned.
- * NULL can be used if the caller does not care about the error message.
- * @param err_buf_len Size of the err_buf buffer.
- *
- * @return HIVE_SUCCESS if successful.
- * HIVE_ERROR if an error occurred (error messages will be stored in err_buf)
- * HIVE_NO_MORE_DATA if this field has already been fetched
- */
-HiveReturn DBGetFieldAsLong(HiveResultSet* resultset, size_t column_idx, long* buffer,
- int* is_null_value, char* err_buf, size_t err_buf_len);
-
-/**
- * @brief Get a field as an unsigned long int.
- *
- * Reads out a field from the currently fetched rowset in a resultset as an unsigned long int
- * (platform specific).
- *
- * @param resultset An initialized HiveResultSet.
- * @param column_idx Zero offset index of a column.
- * @param buffer Pointer to an unsigned long int that will receive the data.
- * @param is_null_value Pointer to an int which will be set to 1 if the field contains a NULL value,
- * or 0 otherwise
- * @param err_buf Buffer to receive an error message if HIVE_ERROR is returned.
- * NULL can be used if the caller does not care about the error message.
- * @param err_buf_len Size of the err_buf buffer.
- *
- * @return HIVE_SUCCESS if successful.
- * HIVE_ERROR if an error occurred (error messages will be stored in err_buf)
- * HIVE_NO_MORE_DATA if this field has already been fetched
- */
-HiveReturn DBGetFieldAsULong(HiveResultSet* resultset, size_t column_idx, unsigned long* buffer,
- int* is_null_value, char* err_buf, size_t err_buf_len);
-
-/**
- * @brief Get a field as an int64_t.
- *
- * Reads out a field from the currently fetched rowset in a resultset as a int64_t
- * (platform independent).
- *
- * @param resultset An initialized HiveResultSet.
- * @param column_idx Zero offset index of a column.
- * @param buffer Pointer to a int64_t that will receive the data.
- * @param is_null_value Pointer to an int which will be set to 1 if the field contains a NULL value,
- * or 0 otherwise
- * @param err_buf Buffer to receive an error message if HIVE_ERROR is returned.
- * NULL can be used if the caller does not care about the error message.
- * @param err_buf_len Size of the err_buf buffer.
- *
- * @return HIVE_SUCCESS if successful.
- * HIVE_ERROR if an error occurred (error messages will be stored in err_buf)
- * HIVE_NO_MORE_DATA if this field has already been fetched
- */
-HiveReturn DBGetFieldAsI64(HiveResultSet* resultset, size_t column_idx, int64_t* buffer,
- int* is_null_value, char* err_buf, size_t err_buf_len);
-
-/**
- * @brief Get a field as an uint64_t.
- *
- * Reads out a field from the currently fetched rowset in a resultset as a uint64_t
- * (platform independent).
- *
- * @param resultset An initialized HiveResultSet.
- * @param column_idx Zero offset index of a column.
- * @param buffer Pointer to a uint64_t that will receive the data.
- * @param is_null_value Pointer to an int which will be set to 1 if the field contains a NULL value,
- * or 0 otherwise
- * @param err_buf Buffer to receive an error message if HIVE_ERROR is returned.
- * NULL can be used if the caller does not care about the error message.
- * @param err_buf_len Size of the err_buf buffer.
- *
- * @return HIVE_SUCCESS if successful.
- * HIVE_ERROR if an error occurred (error messages will be stored in err_buf)
- * HIVE_NO_MORE_DATA if this field has already been fetched
- */
-HiveReturn DBGetFieldAsI64U(HiveResultSet* resultset, size_t column_idx, uint64_t* buffer,
- int* is_null_value, char* err_buf, size_t err_buf_len);
-
-/**
- * @brief Destroys a HiveColumnDesc object.
- *
- * @see DBCreateColumnDesc()
- *
- * @param column_desc A HiveColumnDesc object to be removed from memory.
- * @param err_buf Buffer to receive an error message if HIVE_ERROR is returned.
- * NULL can be used if the caller does not care about the error message.
- * @param err_buf_len Size of the err_buf buffer.
- *
- * @return HIVE_SUCCESS if successful, or HIVE_ERROR if an error occurred
- * (error messages will be stored in err_buf)
- */
-HiveReturn DBCloseColumnDesc(HiveColumnDesc* column_desc, char* err_buf, size_t err_buf_len);
-
-/**
- * @brief Get a column name.
- *
- * Retrieves the column name of the associated column in the result table from
- * a HiveColumnDesc.
- *
- * @see DBCreateColumnDesc()
- *
- * @param column_desc A HiveColumnDesc associated with the column in question.
- * @param buffer Pointer to a buffer that will receive the column name as a C string
- * @param buffer_len Number of bytes allocated to buffer
- *
- * @return void
- */
-void DBGetColumnName(HiveColumnDesc* column_desc, char* buffer, size_t buffer_len);
-
-/**
- * @brief Get the column type name.
- *
- * Retrieves the name of the column type of the associated column in the result table
- * from a HiveColumnDesc.
- *
- * @see DBCreateColumnDesc()
- *
- * @param column_desc A HiveColumnDesc associated with the column in question.
- * @param buffer Pointer to a buffer that will receive the column type name as a C string
- * @param buffer_len Number of bytes allocated to buffer
- *
- * @return void
- */
-void DBGetColumnType(HiveColumnDesc* column_desc, char* buffer, size_t buffer_len);
-
-/**
- * @brief Get the column type as a HiveType.
- *
- * Retrieves the column type as a HiveType for the associated column in the result table
- * from a HiveColumnDesc.
- *
- * @see DBCreateColumnDesc()
- *
- * @param column_desc A HiveColumnDesc associated with the column in question.
- *
- * @return HiveType of the column.
- */
-HiveType DBGetHiveType(HiveColumnDesc* column_desc);
-
-/**
- * @brief Finds whether a column is nullable.
- *
- * Determines from a HiveColumnDesc whether a particular column in the result table is
- * able to contain NULLs.
- *
- * @see DBCreateColumnDesc()
- *
- * @param column_desc A HiveColumnDesc associated with the column in question.
- *
- * @return 1 if the column can contain NULLs, or
- * 0 if the column cannot contain NULLs
- */
-int DBGetIsNullable(HiveColumnDesc* column_desc);
-
-/**
- * @brief Finds whether a column is case sensitive.
- *
- * Determines from a HiveColumnDesc whether a particular column in the result table contains case
- * sensitive data
- *
- * @see DBCreateColumnDesc()
- *
- * @param column_desc A HiveColumnDesc associated with the column in question.
- *
- * @return 1 if the column data is case sensitive, or
- * 0 otherwise
- */
-int DBGetIsCaseSensitive(HiveColumnDesc* column_desc);
-
-/**
- * @brief Finds the max display size of a column's fields.
- *
- * From a HiveColumnDesc, determines the maximum number of characters needed to represent a
- * field within this column.
- *
- * @see DBCreateColumnDesc()
- *
- * @param column_desc A HiveColumnDesc associated with the column in question.
- *
- * @return The maximum number of characters needed to represent a field within this column.
- */
-size_t DBGetMaxDisplaySize(HiveColumnDesc* column_desc);
-
-/**
- * @brief Finds the max (native) byte size of a column's fields.
- *
- * From a HiveColumnDesc, determines the number of bytes needed to store a field within this
- * column in its native type.
- *
- * @see DBCreateColumnDesc()
- *
- * @param column_desc A HiveColumnDesc associated with the column in question.
- *
- * @return The number of bytes needed to store a field within this column in its native type.
- */
-size_t DBGetFieldByteSize(HiveColumnDesc* column_desc);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif // __cpluscplus
-
-
-#endif // __hive_client_h__
http://git-wip-us.apache.org/repos/asf/hive/blob/3468a666/odbc/src/cpp/hiveclienthelper.cpp
----------------------------------------------------------------------
diff --git a/odbc/src/cpp/hiveclienthelper.cpp b/odbc/src/cpp/hiveclienthelper.cpp
deleted file mode 100644
index b0f3aae..0000000
--- a/odbc/src/cpp/hiveclienthelper.cpp
+++ /dev/null
@@ -1,86 +0,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.
- */
-
-#include <algorithm>
-#include <assert.h>
-#include <string.h>
-
-#include "hiveclienthelper.h"
-#include "thriftserverconstants.h"
-
-using namespace std;
-
-/*****************************************************************
- * File Scope Variables (used only within this file)
- *****************************************************************/
-
-/*
- * g_hive_type_table: An array of HiveTypePairs used to define the mapping
- * between the name of a HiveType and its value. This array is only
- * used by the hiveTypeLookup function.
- */
-struct HiveTypePair {
- const char* type_name;
- const HiveType type_value;
-};
-
-static const HiveTypePair g_hive_type_table[] = {
- {VOID_TYPE_NAME, HIVE_VOID_TYPE},
- {BOOLEAN_TYPE_NAME, HIVE_BOOLEAN_TYPE},
- {TINYINT_TYPE_NAME, HIVE_TINYINT_TYPE},
- {SMALLINT_TYPE_NAME, HIVE_SMALLINT_TYPE},
- {INT_TYPE_NAME, HIVE_INT_TYPE},
- {BIGINT_TYPE_NAME, HIVE_BIGINT_TYPE},
- {FLOAT_TYPE_NAME, HIVE_FLOAT_TYPE},
- {DOUBLE_TYPE_NAME, HIVE_DOUBLE_TYPE},
- {STRING_TYPE_NAME, HIVE_STRING_TYPE},
- {DATE_TYPE_NAME, HIVE_DATE_TYPE},
- {DATETIME_TYPE_NAME, HIVE_DATETIME_TYPE},
- {TIMESTAMP_TYPE_NAME, HIVE_TIMESTAMP_TYPE},
- {LIST_TYPE_NAME, HIVE_LIST_TYPE},
- {MAP_TYPE_NAME, HIVE_MAP_TYPE},
- {STRUCT_TYPE_NAME, HIVE_STRUCT_TYPE}
-};
-
-/*****************************************************************
- * Global Helper Functions
- *****************************************************************/
-
-HiveType hiveTypeLookup(const char* hive_type_name) {
- assert(hive_type_name != NULL);
- for (unsigned int idx = 0; idx < LENGTH(g_hive_type_table); idx++) {
- if (strcmp(hive_type_name, g_hive_type_table[idx].type_name) == 0) {
- return g_hive_type_table[idx].type_value;
- }
- }
- return HIVE_UNKNOWN_TYPE;
-}
-
-size_t safe_strncpy(char* dest_buffer, const char* src_buffer, size_t num) {
- /* Make sure arguments are valid */
- if (num == 0 || dest_buffer == NULL || src_buffer == NULL)
- return 0;
-
- size_t len = min(num - 1, strlen(src_buffer));
- strncpy(dest_buffer, src_buffer, len); /* Copy only as much as needed */
- dest_buffer[len] = '\0'; /* NULL terminate in case strncpy copies exactly num-1 characters */
-
- /* Returns the number of bytes copied into the destination buffer (excluding the null terminator)*/
- return len;
-}
-
http://git-wip-us.apache.org/repos/asf/hive/blob/3468a666/odbc/src/cpp/hiveclienthelper.h
----------------------------------------------------------------------
diff --git a/odbc/src/cpp/hiveclienthelper.h b/odbc/src/cpp/hiveclienthelper.h
deleted file mode 100644
index 5814a03..0000000
--- a/odbc/src/cpp/hiveclienthelper.h
+++ /dev/null
@@ -1,132 +0,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.
- *
- ******************************************************************************
- *
- * @file hiveclienthelper.h
- * @brief Provides some commonly used functions and macros.
- *
- *****************************************************************************/
-
-
-#ifndef __hive_client_helper_h__
-#define __hive_client_helper_h__
-
-#include <iostream>
-
-#include "hiveconstants.h"
-
-
-// TODO: add architecture specific macro definitions here if needed
-#ifdef ARCH32
-
-#elif defined(ARCH64)
-
-#else
-
-#endif
-
-/*****************************************************************
- * Macro Functions
- *****************************************************************/
-
-/**
- * @brief A macro that converts a string to a signed 64 bit integer.
- *
- * Macro will work for both 32 and 64 bit architectures
- */
-#define ATOI64(val) int64_t(strtoll(val, NULL, 10))
-
-/**
- * @brief A macro that converts a string to an unsigned 64 bit integer.
- *
- * Macro will work for both 32 and 64 bit architectures
- */
-#define ATOI64U(val) uint64_t(strtoull(val, NULL, 10))
-
-/**
- * @brief Convert a Macro'ed value to a string.
- *
- * Callers should only call STRINGIFY(x) and
- * should never use XSTRINGIFY(x)
- */
-#define STRINGIFY(x) XSTRINGIFY(x)
-#define XSTRINGIFY(x) #x
-
-/**
- * @brief Finds the number of elements in an array
- */
-#define LENGTH(arr) (sizeof(arr)/sizeof(arr[0]))
-
-/**
- * Checks an error condition, and if true:
- * 1. prints the error
- * 2. saves the message to err_buf
- * 3. returns the specified ret_val
- */
-#define RETURN_ON_ASSERT(condition, funct_name, error_msg, err_buf, err_buf_len, ret_val) { \
- if (condition) { \
- cerr << funct_name << ": " << error_msg << endl << flush; \
- safe_strncpy(err_buf, error_msg, err_buf_len); \
- return ret_val; \
- } \
-}
-
-/**
- * Always performs the following:
- * 1. prints the error
- * 2. saves the message to err_buf
- * 3. returns the specified ret_val
- */
-#define RETURN_FAILURE(funct_name, error_msg, err_buf, err_buf_len, ret_val) { \
- RETURN_ON_ASSERT(true, funct_name, error_msg, err_buf, err_buf_len, ret_val); \
-}
-
-/*****************************************************************
- * Global Helper Functions
- *****************************************************************/
-
-/**
- * @brief Convert the name of a HiveType to its actual value.
- *
- * Returns the corresponding HiveType enum given the name of a Hive data type.
- * This function is case sensitive.
- * For example: hiveTypeLookup("string") => HIVE_STRING_TYPE
- *
- * @param hive_type_name Name of a HiveType
- * @return The corresponding HiveType
- */
-HiveType hiveTypeLookup(const char* hive_type_name);
-
-/**
- * @brief Safe version of strncpy.
- *
- * A version of strncpy that guarantees the existance of '\0' at the end of the supplied buffer
- * to prevent buffer overruns. Instead of returning dest_buffer like strncpy, safe_strncpy
- * returns the number of bytes written to dest_buffer (excluding the null terminator).
- *
- * @param dest_buffer Buffer to write into.
- * @param src_buffer Buffer to copy from.
- * @param num The size of the destination buffer in bytes.
- *
- * @return Number of bytes copied into the destination buffer (excluding the null terminator).
- */
-size_t safe_strncpy(char* dest_buffer, const char* src_buffer, size_t num);
-
-
-#endif // __hive_client_helper_h__
http://git-wip-us.apache.org/repos/asf/hive/blob/3468a666/odbc/src/cpp/hiveconstants.h
----------------------------------------------------------------------
diff --git a/odbc/src/cpp/hiveconstants.h b/odbc/src/cpp/hiveconstants.h
deleted file mode 100644
index 72f1049..0000000
--- a/odbc/src/cpp/hiveconstants.h
+++ /dev/null
@@ -1,83 +0,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.
- *
- ******************************************************************************
- *
- * @file hiveconstants.h
- * @brief Provides constants necessary for library caller interaction with Hive Client
- *
- *****************************************************************************/
-
-
-#ifndef __hive_constants_h__
-#define __hive_constants_h__
-
-/// Maximum length of a Hive Client error message
-static const int MAX_HIVE_ERR_MSG_LEN = 128;
-/// Maximum length of a column name
-static const int MAX_COLUMN_NAME_LEN = 64;
-/// Maximum length of a column type name
-static const int MAX_COLUMN_TYPE_LEN = 64;
-
-
-/* Default connection parameters */
-/// Default Hive database name
-static const char* DEFAULT_DATABASE = "default";
-/// Default Hive Server host
-static const char* DEFAULT_HOST = "localhost";
-/// Default Hive Server port
-static const char* DEFAULT_PORT = "10000";
-/// Default connection socket type
-static const char* DEFAULT_FRAMED = "0";
-
-/**
- * Enumeration of known Hive data types
- */
-enum HiveType
-{
- HIVE_VOID_TYPE,
- HIVE_BOOLEAN_TYPE,
- HIVE_TINYINT_TYPE,
- HIVE_SMALLINT_TYPE,
- HIVE_INT_TYPE,
- HIVE_BIGINT_TYPE,
- HIVE_FLOAT_TYPE,
- HIVE_DOUBLE_TYPE,
- HIVE_STRING_TYPE,
- HIVE_DATE_TYPE,
- HIVE_DATETIME_TYPE,
- HIVE_TIMESTAMP_TYPE,
- HIVE_LIST_TYPE,
- HIVE_MAP_TYPE,
- HIVE_STRUCT_TYPE,
- HIVE_UNKNOWN_TYPE
-};
-
-/**
- * Enumeration of Hive return values
- */
-enum HiveReturn
-{
- HIVE_SUCCESS,
- HIVE_ERROR,
- HIVE_NO_MORE_DATA,
- HIVE_SUCCESS_WITH_MORE_DATA,
- HIVE_STILL_EXECUTING
-};
-
-#endif // __hive_constants_h__
http://git-wip-us.apache.org/repos/asf/hive/blob/3468a666/odbc/src/cpp/thriftserverconstants.h
----------------------------------------------------------------------
diff --git a/odbc/src/cpp/thriftserverconstants.h b/odbc/src/cpp/thriftserverconstants.h
deleted file mode 100644
index fe4bac4..0000000
--- a/odbc/src/cpp/thriftserverconstants.h
+++ /dev/null
@@ -1,64 +0,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.
- *
- ******************************************************************************
- *
- * @file thriftserverconstants.h
- * @brief Provides constants necessary for Hive Client interaction with Hive Server
- *
- *****************************************************************************/
-
-
-#ifndef __thrift_server_constants_h__
-#define __thrift_server_constants_h__
-
-/// Maximum number of characters needed to display any field
-static const int MAX_DISPLAY_SIZE = 334;
-/// Maximum number of bytes needed to store any field
-static const int MAX_BYTE_LENGTH = 334;
-
-
-/// Default null format string representation
-static const char* DEFAULT_NULL_FORMAT = "\\N";
-
-/// Schema map property key for field delimiters
-static const char* FIELD_DELIM = "field.delim";
-/// Schema map property key for null format
-static const char* SERIALIZATION_NULL_FORMAT = "serialization.null.format";
-
-
-// From: serde/src/gen-java/org/apache/hadoop/hive/serde/Constants.java
-
-static const char* VOID_TYPE_NAME = "void";
-static const char* BOOLEAN_TYPE_NAME = "boolean";
-static const char* TINYINT_TYPE_NAME = "tinyint";
-static const char* SMALLINT_TYPE_NAME = "smallint";
-static const char* INT_TYPE_NAME = "int";
-static const char* BIGINT_TYPE_NAME = "bigint";
-static const char* FLOAT_TYPE_NAME = "float";
-static const char* DOUBLE_TYPE_NAME = "double";
-static const char* STRING_TYPE_NAME = "string";
-static const char* DATE_TYPE_NAME = "date";
-static const char* DATETIME_TYPE_NAME = "datetime";
-static const char* TIMESTAMP_TYPE_NAME = "timestamp";
-static const char* LIST_TYPE_NAME = "array";
-static const char* MAP_TYPE_NAME = "map";
-static const char* STRUCT_TYPE_NAME = "struct";
-
-
-#endif // __thrift_server_constants_h__