EmbedDB is a high performance embedded data storage and index structure optimized for time series data on embedded systems. It supports key-value and relational data and runs on a wide variety of embedded devices. EmbedDB does not require an operating system and outperforms other systems, including SQLite, on small embedded systems. Key features:
- Minimum memory requirement is 4 KB allowing execution on the smallest devices.
- Key-value store optimized for time series with extremely fast insert performance.
- Efficient insert (put) and query (get) of arbitrary key-value data. Ability to search data both on timestamp (key) and by data value.
- High-performance learned index for keys and efficient, customizable data index optimized for flash memory that outperforms B+-trees.
- Supports any type of storage including raw NOR and NAND chips and SD cards.
- No dependencies on libraries or need for an operating system.
- Advanced query API for SQL queries, which can be written by hand or by using our SQL converter
- Easily included in C projects.
- Open source license. Free to use for commerical and open source projects.
Note: This version is designed for building and execution on an embedded device using Platform.io. A desktop version is also available.
embedDBState* state = (embedDBState*) malloc(sizeof(embedDBState));
state->keySize = 4;
state->dataSize = 12;
// Function pointers that can compare keys and data (user customizable)
state->compareKey = int32Comparator;
state->compareData = dataComparator;
// Storage configuration (SD card example shown)
state->pageSize = 512;
state->eraseSizeInPages = 4;
state->numDataPages = 1000;
state->numIndexPages = 48;
char dataPath[] = "dataFile.bin";
state->fileInterface = getSDInterface();
state->dataFile = setupSDFile(dataPath);
// Configure memory buffers
state->bufferSizeInBlocks = 2; // Minimum 2 buffers is required for read/write operations
state->buffer = malloc((size_t) state->bufferSizeInBlocks * state->pageSize);
// Initialize
embedDBInit(state, splineMaxError);
// Store record
uint32_t key = 123;
char data[12] = "TEST DATA";
embedDBPut(state, (void*) &key, dataPtr);
// Get record
embedDBGet(state, (void*) &key, (void*) returnDataPtr);Core source files needed: embedDB.h, embedDB.c
Examples:
- dueMain.cpp, megaMain.cpp, memboardMain.cpp are main files for the Arduino Due, Mega, and custom hardware respectively.
- embedDBExample - An example file demonstrating how to get, put, and iterate through data in index.
- embedDBVariableDataExample - An example file demonstrating the use of records with variable-sized data.
- embedDBQueryInterfaceExamples - An example file demonstrating the included embedDB query library.
- Setup & usage
- Simple Query Interface
- Setting up a file interface
- Performance Benchmarks
- Time Series Index Publication
- Time Series Learned Index Publication
University of British Columbia Okanagan