src/share/catalog/hive/thrift/README.md
/**
http://license.coscl.org.cn/MulanPubL-2.0
This repository contains the Thrift interface definition files for Apache Hive Metastore, specifically tailored for C++ code generation.
The hive_metastore.thrift file in this directory is copied verbatim from the official Apache Hive 4.0.1 release.
Source reference: Apache Hive GitHub Repository
For Ubuntu/Debian:
sudo apt-get update
sudo apt-get install build-essential cmake libboost-all-dev libssl-dev libevent-dev
For CentOS/RHEL:
sudo yum groupinstall "Development Tools"
sudo yum install cmake boost-devel openssl-devel libevent-devel
To generate C++ client code from the Thrift definition:
cd src/share/catalog/hive/thrift
${THRIFT_HOME}/bin/thrift -I ${THRIFT_HOME} -strict --gen cpp -out ./gen_cpp share/fb303/if/fb303.thrift
${THRIFT_HOME}/bin/thrift -I ${THRIFT_HOME} -strict --gen cpp -out ./gen_cpp hive_metastore.thrift
The generated code will be output to a gen_cpp directory. Ensure you have:
# wget the thrift from official website
tar -xzf thrift-0.16.0.tar.gz
cd thrift-0.16.0
Note: some dev machine without the compatible boost version, then should download and set the --with-boost configure.
./configure --prefix=/usr/local --enable-static --with-c_glib=yes --with-cpp=yes --without-erlang --without-nodejs --without-python --without-py3 --without-perl --without-php --without-php_extension --without-ruby --without-haskell --without-go --without-swift --without-dotnetcore --without-qt5 --enable-tutorial=no --enable-tests=no CFLAGS="-g -O2 -fPIC" CXXFLAGS="-g -O2 -fPIC" --with-boost=/PATH/TO/BOOST
make -j$(nproc)
sudo make install
thrift --version
After installation, set the THRIFT_HOME environment variable:
export THRIFT_HOME=/usr/local # or wherever thrift is installed
export PATH=$THRIFT_HOME/bin:$PATH
Add to your shell profile (.bashrc, .zshrc, etc.) for persistence.
After running the code generation commands, you'll get:
gen_cpp/
├── hive_metastore_constants.cpp
├── hive_metastore_constants.h
├── hive_metastore_types.cpp
├── hive_metastore_types.h
├── hive_metastore.cpp
├── hive_metastore.h
├── fb303_constants.cpp
├── fb303_constants.h
├── fb303_types.cpp
├── fb303_types.h
├── fb303.cpp
└── fb303.h
Common Issues:
"thrift: command not found"
which thrift and thrift --version"Cannot find Thrift headers"
THRIFT_HOME is set correctlyCompilation errors with generated code
STD library may cause performance issue in OBSERVER
Version Compatibility: