### Build C++ Client Examples with Maven Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/examples/README.md Use this Maven command to clean, verify, and build the C++ client and its examples. It also starts a local IoTDB server for testing. ```bash mvn clean verify -P with-cpp -pl iotdb-client/client-cpp -am ``` -------------------------------- ### Build the C REST Client Example Source: https://github.com/apache/iotdb/blob/master/example/rest-client-c-example/README.md Steps to build the C REST client executable using CMake and Make. This process requires libcurl to be installed. ```shell mkdir build cd build cmake .. make ``` -------------------------------- ### Stage Example Binaries and Runtime Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/examples/CMakeLists.txt Collects example binaries and IoTDB runtime into a self-contained distribution directory for easy copying. It stages the main example targets, the IoTDB runtime, and bundled OpenSSL libraries. ```cmake set(_example_dist_dir "${CMAKE_BINARY_DIR}/dist") add_custom_target(example-dist DEPENDS ${_example_targets} COMMENT "Collect example binaries and IoTDB runtime into ${_example_dist_dir}") foreach(_t IN LISTS _example_targets) add_custom_command(TARGET example-dist POST_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${_example_dist_dir}" COMMAND ${CMAKE_COMMAND} -E copy_if_different $ "${_example_dist_dir}/" COMMENT "Stage ${_t}") endforeach() if(EXISTS "${_iotdb_runtime}") add_custom_command(TARGET example-dist POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_iotdb_runtime}" "${_example_dist_dir}/") endif() # Stage the bundled OpenSSL runtime too, so a copied dist/ runs on a machine # without a system OpenSSL. foreach(_ssl_lib IN LISTS _iotdb_sdk_ssl_runtime) add_custom_command(TARGET example-dist POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_ssl_lib}" "${_example_dist_dir}/") endforeach() ``` -------------------------------- ### Install Flex on Ubuntu Source: https://github.com/apache/iotdb/blob/master/README.md Install the Flex lexical analyzer generator on Ubuntu. ```bash sudo apt install flex ``` -------------------------------- ### Install Git on Ubuntu Source: https://github.com/apache/iotdb/blob/master/README.md Install the Git version control system on Ubuntu if it is not already present. ```bash sudo apt install git ``` -------------------------------- ### Stage C++ Examples for Deployment Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/examples/README.md Use this CMake build target to copy all example binaries and the shared IoTDB runtime library to a staging directory for deployment. ```bash cmake --build build --target example-dist ``` -------------------------------- ### Cross-compile the C REST Example Program Source: https://github.com/apache/iotdb/blob/master/example/rest-client-c-example/README.md Compiles the main C REST client example using an ARM cross-compiler. Specify the libcurl installation directory using the -L flag and include path if necessary. ```shell arm-linux-gnueabihf-gcc main.c base64.c -o c_rest -L `(libcurl install dir)/lib/` -l curl ``` -------------------------------- ### Build C++ Examples with CMake Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/examples/README.md Build the configured C++ examples using CMake. This command assumes prior configuration with CMake. ```bash cmake --build build ``` -------------------------------- ### Build Bundled Examples with CMake Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/README.md Use CMake to build the example programs included in the IoTDB C++ client SDK. This command configures the build for release type. ```bash cmake -S examples -B examples-build -DCMAKE_BUILD_TYPE=Release cmake --build examples-build ``` -------------------------------- ### Start IoTDB Server Source: https://github.com/apache/iotdb/blob/master/README.md Execute the appropriate script to start the IoTDB standalone server. This is the first step before interacting with the database. ```shell # Unix/OS X > sbin/start-standalone.sh ``` ```shell # Windows > sbin\start-standalone.bat ``` -------------------------------- ### Run IoTDB Server Docker Container (1.0.0+) Source: https://github.com/apache/iotdb/blob/master/docker/ReadMe.md Example command to run an IoTDB Docker container, including ports for cluster internal metadata and data, starting from version 1.0.0. Consult official documentation for port details. ```shell docker run -d --name iotdb -p 6667:6667 -p 31999:31999 -p 8181:8181 -p 5555:5555 -p 9003:9003 -p 40010:40010 apache/iotdb: ``` -------------------------------- ### Install Java Development Kit on Ubuntu Source: https://github.com/apache/iotdb/blob/master/README.md Install the default Java Development Kit (JDK) on Ubuntu. ```bash sudo apt install default-jdk ``` -------------------------------- ### Install Flex and Bison on Windows Source: https://github.com/apache/iotdb/blob/master/README.md Install Flex and Bison on Windows using the Chocolatey package manager. ```bash choco install winflexbison ``` -------------------------------- ### Configure OpenSSL Runtime Libraries Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/examples/CMakeLists.txt This snippet finds bundled OpenSSL runtime libraries (libssl, libcrypto) in the SDK installation directory. These are used to ensure examples can run without a system-wide OpenSSL installation by copying them next to the example binaries. ```cmake set(_iotdb_sdk_ssl_runtime "") if(NOT _iotdb_examples_in_tree) file(GLOB _iotdb_sdk_ssl_runtime "${IOTDB_SDK_ROOT}/lib/libssl*.so*" "${IOTDB_SDK_ROOT}/lib/libcrypto*.so*" "${IOTDB_SDK_ROOT}/lib/libssl*.dylib" "${IOTDB_SDK_ROOT}/lib/libcrypto*.dylib" "${IOTDB_SDK_ROOT}/lib/libssl*.dll" "${IOTDB_SDK_ROOT}/lib/libcrypto*.dll") endif() ``` -------------------------------- ### Configure C++ Examples with CMake Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/examples/README.md Configure the C++ examples using CMake, specifying the build type and the root directory of the unpacked IoTDB C++ SDK. This is for manual SDK integration. ```bash cmake -S iotdb-client/client-cpp/examples -B build \ -DCMAKE_BUILD_TYPE=Release \ -DIOTDB_SDK_ROOT=/path/to/iotdb-session-cpp-... ``` -------------------------------- ### Install Java on macOS using Homebrew Source: https://github.com/apache/iotdb/blob/master/README.md Install Java using Homebrew on macOS. ```bash brew install java ``` -------------------------------- ### Build Library and Integration Tests (Linux/macOS) Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/README.md This command sequence first installs the distribution and C++ client, then verifies the C++ client with integration tests using Maven. ```bash mvn clean install -P with-cpp -pl distribution,iotdb-client/client-cpp -am ``` ```bash mvn -P with-cpp -pl iotdb-client/client-cpp -am verify ``` -------------------------------- ### Windows File Copy Example Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/examples/README.md List of files to copy to the target Windows machine for running the SessionExample. ```plaintext SessionExample.exe iotdb_session.dll ``` -------------------------------- ### Build Bundled Examples on Windows with CMake Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/README.md Use CMake to build the example programs on Windows, specifying the Visual Studio generator and architecture. This command configures the build for release type. ```bat cmake -S examples -B examples-build -G "Visual Studio 17 2022" -A x64 cmake --build examples-build --config Release ``` -------------------------------- ### Install Public Headers Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/CMakeLists.txt Installs public header files for the IoTDB session client into the include directory. ```cmake foreach(_hdr IN LISTS IOTDB_PUBLIC_HEADERS) install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/include/${_hdr}" DESTINATION include) endforeach() ``` -------------------------------- ### Install Bison on Ubuntu Source: https://github.com/apache/iotdb/blob/master/README.md Install the Bison parser generator on Ubuntu. ```bash sudo apt install bison ``` -------------------------------- ### Build C++ Examples with CMake (Windows) Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/examples/README.md Configure and build the C++ examples on Windows using CMake with the Visual Studio generator. Ensure the correct architecture (e.g., x64) is specified. ```powershell cmake -S . -B build -A x64 cmake --build build --config Release ``` -------------------------------- ### Install Git on Windows using Chocolatey Source: https://github.com/apache/iotdb/blob/master/README.md Install Git for Windows using the Chocolatey package manager. ```bash choco install git.install ``` -------------------------------- ### Install Boost C++ libraries on Ubuntu Source: https://github.com/apache/iotdb/blob/master/README.md Install all Boost C++ libraries on Ubuntu, which may be required for compiling certain software. ```bash sudo apt install libboost-all-dev ``` -------------------------------- ### Create Distribution Folder with CMake Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/README.md Use CMake to build a distribution folder containing examples and the runtime library. This command targets the example-dist build. ```bash cmake --build examples-build --target example-dist ``` -------------------------------- ### Install OpenSSL header files on Ubuntu Source: https://github.com/apache/iotdb/blob/master/README.md Install the OpenSSL development header files on Ubuntu, necessary for compiling software that uses OpenSSL. ```bash sudo apt install libssl-dev ``` -------------------------------- ### Install OpenSSL on Windows using Chocolatey Source: https://github.com/apache/iotdb/blob/master/README.md Install OpenSSL on Windows using the Chocolatey package manager. ```bash choco install openssl ``` -------------------------------- ### Install OpenJDK on Windows using Chocolatey Source: https://github.com/apache/iotdb/blob/master/README.md Install the OpenJDK runtime environment on Windows using the Chocolatey package manager. ```bash choco install openjdk ``` -------------------------------- ### Build C++ Client with Distribution and Skip Tests Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/README.md Use this command to clean, install the distribution and C++ client modules, and skip running tests during the initial build. ```bash mvn clean install -P with-cpp -pl distribution,iotdb-client/client-cpp -am -DskipTests ``` -------------------------------- ### Build and Start RatisConsensusImpl Source: https://github.com/apache/iotdb/blob/master/iotdb-core/consensus/README.md Instantiates and starts a RatisConsensusImpl. Requires specifying the consensus implementation name, endpoint, storage directory, and a state machine factory. The endpoint defines communication, and the storage directory is crucial for log recovery. ```java IConsensus consensusImpl = ConsensusFactory.getConsensusImpl( ConsensusFactory.RatisConsensus, new Endpoint(conf.getRpcAddress(), conf.getInternalPort()), new File(conf.getConsensusDir()), gid -> new ConfigRegionStateMachine()) .orElseThrow(() -> new IllegalArgumentException( String.format( ConsensusFactory.CONSTRUCT_FAILED_MSG, ConsensusFactory.RatisConsensus))); consensusImpl.start(); ``` -------------------------------- ### IoTDB JDBC Client Example Source: https://github.com/apache/iotdb/blob/master/iotdb-client/jdbc/README.md This example demonstrates a comprehensive set of operations using the IoTDB JDBC client. It covers creating databases and timeseries, inserting data in batches, performing various types of queries (full, exact, time range, aggregate), and deleting timeseries. Ensure you have a running IoTDB instance and the JDBC driver properly configured. ```Java import java.sql.*; import org.apache.iotdb.jdbc.IoTDBSQLException; public class JDBCExample { /** * Before executing a SQL statement with a Statement object, you need to create a Statement object using the createStatement() method of the Connection object. * After creating a Statement object, you can use its execute() method to execute a SQL statement * Finally, remember to close the 'statement' and 'connection' objects by using their close() method * For statements with read results, we can use the getResultSet() method of the Statement object to get the result set. */ public static void main(String[] args) throws SQLException { Connection connection = getConnection(); if (connection == null) { System.out.println("get connection defeat"); return; } Statement statement = connection.createStatement(); //Create database try { statement.execute("CREATE DATABASE root.demo"); }catch (IoTDBSQLException e){ System.out.println(e.getMessage()); } //SHOW DATABASES statement.execute("SHOW DATABASES"); outputResult(statement.getResultSet()); //Create time series //Different data type has different encoding methods. Here use INT32 as an example try { statement.execute("CREATE TIMESERIES root.demo.s0 WITH DATATYPE=INT32,ENCODING=RLE;"); }catch (IoTDBSQLException e){ System.out.println(e.getMessage()); } //Show time series statement.execute("SHOW TIMESERIES root.demo"); outputResult(statement.getResultSet()); //Show devices statement.execute("SHOW DEVICES"); outputResult(statement.getResultSet()); //Count time series statement.execute("COUNT TIMESERIES root"); outputResult(statement.getResultSet()); //Count nodes at the given level statement.execute("COUNT NODES root LEVEL=3"); outputResult(statement.getResultSet()); //Count timeseries group by each node at the given level statement.execute("COUNT TIMESERIES root GROUP BY LEVEL=3"); outputResult(statement.getResultSet()); //Execute insert statements in batch statement.addBatch("insert into root.demo(timestamp,s0) values(1,1);"); statement.addBatch("insert into root.demo(timestamp,s0) values(1,1);"); statement.addBatch("insert into root.demo(timestamp,s0) values(2,15);"); statement.addBatch("insert into root.demo(timestamp,s0) values(2,17);"); statement.addBatch("insert into root.demo(timestamp,s0) values(4,12);"); statement.executeBatch(); statement.clearBatch(); //Full read statement String sql = "select * from root.demo"; ResultSet resultSet = statement.executeQuery(sql); System.out.println("sql: " + sql); outputResult(resultSet); //Exact read statement sql = "select s0 from root.demo where time = 4;"; resultSet= statement.executeQuery(sql); System.out.println("sql: " + sql); outputResult(resultSet); //Time range read sql = "select s0 from root.demo where time >= 2 and time < 5;"; resultSet = statement.executeQuery(sql); System.out.println("sql: " + sql); outputResult(resultSet); //Aggregate read sql = "select count(s0) from root.demo;"; resultSet = statement.executeQuery(sql); System.out.println("sql: " + sql); outputResult(resultSet); //Delete time series statement.execute("delete timeseries root.demo.s0"); //close connection statement.close(); connection.close(); } public static Connection getConnection() { // JDBC driver name and database URL String driver = "org.apache.iotdb.jdbc.IoTDBDriver"; String url = "jdbc:iotdb://127.0.0.1:6667/"; // Database credentials String username = "root"; String password = "root"; Connection connection = null; try { Class.forName(driver); connection = DriverManager.getConnection(url, username, password); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } return connection; } /** * This is an example of outputting the results in the ResultSet */ private static void outputResult(ResultSet resultSet) throws SQLException { if (resultSet != null) { System.out.println("--------------------------"); final ResultSetMetaData metaData = resultSet.getMetaData(); final int columnCount = metaData.getColumnCount(); for (int i = 0; i < columnCount; i++) { System.out.print(metaData.getColumnLabel(i + 1) + " "); } System.out.println(); while (resultSet.next()) { for (int i = 1; ; i++) { System.out.print(resultSet.getString(i)); if (i < columnCount) { System.out.print(", "); } else { System.out.println(); break; } } } System.out.println("--------------------------\n"); } } } ``` -------------------------------- ### Install IoTDB Session Target Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/CMakeLists.txt Installs the built IoTDB session target, including runtime, library, and archive files to specified destinations. ```cmake install(TARGETS iotdb_session RUNTIME DESTINATION lib LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) ``` -------------------------------- ### Linux File Copy and Permissions Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/examples/README.md List of files to copy to the target Linux machine and the command to make the example executable. ```bash SessionExample libiotdb_session.so chmod +x SessionExample ``` -------------------------------- ### Install Visual Studio 2022 Community on Windows Source: https://github.com/apache/iotdb/blob/master/README.md Install the Visual Studio 2022 Community edition on Windows using Chocolatey. ```bash choco install visualstudio2022community ``` -------------------------------- ### IoTDBContainer Initialization and Usage Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-py/README.md Provides a context manager for starting and stopping an IoTDB database in a Docker container for testing purposes. ```APIDOC ## IoTDBContainer ### Description Provides a convenient way to manage an IoTDB instance within a Docker container for testing. ### Usage Example ```python from iotdb.testcontainer import IoTDBContainer import unittest class MyTestCase(unittest.TestCase): def test_something(self): with IoTDBContainer() as c: session = Session("localhost", c.get_exposed_port(6667), "root", "root") session.open(False) result = session.execute_query_statement("SHOW TIMESERIES") print(result) session.close() ``` ### Parameters * **image_tag** (str, optional) - The Docker image tag for IoTDB. Defaults to `"apache/iotdb:latest"`. ``` -------------------------------- ### Install libcurl on Ubuntu Source: https://github.com/apache/iotdb/blob/master/example/rest-client-c-example/README.md Installs the libcurl development package required for the C REST client. Ensure you are using a compatible Ubuntu version. ```shell sudo apt-get install libcurl4-openssl-dev ``` -------------------------------- ### Direct CMake Build and Install Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/README.md Builds and installs the C++ client directly using CMake without Maven. This is an alternative for environments where Maven is not available or preferred. ```bash cmake -S iotdb-client/client-cpp -B build && cmake --build build --target install ``` -------------------------------- ### Register and Configure Example Tests Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/examples/CMakeLists.txt Conditionally registers example targets as CTest tests if IOTDB_EXAMPLES_REGISTER_TESTS is enabled. It also sets these tests to run serially. ```cmake if(IOTDB_EXAMPLES_REGISTER_TESTS) set(_runnable_example_targets SessionExample AlignedTimeseriesSessionExample TableModelSessionExample tree_example table_example) foreach(_t IN LISTS _runnable_example_targets) add_test(NAME example_${_t} COMMAND ${_t}) endforeach() set_tests_properties( example_SessionExample example_AlignedTimeseriesSessionExample example_TableModelSessionExample example_tree_example example_table_example PROPERTIES RUN_SERIAL TRUE) endif() ``` -------------------------------- ### C++ Client Project Layout Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/examples/README.md This snippet shows the directory structure for the C++ client examples module within the Apache IoTDB project. ```text client-cpp/examples/ ├── README.md ├── README_zh.md ├── CMakeLists.txt ├── SessionExample.cpp ├── AlignedTimeseriesSessionExample.cpp ├── TableModelSessionExample.cpp ├── MultiSvrNodeClient.cpp ├── tree_example.c └── table_example.c ``` -------------------------------- ### Link Libraries for Example Targets Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/examples/CMakeLists.txt This code block iterates through example targets, linking the main IoTDB client library and conditionally linking OpenSSL libraries if WITH_SSL is enabled. It also links the pthread library on UNIX systems. ```cmake foreach(_t IN LISTS _example_targets) IF(WITH_SSL) TARGET_LINK_LIBRARIES(${_t} PRIVATE "${_iotdb_link_lib}" OpenSSL::SSL OpenSSL::Crypto) ELSE() TARGET_LINK_LIBRARIES(${_t} PRIVATE "${_iotdb_link_lib}") ENDIF() IF(UNIX) TARGET_LINK_LIBRARIES(${_t} PRIVATE pthread) ENDIF() # The packaged libiotdb_session records the bundled OpenSSL libs as DT_NEEDED; # point the linker at the SDK lib/ so it can resolve them without a system # OpenSSL present. if(UNIX AND NOT _iotdb_examples_in_tree) target_link_directories(${_t} PRIVATE "${IOTDB_SDK_ROOT}/lib") endif() # Run from the build output directory without setting LD_LIBRARY_PATH / PATH. if(UNIX) set_target_properties(${_t} PROPERTIES BUILD_RPATH "$ORIGIN" INSTALL_RPATH "$ORIGIN") endif() if(_iotdb_examples_in_tree) add_custom_command(TARGET ${_t} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ COMMENT "Copy IoTDB runtime library next to ${_t}") elseif(EXISTS "${_iotdb_runtime}") add_custom_command(TARGET ${_t} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_iotdb_runtime}" $ COMMENT "Copy IoTDB runtime library next to ${_t}") foreach(_ssl_lib IN LISTS _iotdb_sdk_ssl_runtime) add_custom_command(TARGET ${_t} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_ssl_lib}" $ COMMENT "Copy bundled OpenSSL runtime next to ${_t}") endforeach() elseif(WIN32) message(WARNING "Missing ${_iotdb_runtime}; copy iotdb_session.dll manually before running ${_t}.") endif() endforeach() ``` -------------------------------- ### Online Build with CMake (Linux/macOS) Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/README.md Configures and builds the C++ client using CMake with online dependency resolution. CMake must be installed. ```bash cmake -S iotdb-client/client-cpp -B build -DCMAKE_BUILD_TYPE=Release cmake --build build --target install ``` -------------------------------- ### Online Build with CMake (Windows/Visual Studio) Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/README.md Configures and builds the C++ client using CMake with Visual Studio generator. CMake and Visual Studio must be installed. ```bash cmake -S iotdb-client/client-cpp -B build -G "Visual Studio 17 2022" -A x64 cmake --build build --config Release --target install ``` -------------------------------- ### Run SessionExample on Windows Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/examples/README.md Command to execute the SessionExample on a Windows machine after copying the necessary files. ```powershell .\SessionExample.exe ``` -------------------------------- ### Run SessionExample on Linux Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/examples/README.md Command to execute the SessionExample on a Linux machine when the shared library is in the same directory. ```bash ./SessionExample ``` -------------------------------- ### Run AINode Docker Container (2.0.7+) Source: https://github.com/apache/iotdb/blob/master/docker/ReadMe.md Example command to run an AINode Docker container starting from version 2.0.7. This command configures network, ports, and essential environment variables for AINode to connect to an IoTDB cluster. ```shell docker run -d \ --name iotdb-ainode \ --network host \ -p 10810:10810 \ -p 8080:8080 \ -e AIN_SEED_CONFIG_NODE=127.0.0.1:10710 \ -e AIN_RPC_ADDRESS=127.0.0.1 \ -e AIN_RPC_PORT=10810 \ -e AIN_CLUSTER_INGRESS_ADDRESS=127.0.0.1 \ -e AIN_CLUSTER_INGRESS_PORT=6667 \ -e AIN_CLUSTER_INGRESS_USERNAME=root \ -e AIN_CLUSTER_INGRESS_PASSWORD=root \ apache/iotdb:2.0.7-SNAPSHOT-ainode ``` -------------------------------- ### Install Homebrew on macOS Source: https://github.com/apache/iotdb/blob/master/README.md Install the Homebrew package manager on macOS, used for installing various development tools and libraries. ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` -------------------------------- ### Install Package Metadata Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/CMakeLists.txt Installs generated package metadata files, including configuration, pkgconfig, version, and build info, to the installation directory. ```cmake install(FILES "${CMAKE_BINARY_DIR}/package-metadata/cmake/iotdb-session-config.cmake" DESTINATION cmake) install(FILES "${CMAKE_BINARY_DIR}/package-metadata/pkgconfig/iotdb-session.pc" DESTINATION pkgconfig) install(FILES "${CMAKE_BINARY_DIR}/package-metadata/VERSION" "${CMAKE_BINARY_DIR}/package-metadata/BUILD-INFO.txt" DESTINATION .) ``` -------------------------------- ### Cross-compile libcurl for ARM Source: https://github.com/apache/iotdb/blob/master/example/rest-client-c-example/README.md Instructions for cross-compiling libcurl for an ARM target, including configuration and installation. Replace '`install dir`' with your desired installation path. ```shell ./configure --host=arm-linux/arm-linux-gnueabihf/others CC=arm-linux-gnueabihf-gcc --prefix=`install dir` --enable-static --with-wolfssl make make install ``` -------------------------------- ### Install IoTDB JDBC Feature in Karaf Source: https://github.com/apache/iotdb/blob/master/iotdb-client/jdbc/README.md Install the IoTDB JDBC feature in Karaf after adding the feature repository. Ensure the JDBC feature is installed before the iotdb-feature. ```bash feature:install jdbc feature:install iotdb-feature ``` -------------------------------- ### Connect to IoTDB CLI Source: https://github.com/apache/iotdb/blob/master/README.md Use the start-cli script to connect to the IoTDB server. Specify connection parameters like host, port, username, and password. ```shell # Unix/OS X > sbin/start-cli.sh -h 127.0.0.1 -p 6667 -u root -pw root ``` ```shell # Windows > sbin\start-cli.bat -h 127.0.0.1 -p 6667 -u root -pw root ``` -------------------------------- ### Session Initialization and Management Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-py/README.md Demonstrates how to initialize, open, and close a session with the Apache IoTDB server. ```APIDOC ## Session Initialization ### Initialize a Session ```python session = Session(ip, port_, username_, password_, fetch_size=1024, zone_id="Asia/Shanghai") ``` ### Open a Session Opens a session with the IoTDB server. The `enable_rpc_compression` parameter controls whether RPC compression is enabled. ```python session.open(enable_rpc_compression=False) ``` **Note:** The RPC compression status of the client must comply with that of the IoTDB server. ### Close a Session Closes the current session with the IoTDB server. ```python session.close() ``` ``` -------------------------------- ### Enable Testing and Examples Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/CMakeLists.txt Conditionally enables testing and adds subdirectories for tests and examples if testing is enabled. ```cmake if(BUILD_TESTING) enable_testing() add_subdirectory(test) set(IOTDB_EXAMPLES_REGISTER_TESTS ON) add_subdirectory(examples) endif() ``` -------------------------------- ### Build IoTDB C++ Client Library (Windows/MSVC) Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/README.md Builds the C++ client library on Windows using MSVC with Maven. Requires specifying the Boost include directory and skips tests. ```bash mvn -P with-cpp -pl iotdb-client/client-cpp -am -DskipTests "-Dboost.include.dir=C:\\boost_1_88_0" package ``` -------------------------------- ### Install OpenSSL on macOS Source: https://github.com/apache/iotdb/blob/master/README.md Install OpenSSL on macOS using Homebrew, required for building Thrift with the C++ profile. ```bash brew install openssl ``` -------------------------------- ### Install Development Requirements Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-py/README.md Install necessary development dependencies for the Python client. This command should be run in your Python environment. ```shell pip install -r requirements_dev.txt ``` -------------------------------- ### Download and Setup Catch2 Unit Testing Framework Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/test/CMakeLists.txt This snippet configures the download path for the Catch2 header file. If the Catch2 include directory is not already defined, it creates the directory and downloads the 'catch.hpp' header from a specified URL. ```cmake set(CATCH2_URL "https://github.com/catchorg/Catch2/releases/download/v2.13.7/catch.hpp") if(CATCH2_INCLUDE_DIR) set(_catch2_include_dir "${CATCH2_INCLUDE_DIR}") else() set(_catch2_include_dir "${CMAKE_CURRENT_BINARY_DIR}/catch2") endif() set(_catch2_header "${_catch2_include_dir}/catch.hpp") if(NOT EXISTS "${_catch2_header}") file(MAKE_DIRECTORY "${_catch2_include_dir}") message(STATUS "Downloading Catch2 from ${CATCH2_URL}") file(DOWNLOAD "${CATCH2_URL}" "${_catch2_header}" SHOW_PROGRESS TLS_VERIFY ON) endif() ``` -------------------------------- ### IoTDB CLI Welcome Message Source: https://github.com/apache/iotdb/blob/master/README.md This is the expected output upon successful connection to the IoTDB CLI, indicating the server is ready for commands. ```text _____ _________ ______ ______ |_ _| | _ _ ||_ _ `.|_ _ \ | | .--.|_/ | | \_| | | `. \ | |_) | | | / .'`\ \ | | | | | | | __'. _| |_| \__. | _| |_ _| |_.' /_| |__) | |_____|'.__.' |_____| |______.'|_______/ version x.x.x IoTDB> login successfully IoTDB> ``` -------------------------------- ### Print Configuration Summary Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/CMakeLists.txt Prints a summary of the current build configuration options to the console. ```cmake message(STATUS "iotdb_session configuration summary:") message(STATUS " WITH_SSL = ${WITH_SSL}") message(STATUS " BUILD_TESTING = ${BUILD_TESTING}") message(STATUS " IOTDB_OFFLINE = ${IOTDB_OFFLINE}") message(STATUS " IOTDB_USE_CXX11_ABI = ${IOTDB_USE_CXX11_ABI}") message(STATUS " IOTDB_DEPS_DIR = ${IOTDB_DEPS_DIR}") message(STATUS " BOOST_INCLUDE_DIR = ${BOOST_INCLUDE_DIR} (Thrift build only)") message(STATUS " THRIFT_INCLUDE_DIR = ${THRIFT_INCLUDE_DIR}") message(STATUS " THRIFT_STATIC_LIB = ${THRIFT_STATIC_LIB_PATH}") message(STATUS " THRIFT_EXECUTABLE = ${THRIFT_EXECUTABLE}") message(STATUS " CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}") ``` -------------------------------- ### Install Boost for MSVC 14.2 on Windows Source: https://github.com/apache/iotdb/blob/master/README.md Install the Boost C++ libraries compatible with MSVC 14.2 on Windows using Chocolatey. ```bash choco install boost-msvc-14.2 ``` -------------------------------- ### Install Bison on macOS Source: https://github.com/apache/iotdb/blob/master/README.md Install the Bison parser generator on macOS using Homebrew, required for building Thrift with the C++ profile. ```bash brew install bison ``` -------------------------------- ### Full Apache IoTDB Build (Skip Tests) Source: https://github.com/apache/iotdb/blob/master/AGENTS.md Use this command for a complete build of the distribution module, skipping all tests. It requires Maven. ```bash mvn clean package -pl distribution -am -DskipTests ``` -------------------------------- ### Install Boost C++ on macOS Source: https://github.com/apache/iotdb/blob/master/README.md Install the Boost C++ libraries on macOS using Homebrew, required for building Thrift with the C++ profile. ```bash brew install boost ``` -------------------------------- ### Minimal C++ Program for IoTDB Session Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/README.md A minimal C++ program demonstrating how to establish a session with IoTDB, set a storage group, check for timeseries existence, and create a new timeseries. Ensure an IoTDB instance is running before execution. ```cpp #include "Session.h" #include #include int main() { auto session = std::make_shared("127.0.0.1", 6667, "root", "root"); session->open(false); session->setStorageGroup("root.test"); if (!session->checkTimeseriesExists("root.test.d0.s0")) { session->createTimeseries( "root.test.d0.s0", TSDataType::INT64, TSEncoding::RLE, CompressionType::SNAPPY); } session->close(); std::cout << "IoTDB C++ session is ready." << std::endl; return 0; } ``` -------------------------------- ### Build IoTDB C++ Client Library (Linux/macOS) Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/README.md Use this command to build only the C++ client library on Linux or macOS using Maven. It skips tests and packages the output. ```bash mvn -P with-cpp -pl iotdb-client/client-cpp -am -DskipTests package ``` -------------------------------- ### Install OpenSSL Runtime Libraries Source: https://github.com/apache/iotdb/blob/master/iotdb-client/client-cpp/CMakeLists.txt Conditionally installs OpenSSL runtime libraries alongside the IoTDB session library to ensure a self-contained SDK on Windows. ```cmake if(WITH_SSL) iotdb_install_openssl_runtime() endif() ``` -------------------------------- ### Install JDBC Project to Local Maven Repository Source: https://github.com/apache/iotdb/blob/master/iotdb-client/jdbc/README.md Use this command to clean, install, and skip tests for the JDBC module into your local Maven repository. ```bash mvn clean install -pl jdbc -am -Dmaven.test.skip=true ```