You have to install Thrift (0.11.0 or later) to compile our thrift file into python code. Below is the official tutorial of installation:

Installation

  • Option 1: pip install

You can find the Apache IoTDB Python Client API package on https://pypi.org/project/apache-iotdb/.

The download command is:

  • Option 2: basic usage of thrift

Optionally, if you know the basic usage of thrift, you can download the thrift source file in thrift\src\main\thrift\rpc.thrift, and simply run thrift -gen py -out ./target/iotdb rpc.thrift to generate the Python library.

We provided an example of how to use the thrift library to connect to IoTDB in client-py/src /SessionExample.py, please read it carefully before you write your own code.

C++ Native Interfaces

Dependencies

  • Maven 3.5+
  • Flex
  • Bison 2.7+
  • Boost 1.56+
  • OpenSSL 1.0+
  • GCC 5.5.0+

The compilation of CPP client requires the module “compile-tools” to be built first. “compile-tools” is mainly responsible for building Thrift libraries locally.

Build Thrift on MacOS

  • Bison

Bison 2.3 is preinstalled on OSX, but this version is too low. When building Thrift with Bison 2.3, the following error would pop out:

  1. invalid directive: '%code'

For such case, please update Bison:

  1. brew install bison
  2. brew link bison --force

Then, you need to tell the OS where the new bison is.

For Bash users:

  1. echo 'export PATH="/usr/local/opt/bison/bin:$PATH"' >> ~/.bash_profile

For zsh users:

  • Boost

Please make sure a relative new version of Boost is ready on your machine. If no Boost available, install the latest version of Boost:

  1. brew install boost
  2. brew link boost
  • OpenSSL

to specify the OpenSSL installation directory on your Mac.

Build Thrift on Linux

Ubuntu 20:

To install all dependencies, run:

  1. sudo apt-get install gcc-9 g++-9 libstdc++-9-dev bison flex libboost-all-dev libssl-dev zlib1g-dev

CentOS 7.x:

In CentOS 7.x, Some packages can be installed using Yum:

  1. sudo yum install bison flex openssl-devel

The version of gcc and boost installed by yum is too low, therefore you should compile or download these binary packages by yourself.

Build Thrift on Windows

Make sure a complete Windows C++ building environment is prepared on your machine. MSVC, MinGW… are supported.

If you are using MS Visual Studio, remember to install Visual Studio C/C++ IDE and compiler(supporting CMake, Clang, MinGW).

After downloaded, please rename the executables to flex.exe and bison.exe and add them to “PATH” environment variables.

Then build Boost by executing bootstrap.bat and b2.exe.

  1. bootstrap.bat
  2. .\b2.exe

To help CMake find your Boost libraries on windows, you should set -Dboost.include.dir=${your boost header folder} -Dboost.library.dir=${your boost lib (stage) folder} to your mvn build command.

Cmake generator on Windows

the list is available via command: cmake --help

When building client-cpp project, use -Dcmake.generator=”” option to specify a Cmake generator. E.g., mvn package -Dcmake.generator="Visual Studio 15 2017 [arch]"

Building C++ Client

To compile cpp client, add “-P compile-cpp” option to maven build command.

The compiling requires the module “compile-tools” to be built first.

Compile and Test:

mvn package -P compile-cpp -pl example/client-cpp-example -am -DskipTest

To compile on Windows, please install Boost first and add following Maven settings:

  1. -Dboost.include.dir=${your boost header folder} -Dboost.library.dir=${your boost lib (stage) folder}`

e.g.,

  1. mvn package -P compile-cpp -pl client-cpp,server,example/client-cpp-example -am

If the compilation finishes successfully, the packaged zip file will be placed under “client-cpp/target/client-cpp-${project.version}-cpp-${os}.zip”.

On Mac machines, the hierarchy of the package should look like this:

  1. .
  2. +-- client
  3. | +-- include
  4. | +-- Session.h
  5. | +-- TSIService.h
  6. | +-- rpc_types.h
  7. | +-- rpc_constants.h
  8. | +-- thrift
  9. | +-- thrift_headers...
  10. | +-- lib

Q&A

on Mac

If errors occur when compiling thrift source code, try to downgrade your xcode-commandline from 12 to 11.5

see https://stackoverflow.com/questions/63592445/ld-unsupported-tapi-file-type-tapi-tbd-in-yaml-file/65518087#65518087

on Windows

When Building Thrift and downloading packages via “wget”, a possible annoying issue may occur with error message looks like:

  1. Failed to delete cached file C:\Users\Administrator\.m2\repository\.cache\download-maven-plugin\index.ser
  • Try to delete the “.m2\repository\.cache” directory and try again.