当前位置: 首页 > 工具软件 > IonDB > 使用案例 >

键值数据库 IonDB

汲睿
2023-12-01

IonDB 详细介绍

IonDB 专为 Arduino 和 IoT 提供开箱即用的,基于磁盘的快速存储功能,为受限系统提供键值存储功能,速度非常快,可以充分提升 Arduino 的性能。

这个项目是英国哥伦比亚的奥肯那根大学 Ramon Lawrence 博士指导项目的一部分,由 Lawrence 博士的分布式数据实验室支持。还有另外一个类似的项目,也是专为嵌入式设备和传感器节点设计的关系型数据库 LittleD。

一般情况下,IonDB 支持:

存储一个键的任意值

重复键支持

范围和等值查询

基于硬盘的持久化数据存储

示例:

#include <SD.h>
#include "dictionary.h"
#include "slhandler.h"
void setup() {
    //Declare the dictionary and handler structs
    dictionary_handler_t    handler;
    dictionary_t            dictionary;
    //Initialize handler
    sldict_init(&handler);
    //Create dictionary: Given handler, dictionary, key type, key size, value size, dict size
    dictionary_create(&handler, &dictionary, key_type_numeric_signed, sizeof(int), 60, 10);
    ion_key_t   key = IONIZE(42);
    ion_value_t value = (ion_value_t) "Hello IonDB";
    dictionary_insert(&dictionary, key, value);
    ion_value_t returned_value = (ion_value_t) malloc(60); //from value_size
    dictionary_get(&dictionary, key, returned_value);
    printf("Returned %s\n", returned_value);
    free(returned_value);
}
void loop() {}

文章转载自 开源中国社区[https://www.oschina.net]

 类似资料: