开源嵌入式数组引擎TileDB的简单使用

TileDB 是C++编写的存储和访问通用多维数组引擎,它的官方Github网站https://github.1git.de/TileDB-Inc/TileDB

1.下载源代码和二进制库

源代码https://github.1git.de/TileDB-Inc/TileDB/archive/refs/tags/2.28.1.tar.gz

选择符合你的机器CPU架构和操作系统的库

二进制库https://github.1git.de/TileDB-Inc/TileDB/releases/download/2.28.1/tiledb-linux-arm64-2.28.1-d648231.tar.gz

2.从源代码编译库

一般不需要,因为https://github.1git.de/TileDB-Inc/TileDB/releases/expanded_assets/2.28.1已经提供了大多数平台的现成库

如果需要,按照以下步骤

tar xf 2.28.1.tar.gz

然后按照解压的BUILDING_FROM_SOURCE.md文件提示的步骤,大致是

bash 复制代码
mkdir build
cd build
../bootstrap <flags>
# Or use CMake directly instead of bootstrap:
# cmake <flags> ..

make -j <nprocs>

make install

3.编译源代码中的例子

参照解压的USAGE.md文件提示的步骤,

定位到目录examples/c_api

以as_built.c为例,编译命令行如下,这里-I /shujv/par/tiledb/include-L /shujv/par/tiledb/lib分别是tiledb头文件和动态库的位置

bash 复制代码
gcc as_built.c -o as_built -ltiledb -I /shujv/par/tiledb/include -L /shujv/par/tiledb/lib

注意对系统c/c++库版本有要求,如果不满足,将报错

bash 复制代码
/shujv/par/tiledb/lib/libtiledb.so:对'std::thread::_State::~_State()@GLIBCXX_3.4.22'未定义的引用
/shujv/par/tiledb/lib/libtiledb.so:对'__cxa_init_primary_exception@CXXABI_1.3.11'未定义的引用
/shujv/par/tiledb/lib/libtiledb.so:对'fcntl64@GLIBC_2.28'未定义的引用
/shujv/par/tiledb/lib/libtiledb.so:对'getentropy@GLIBC_2.25'未定义的引用
/shujv/par/tiledb/lib/libtiledb.so:对'logf@GLIBC_2.27'未定义的引用
/shujv/par/tiledb/lib/libtiledb.so:对'operator new(unsigned long, std::align_val_t)@CXXABI_1.3.11'未定义的引用
/shujv/par/tiledb/lib/libtiledb.so:对'typeinfo for std::thread::_State@GLIBCXX_3.4.22'未定义的引用

等等

我切换到gcc 14.2 docker镜像,编译就不报错了,注意要设置LD_LIBRARY_PATH环境变量加入tiledb动态库的位置

bash 复制代码
gcc as_built.c -o as_built -ltiledb -I  /par/tiledb/include -L /par/tiledb/lib
root@66d4e20ec1d7:/par/TileDB-main/examples/c_api# export LD_LIBRARY_PATH="/par/tiledb/lib:$LD_LIBRARY_PATH"
root@66d4e20ec1d7:/par/TileDB-main/examples/c_api# ./as_built
{
  "as_built": {
    "parameters": {
      "storage_backends": {
        "azure": {
          "enabled": true
        },
        "gcs": {
          "enabled": true
        },
        "s3": {
          "enabled": true
        }
      },
      "support": {
        "serialization": {
          "enabled": true
        }
      }
    }
  }

再编译query_condition_dense.c,能实现对数组条件查询,是不是有点像数据库

bash 复制代码
gcc query_condition_dense.c -o qcd -ltiledb -I  /par/tiledb/include -L /par/tiledb/lib
root@66d4e20ec1d7:/par/TileDB-main/examples/c_api# ./qcd   
Printing the entire array...
{null, alice, 0, 4.1}
{2, bob, 0, 3.4}
{null, craig, 0, 5.6}
{4, dave, 0, 3.7}
{null, erin, 0, 2.3}
{6, frank, 0, 1.7}
{null, grace, 1, 3.8}
{8, heidi, 2, 4.9}
{null, ivan, 3, 3.2}
{10, judy, 4, 3.1}

Running read query with query condition `a = null`...
{null, alice, 0, 4.1}
{null, craig, 0, 5.6}
{null, erin, 0, 2.3}
{null, grace, 1, 3.8}
{null, ivan, 3, 3.2}

Running read query with query condition `b < "eve"`...
{null, alice, 0, 4.1}
{2, bob, 0, 3.4}
{null, craig, 0, 5.6}
{4, dave, 0, 3.7}
{null, erin, 0, 2.3}

Running read query with query condition `c >= 1`...
{null, grace, 1, 3.8}
{8, heidi, 2, 4.9}
{null, ivan, 3, 3.2}
{10, judy, 4, 3.1}

Running read query with query condition `3.0f <= d AND d <= 4.0f`...
{2, bob, 0, 3.4}
{4, dave, 0, 3.7}
{null, grace, 1, 3.8}
{null, ivan, 3, 3.2}
{10, judy, 4, 3.1}

Running read query with query condition `3.0f <= d AND d <= 4.0f AND a != null AND b < "eve"`...
{2, bob, 0, 3.4}
{4, dave, 0, 3.7}
相关推荐
minji...6 小时前
Linux 线程同步与互斥(三) 生产者消费者模型,基于阻塞队列的生产者消费者模型的代码实现
linux·运维·服务器·开发语言·网络·c++·算法
GottdesKrieges6 小时前
OceanBase数据库备份配置
数据库·oceanbase
SPC的存折7 小时前
MySQL 8组复制完全指南
linux·运维·服务器·数据库·mysql
运维行者_7 小时前
OpManager MSP NetFlow Analyzer集成解决方案,应对多客户端网络流量监控挑战
大数据·运维·服务器·网络·数据库·自动化·运维开发
炸炸鱼.8 小时前
Python 操作 MySQL 数据库
android·数据库·python·adb
CoderCodingNo8 小时前
【GESP】C++三级真题 luogu-B4499, [GESP202603 三级] 二进制回文串
数据结构·c++·算法
softshow10268 小时前
Etsy 把 1000 个 MySQL 分片迁进 Vitess
数据库·mysql
Ronaldinho Gaúch8 小时前
MySQL基础
数据库·mysql
cmpxr_9 小时前
【C】局部变量和全局变量及同名情况
c语言·开发语言
不剪发的Tony老师9 小时前
Noir:一款键盘驱动的现代化数据库管理工具
数据库·sql