Olaf
Overly Lightweight Acoustic Fingerprinting
Loading...
Searching...
No Matches
Data Structures | Typedefs | Functions
olaf_db.h File Reference

Olaf fingerprint database. More...

#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  Olaf_Resource_Meta_data
 A struct containing meta data on indexed audio files. More...
 

Typedefs

typedef struct Olaf_DB Olaf_DB
 
typedef struct Olaf_Resource_Meta_data Olaf_Resource_Meta_data
 

Functions

Olaf_DBolaf_db_new (const char *db_file_folder, bool readonly)
 
void olaf_db_destroy (Olaf_DB *db)
 
void olaf_db_store_meta_data (Olaf_DB *db, uint32_t *key, Olaf_Resource_Meta_data *value)
 
void olaf_db_find_meta_data (Olaf_DB *db, uint32_t *key, Olaf_Resource_Meta_data *value)
 
void olaf_db_delete_meta_data (Olaf_DB *db, uint32_t *key)
 
bool olaf_db_has_meta_data (Olaf_DB *db, uint32_t *key)
 
void olaf_db_stats_meta_data (Olaf_DB *db, bool verbose)
 
void olaf_db_store (Olaf_DB *db, uint64_t *keys, uint64_t *values, size_t size)
 
void olaf_db_delete (Olaf_DB *db, uint64_t *keys, uint64_t *values, size_t size)
 
size_t olaf_db_find (Olaf_DB *db, uint64_t start_key, uint64_t stop_key, uint64_t *results, size_t results_size)
 
bool olaf_db_find_single (Olaf_DB *db, uint64_t start_key, uint64_t stop_key)
 
void olaf_db_stats (Olaf_DB *db, bool verbose)
 
uint32_t olaf_db_string_hash (const char *key, size_t len)
 

Detailed Description

Olaf fingerprint database.

The interface to a data store with fingerprints. There are two implementations included in Olaf. A persistent key value store backed by a B-tree (LMDB) or an in memory store.

The data store is a list of fingerprint hashes (uint64_t) pointing to a value (also uint64_t) The value consists of: *

Hash collisions are possible so duplicates should be allowed.

Function Documentation

◆ olaf_db_delete()

void olaf_db_delete ( Olaf_DB db,
uint64_t *  keys,
uint64_t *  values,
size_t  size 
)

Delete a list of elements in the data store.

Parameters
dbThe database.
keysA list of keys: the 64bit fingerprint hash.
valuesA list of values: Typically the highest 32bits contain a timestamp, the lowest 32bits an audio identifier.
sizeThe size of both the keys and values arrays.

◆ olaf_db_delete_meta_data()

void olaf_db_delete_meta_data ( Olaf_DB db,
uint32_t *  key 
)

Delete meta-data.

Parameters
dbThe database.
keyThe audio identifier to delete meta-data for.-

◆ olaf_db_destroy()

void olaf_db_destroy ( Olaf_DB db)

Free database related memory resources and close files or other resources.

Parameters
dbthe database to close.

◆ olaf_db_find()

size_t olaf_db_find ( Olaf_DB db,
uint64_t  start_key,
uint64_t  stop_key,
uint64_t *  results,
size_t  results_size 
)

Find a list of elements in the database store

Parameters
dbThe database.
start_keyThe begin key to start returning results from.
stop_keyThe end key, should be greater than start_key.
resultsAn array to store the results in.
results_sizethe maximum size of the results array.
Returns
The number of found results

◆ olaf_db_find_meta_data()

void olaf_db_find_meta_data ( Olaf_DB db,
uint32_t *  key,
Olaf_Resource_Meta_data value 
)

Search meta-data.

Parameters
dbThe database.
keyThe audio identifier.
valueWhere to store meta-data information on the audio.

◆ olaf_db_find_single()

bool olaf_db_find_single ( Olaf_DB db,
uint64_t  start_key,
uint64_t  stop_key 
)

Checks if a hash is present in the database.

Parameters
dbThe database.
start_keyThe begin key to start returning results from.
stop_keyThe end key, should be greater than start_key.
Returns
The true if a hash in the range is present.

◆ olaf_db_has_meta_data()

bool olaf_db_has_meta_data ( Olaf_DB db,
uint32_t *  key 
)

Check if there is meta data for a key.

Parameters
dbThe database.
keyThe audio identifier.
Returns
True if meta-data is available.

◆ olaf_db_new()

Olaf_DB * olaf_db_new ( const char *  db_file_folder,
bool  readonly 
)

Creates a new database, if the file name exists, read the contents

Parameters
db_file_folderThe folder used to store database files
readonlyThe mode to open the database, if no write operations are expected this should be true.

◆ olaf_db_stats()

void olaf_db_stats ( Olaf_DB db,
bool  verbose 
)

Print database statistics.

Parameters
dbThe database.
verbosePrint more information than usual.

◆ olaf_db_stats_meta_data()

void olaf_db_stats_meta_data ( Olaf_DB db,
bool  verbose 
)

Print meta database statistics.

Parameters
dbThe database.
verbosePrint more information than usual.

◆ olaf_db_store()

void olaf_db_store ( Olaf_DB db,
uint64_t *  keys,
uint64_t *  values,
size_t  size 
)

Store a list of elements in the data store.

Parameters
dbThe database.
keysA list of keys: the 64bit fingerprint hash.
valuesA list of values: Typically the highest 32bits contain a timestamp, the lowest 32bits an audio identifier.
sizeThe size of both the keys and values arrays.

◆ olaf_db_store_meta_data()

void olaf_db_store_meta_data ( Olaf_DB db,
uint32_t *  key,
Olaf_Resource_Meta_data value 
)

Store meta-data.

Parameters
dbThe database to store info in.
keyThe audio identifier.
valueThe meta-data with information on the audio.

◆ olaf_db_string_hash()

uint32_t olaf_db_string_hash ( const char *  key,
size_t  len 
)

Hash a string into a 32 bit integer e.g. using a Jenkins hash. This can be practial to convert an audio file name into an identifier.

Parameters
keyThe list of characters.
lenThe length of the string.