Skip to main content

qmap_open

Function qmap_open 

Source
pub unsafe extern "C" fn qmap_open(
    filename: *const c_char,
    database: *const c_char,
    ktype: u32,
    vtype: u32,
    mask: u32,
    flags: u32,
) -> u32
Expand description

@brief Open a database.

Creates an in-memory map and registers its handle with the internal file cache, linking it to ‘filename’. If a file exists, it loads the map data for the specified ‘database’.

@param[in] filename Path to file or cache key. NULL → in-memory only. @param[in] database Logical name within file. NULL → skip file association. @param[in] ktype Built-in or registered key type. @param[in] vtype Built-in or registered value type. @param[in] mask Must be 2ⁿ − 1; table size is (mask + 1). @param[in] flags Bitwise OR of QM_AINDEX, QM_MIRROR, QM_SORTED, etc. @return Map handle (hd).

@note File Persistence: File-backed maps automatically load data from disk when opened, regardless of flags. The QM_MIRROR flag enables bidirectional lookup (creating a reverse map at handle hd + 1) which is useful for many persistence scenarios. The mirror map is automatically closed when closing the primary map.

@note Multiple databases can share a single file. Each database is identified by a hash of its name (XXH32). Data is saved and loaded based on this database ID.