.TH "islet_core" 3 "islet" \" -*- nroff -*- .ad l .nh .SH NAME islet_core \- Islet core API .PP \- Spatial map operations using Morton code indexing\&. .SH SYNOPSIS .br .PP .SS "Data Structures" .in +1c .ti -1c .RI "struct \fBislet_ops_t\fP" .br .RI "Per-dimension operation table\&. " .in -1c .SS "Macros" .in +1c .ti -1c .RI "#define \fBISLET_MISS\fP UINT32_MAX" .br .ti -1c .RI "#define \fBISLET_FILL_MAX_VOL\fP 1048576u" .br .ti -1c .RI "#define \fBISLET_AXIS_MAX_POINTS\fP 1024u" .br .in -1c .SS "Functions" .in +1c .ti -1c .RI "void \fBislet_init\fP (void)" .br .RI "Initialize the islet subsystem\&. " .ti -1c .RI "uint32_t \fBislet_open\fP (char *filename, char *database, uint32_t mask)" .br .RI "Open or create a spatial database\&. " .ti -1c .RI "uint32_t \fBislet_iter_1\fP (uint32_t pdb_hd, int16_t *s, uint16_t *l)" .br .RI "Create an iterator for all points within a rectangular bounding box\&. " .ti -1c .RI "uint32_t \fBislet_iter_2_32\fP (uint32_t pdb_hd, int32_t *s, int32_t *l)" .br .RI "2D x 32-bit box iterator\&. Same contract as islet_iter_N(), on int32_t lanes (start AND lengths)\&. Use with \fBislet_next32()\fP\&. " .ti -1c .RI "int \fBislet_next\fP (int16_t *p, uint32_t *ref, uint32_t cur)" .br .RI "Advance iterator and retrieve the next point/value pair\&. " .ti -1c .RI "int \fBislet_next32\fP (int32_t *p, uint32_t *ref, uint32_t cur)" .br .RI "Advance a 2D x 32-bit iterator (islet_iter_2_32 handle)\&. " .ti -1c .RI "static void \fBislet_del_1\fP (uint32_t pdb_hd, int16_t *p)" .br .RI "Delete the first value stored at a spatial coordinate\&. " .ti -1c .RI "static void \fBislet_del_2\fP (uint32_t pdb_hd, int16_t *p)" .br .RI "2D delete\&. See \fBislet_del_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBislet_del_3\fP (uint32_t pdb_hd, int16_t *p)" .br .RI "3D delete\&. See \fBislet_del_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBislet_del_4\fP (uint32_t pdb_hd, int16_t *p)" .br .RI "4D delete\&. See \fBislet_del_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBislet_del_2_32\fP (uint32_t pdb_hd, int32_t *p)" .br .RI "2D x 32-bit delete\&. See \fBislet_del_1()\fP for the family docs\&. " .ti -1c .RI "static uint32_t \fBislet_del_all_1\fP (uint32_t pdb_hd, int16_t *p)" .br .RI "Delete every value stored at a spatial coordinate\&. " .ti -1c .RI "static uint32_t \fBislet_del_all_2\fP (uint32_t pdb_hd, int16_t *p)" .br .RI "2D delete-all\&. See \fBislet_del_all_1()\fP for the family docs\&. " .ti -1c .RI "static uint32_t \fBislet_del_all_3\fP (uint32_t pdb_hd, int16_t *p)" .br .RI "3D delete-all\&. See \fBislet_del_all_1()\fP for the family docs\&. " .ti -1c .RI "static uint32_t \fBislet_del_all_4\fP (uint32_t pdb_hd, int16_t *p)" .br .RI "4D delete-all\&. See \fBislet_del_all_1()\fP for the family docs\&. " .ti -1c .RI "static uint32_t \fBislet_del_all_2_32\fP (uint32_t pdb_hd, int32_t *p)" .br .RI "2D x 32-bit delete-all\&. See \fBislet_del_all_1()\fP for the family docs\&. " .ti -1c .RI "uint32_t \fBislet_del_value_2_32\fP (uint32_t pdb_hd, int32_t *p, uint32_t thing)" .br .RI "2D x 32-bit delete-by-value\&. See \fBislet_del_value_1()\fP for the family docs\&. " .ti -1c .RI "static uint32_t \fBislet_get_1\fP (uint32_t pdb_hd, int16_t *p)" .br .RI "Retrieve the value stored at a spatial coordinate\&. " .ti -1c .RI "static uint32_t \fBislet_get_2\fP (uint32_t pdb_hd, int16_t *p)" .br .RI "2D retrieve\&. See \fBislet_get_1()\fP for the family docs\&. " .ti -1c .RI "static uint32_t \fBislet_get_3\fP (uint32_t pdb_hd, int16_t *p)" .br .RI "3D retrieve\&. See \fBislet_get_1()\fP for the family docs\&. " .ti -1c .RI "static uint32_t \fBislet_get_4\fP (uint32_t pdb_hd, int16_t *p)" .br .RI "4D retrieve\&. See \fBislet_get_1()\fP for the family docs\&. " .ti -1c .RI "static uint32_t \fBislet_get_2_32\fP (uint32_t pdb_hd, int32_t *p)" .br .RI "2D x 32-bit retrieve\&. See \fBislet_get_1()\fP for the family docs\&. " .ti -1c .RI "static uint32_t \fBislet_cell_count_1\fP (uint32_t pdb_hd, int16_t *p)" .br .RI "Count the values stored at a spatial coordinate\&. " .ti -1c .RI "static uint32_t \fBislet_cell_count_2\fP (uint32_t pdb_hd, int16_t *p)" .br .RI "2D cell count\&. See \fBislet_cell_count_1()\fP for the family docs\&. " .ti -1c .RI "static uint32_t \fBislet_cell_count_3\fP (uint32_t pdb_hd, int16_t *p)" .br .RI "3D cell count\&. See \fBislet_cell_count_1()\fP for the family docs\&. " .ti -1c .RI "static uint32_t \fBislet_cell_count_4\fP (uint32_t pdb_hd, int16_t *p)" .br .RI "4D cell count\&. See \fBislet_cell_count_1()\fP for the family docs\&. " .ti -1c .RI "static uint32_t \fBislet_cell_count_2_32\fP (uint32_t pdb_hd, int32_t *p)" .br .RI "2D x 32-bit cell count\&. See \fBislet_cell_count_1()\fP for the family docs\&. " .ti -1c .RI "uint32_t \fBislet_last_scan_count\fP (void)" .br .RI "Diagnostic: index entries examined by the last box walk\&. " .ti -1c .RI "uint32_t \fBislet_get_multi_1\fP (uint32_t pdb_hd, int16_t *p)" .br .RI "Create an iterator for all values stored at one coordinate\&. " .ti -1c .RI "uint32_t \fBislet_get_multi_2_32\fP (uint32_t pdb_hd, int32_t *p)" .br .RI "2D x 32-bit cell iterator\&. Same contract as islet_get_multi_N() (use the shared \fBislet_cell_next()\fP to read values)\&. " .ti -1c .RI "int \fBislet_cell_next\fP (uint32_t *ref, uint32_t cur)" .br .RI "Advance a cell iterator and retrieve the next value\&. " .ti -1c .RI "uint32_t \fBislet_del_value_1\fP (uint32_t pdb_hd, int16_t *p, uint32_t thing)" .br .RI "Delete one value from a spatial coordinate (phase-2A adapter primitive)\&. " .ti -1c .RI "static void \fBislet_put_1\fP (uint32_t pdb_hd, int16_t *p, uint32_t thing)" .br .RI "Store a value at a spatial coordinate (append)\&. " .ti -1c .RI "static void \fBislet_put_2\fP (uint32_t pdb_hd, int16_t *p, uint32_t thing)" .br .RI "2D append\&. See \fBislet_put_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBislet_put_3\fP (uint32_t pdb_hd, int16_t *p, uint32_t thing)" .br .RI "3D append\&. See \fBislet_put_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBislet_put_4\fP (uint32_t pdb_hd, int16_t *p, uint32_t thing)" .br .RI "4D append\&. See \fBislet_put_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBislet_put_2_32\fP (uint32_t pdb_hd, int32_t *p, uint32_t thing)" .br .RI "2D x 32-bit append\&. See \fBislet_put_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBislet_set_1\fP (uint32_t pdb_hd, int16_t *p, uint32_t thing)" .br .RI "Store a value at a spatial coordinate (replace)\&. " .ti -1c .RI "static void \fBislet_set_2\fP (uint32_t pdb_hd, int16_t *p, uint32_t thing)" .br .RI "2D replace\&. See \fBislet_set_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBislet_set_3\fP (uint32_t pdb_hd, int16_t *p, uint32_t thing)" .br .RI "3D replace\&. See \fBislet_set_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBislet_set_4\fP (uint32_t pdb_hd, int16_t *p, uint32_t thing)" .br .RI "4D replace\&. See \fBislet_set_1()\fP for the family docs\&. " .ti -1c .RI "static void \fBislet_set_2_32\fP (uint32_t pdb_hd, int32_t *p, uint32_t thing)" .br .RI "2D x 32-bit replace\&. See \fBislet_set_1()\fP for the family docs\&. " .ti -1c .RI "int \fBrec_axis_fill_bbox_1\fP (uint32_t pdb_hd, int16_t *s, uint16_t *l, rec_set_t *out)" .br .RI "Fill a recall candidate set with the values in a bounding box\&. " .ti -1c .RI "int \fBrec_axis_fill_bbox_2_32\fP (uint32_t pdb_hd, int32_t *s, int32_t *l, rec_set_t *out)" .br .RI "2D x 32-bit box fill\&. Same contract as rec_axis_fill_bbox_N(), on int32_t lanes (start AND lengths)\&. ISLET_FILL_MAX_VOL caps every config alike\&. " .ti -1c .RI "uint32_t \fBmorton_set_bulk\fP (uint64_t *out, int16_t points[][3], uint32_t n)" .br .RI "Batch-encode multiple 3D points to Morton codes using SIMD\&. " .ti -1c .RI "uint32_t \fBmorton_set_bulk4\fP (uint64_t *out, int16_t points[][4], uint32_t n)" .br .RI "Batch-encode multiple 4D points to Morton codes using SIMD\&. " .ti -1c .RI "uint32_t \fBmorton_get_bulk\fP (int16_t points[][3], const uint64_t *codes, uint32_t n)" .br .RI "Batch-decode multiple 3D Morton codes to points using SIMD\&. " .ti -1c .RI "uint32_t \fBmorton_get_bulk4\fP (int16_t points[][4], const uint64_t *codes, uint32_t n)" .br .RI "Batch-decode multiple 4D Morton codes to points using SIMD\&. " .ti -1c .RI "bool \fBislet_box_is_empty\fP (uint32_t pdb_hd, int16_t x, int16_t y, uint16_t size)" .br .RI "Test if an axis-aligned 2D bounding box contains any discrete data\&. " .in -1c .SS "Variables" .in +1c .ti -1c .RI "const \fBislet_ops_t\fP \fBislet_ops\fP [5]" .br .RI "The per-dimension operation table (islet_ops[0] = all NULL)\&. " .in -1c .SH "Detailed Description" .PP Spatial map operations using Morton code indexing\&. Islet provides a spatial database that maps multi-dimensional coordinates to arbitrary uint32_t values\&. Internally, coordinates are converted to Morton codes (Z-order) for efficient spatial queries and storage\&. .PP Value Semantics (multi-value cells): .IP "\(bu" 2 A grid cell may hold MULTIPLE values (CM_MULTIVALUE map)\&. islet_put_N() appends; islet_get_N() returns the first value; islet_get_multi_N() iterates all values in insertion order; islet_del_N() removes the first value; islet_del_all_N() removes every value; islet_set_N() replaces all values with a single new one (N = 1\&.\&.4)\&. .PP .PP Coordinate System: .IP "\(bu" 2 Type: int16_t (signed 16-bit integers) .IP "\(bu" 2 Range: -32768 to 32767 per dimension .IP "\(bu" 2 Dimensions 1\&.\&.4 supported; optimized for 3D (dim=3) with 4D (dim=4) support\&. 1D/2D/3D codes are bit-identical to v0\&.5\&.0; 4D codes densely fill all 64 key bits\&. .PP .PP The 2D x 32-bit config (int32_t lanes, islet_*_2_32 / morton_*_2_32) is a second dense family member: 2 x 32 = 64 key bits, no reserved bits, lane range -2147483648\&.\&.2147483647\&. .PP \fBNote\fP .RS 4 Keyspace: all dimensions and configs share the uint64 Morton key space\&. Use one dimension AND one config per database, and never reopen a database with a different config's functions: the file carries no config tag, so a cross-config reopen silently decodes garbage\&. .PP islet_ops[] covers the int16-lane configs (1\&.\&.4) only; the 2D x 32-bit config is reached through its suffixed monomorphs (\fBislet_put_2_32()\fP, \fBislet_iter_2_32()\fP, \&.\&.\&.) directly\&. .PP Preferred surface: the config objects in \fBpointcfg\&.h\fP (Point1_2\&.\&.Point4_2, Point2_4) group everything above per config as static-method structs\&. This header's flat functions remain the ABI and the tight-loop fast path\&. .PP Thread Safety: Islet inherits libcorm's thread-safety properties\&. It uses global state and is NOT thread-safe\&. Use external synchronization if accessing from multiple threads\&. .PP Capacity: The mask parameter sizes the initial hash table (capacity = mask + 1)\&. The map AUTO-GROWS by doubling when it fills (inherited from libcorm; libislet never passes CM_NOGROW), so exceeding the initial capacity is safe\&. Choose a mask near your expected entry count to avoid early regrows\&. .PP Memory: Malloc failures terminate the process immediately via CBUG()\&. There is no graceful error handling for out-of-memory conditions\&. .PP ID-uniformity contract (see RECALL-KERNEL\&.md): the per-cell stored value ("thing"/"ref") is intentionally \fRuint32_t\fP, not the wider \fRrec_ref_t\fP — which is itself \fRuint32_t\fP (from rec\&.h), matching what libsepal/liblemma use natively and libjoint widens to at its fill boundary, so the fill widen is now an identity cast\&. Islet's storage/SIMD paths are tuned around the 4-byte value; doubling it is a real cost, not a free uniformity win\&. The uniformity boundary is enforced only at rec_axis_fill_bbox_N(), which already widens every stored uint32_t to rec_ref_t before pushing it into the caller's rec_set_t\&. Do not assume ids above UINT32_MAX round-trip through islet_put_N()/islet_get_N()\&. .RE .PP \fBWarning\fP .RS 4 File Persistence: File-backed databases are automatically saved at process exit via libcorm\&. Explicit corm_save() calls are only needed for mid-execution checkpointing\&. .RE .PP \fBSee also\fP .RS 4 \fBMorton code helpers\fP .PP \fBPoint utilities\fP .RE .PP .SH "Macro Definition Documentation" .PP .SS "#define ISLET_AXIS_MAX_POINTS 1024u" Maximum point count accepted by the phase-2A \fRrec_axis_store\fP value grammar (\fR"x,y[,z];x2,y2"\fP)\&. A value listing more points is rejected with -1 (\fRerrno\fP = \fRERANGE\fP): almost certainly a caller bug, and the grid + \fRrev\fP writes would be large\&. The point count is the number of \fR;\fP-separated points, whatever their dimension\&. .SS "#define ISLET_FILL_MAX_VOL 1048576u" Maximum bounding-box volume (in cells) accepted by the rec_axis_fill_bbox family (including rec_axis_fill_bbox_2_32)\&. Boxes whose volume exceeds this are rejected with -1: they are almost certainly a caller bug, and the sealed set would be huge\&. Raw islet_iter_N() carries no such cap — it only allocates for entries found\&. .SS "#define ISLET_MISS UINT32_MAX" Sentinel value returned by islet_get when no entry exists\&. .SH "Function Documentation" .PP .SS "bool islet_box_is_empty (uint32_t pdb_hd, int16_t x, int16_t y, uint16_t size)" .PP Test if an axis-aligned 2D bounding box contains any discrete data\&. Uses Morton Z-order box iteration to detect if any points exist in [x\&.\&.x+size-1, y\&.\&.y+size-1]\&. Returns true if the box is completely empty (pure procedural wilderness), false if discrete points or structures are present\&. .PP \fBParameters\fP .RS 4 \fIpdb_hd\fP Database handle from \fBislet_open()\fP\&. .br \fIx\fP Minimum X coordinate\&. .br \fIy\fP Minimum Y coordinate\&. .br \fIsize\fP Physical extent along X and Y\&. .RE .PP \fBReturns\fP .RS 4 true if completely empty, false if any point exists\&. .RE .PP .SS "uint32_t islet_cell_count_1 (uint32_t pdb_hd, int16_t * p)\fR [inline]\fP, \fR [static]\fP" .PP Count the values stored at a spatial coordinate\&. .PP \fBParameters\fP .RS 4 \fIpdb_hd\fP Database handle from \fBislet_open()\fP\&. .br \fIp\fP Point coordinate\&. Array of int16_t with at least the dimension count of the function used\&. .RE .PP \fBReturns\fP .RS 4 Number of values stored at this coordinate (0 if empty)\&. .RE .PP \fBSee also\fP .RS 4 \fBislet_get_1\fP \fBislet_get_2\fP \fBislet_get_3\fP \fBislet_get_4\fP .PP \fBislet_get_multi_1\fP islet_get_multi_2 islet_get_multi_3 islet_get_multi_4 .PP corm_count .RE .PP .SS "int islet_cell_next (uint32_t * ref, uint32_t cur)" .PP Advance a cell iterator and retrieve the next value\&. Retrieves the next value from the iterator created by islet_get_multi_N()\&. When all values have been returned, returns 0 and automatically frees the iterator\&. .PP \fBParameters\fP .RS 4 \fIref\fP Output pointer for the stored value (uint32_t)\&. .br \fIcur\fP Iterator handle from islet_get_multi_N()\&. .RE .PP \fBReturns\fP .RS 4 1 if a value was retrieved\&. 0 when iteration is complete; the iterator is automatically freed on return 0\&. .RE .PP \fBWarning\fP .RS 4 After this function returns 0, the iterator handle becomes invalid\&. .RE .PP \fBSee also\fP .RS 4 \fBislet_get_multi_1\fP islet_get_multi_2 islet_get_multi_3 islet_get_multi_4 .RE .PP .SS "void islet_del_1 (uint32_t pdb_hd, int16_t * p)\fR [inline]\fP, \fR [static]\fP" .PP Delete the first value stored at a spatial coordinate\&. Per-dimension variants (islet_del_1\&.\&.4); the function name carries the dimension count\&. Removes the first value stored at the given point from the database\&. Internally converts the coordinate to a Morton code and calls corm_del()\&. If no entry exists at the coordinate, this is a no-op (safe to call)\&. When several values share the cell, only the earliest-inserted one is removed; use \fBislet_del_all_3()\fP to clear the cell\&. .PP \fBParameters\fP .RS 4 \fIpdb_hd\fP Database handle from \fBislet_open()\fP\&. .br \fIp\fP Point coordinate\&. Array of int16_t with at least the dimension count of the function used\&. .RE .PP \fBNote\fP .RS 4 This operation invalidates any pointers obtained from \fBislet_get_3()\fP or \fBislet_next()\fP that refer to this coordinate\&. .PP Safe to call on non-existent coordinates (no error, no effect)\&. .RE .PP Example: .PP .nf int16_t pos[3] = {10, 20, 30}; islet_del_3(db, pos); // Remove entry at (10,20,30) .fi .PP .PP \fBSee also\fP .RS 4 \fBislet_get_3\fP .PP \fBislet_put_3\fP .PP corm_del .RE .PP .SS "uint32_t islet_del_all_1 (uint32_t pdb_hd, int16_t * p)\fR [inline]\fP, \fR [static]\fP" .PP Delete every value stored at a spatial coordinate\&. Per-dimension variants (islet_del_all_1\&.\&.4)\&. Removes all values stored at the given point from the database\&. Internally converts the coordinate to a Morton code and calls corm_del_all()\&. If no entry exists at the coordinate, this is a no-op (safe to call, returns 0)\&. .PP \fBParameters\fP .RS 4 \fIpdb_hd\fP Database handle from \fBislet_open()\fP\&. .br \fIp\fP Point coordinate\&. Array of int16_t with at least the dimension count of the function used\&. .RE .PP \fBReturns\fP .RS 4 Number of values removed (0 if the cell was empty)\&. .RE .PP Example: .PP .nf int16_t pos[3] = {10, 20, 30}; uint32_t n = islet_del_all_3(db, pos); // Clear the cell .fi .PP .PP \fBSee also\fP .RS 4 \fBislet_del_3\fP .PP \fBislet_set_3\fP .PP corm_del_all .RE .PP .SS "uint32_t islet_del_value_1 (uint32_t pdb_hd, int16_t * p, uint32_t thing)" .PP Delete one value from a spatial coordinate (phase-2A adapter primitive)\&. Per-dimension variants (islet_del_value_1\&.\&.4)\&. Removes every entry holding \fRthing\fP from the cell at the given point, leaving the cell's other values untouched (in their relative order)\&. Where islet_del_N() removes the first value and islet_del_all_N() clears the cell, this one removes by value — exactly what \fRrec_axis_unstore\fP needs when several refs share one cell\&. .PP \fBParameters\fP .RS 4 \fIpdb_hd\fP Database handle from \fBislet_open()\fP\&. .br \fIp\fP Point coordinate\&. Array of int16_t with at least the dimension count of the function used\&. .br \fIthing\fP Value to remove (uint32_t)\&. .RE .PP \fBReturns\fP .RS 4 Number of entries removed (0 when the cell is empty or holds no such value)\&. .RE .PP \fBNote\fP .RS 4 A pure cell primitive: it knows nothing of the phase-2A \fRrev\fP manifest\&. The \fRrec_axis_unstore\fP adapter (the rev-aware path) keeps cell and manifest in sync; callers manipulating the grid directly own that sync themselves\&. .RE .PP Example: .PP .nf int16_t pos[3] = {10, 20, 30}; islet_put_3(db, pos, 7); islet_put_3(db, pos, 9); islet_del_value_3(db, pos, 9); // Cell now holds exactly {7} .fi .PP .PP \fBSee also\fP .RS 4 \fBislet_del_1\fP \fBislet_del_all_1\fP \fBislet_cell_count_1\fP .RE .PP .SS "uint32_t islet_get_1 (uint32_t pdb_hd, int16_t * p)\fR [inline]\fP, \fR [static]\fP" .PP Retrieve the value stored at a spatial coordinate\&. Per-dimension variants (islet_get_1\&.\&.4)\&. Looks up the value at the given point in the database\&. Internally converts the coordinate to a Morton code and calls corm_get()\&. .PP \fBParameters\fP .RS 4 \fIpdb_hd\fP Database handle from \fBislet_open()\fP\&. .br \fIp\fP Point coordinate\&. Array of int16_t with at least the dimension count of the function used\&. Coordinates are signed 16-bit integers ranging from -32768 to 32767\&. .RE .PP \fBReturns\fP .RS 4 The first stored uint32_t value at this coordinate, or ISLET_MISS (UINT32_MAX) if no entry exists at this point\&. When several values share the cell, the earliest-inserted one is returned; use islet_get_multi_3() to retrieve them all\&. .RE .PP \fBNote\fP .RS 4 ISLET_MISS equals UINT32_MAX (0xFFFFFFFF), the same as CM_MISS\&. This is the standard sentinel value for missing entries\&. .PP The returned value is a copy, not a pointer\&. Unlike corm_get() which returns a pointer, \fBislet_get_3()\fP returns the actual uint32_t value\&. .RE .PP Example: .PP .nf int16_t pos[3] = {10, 20, 30}; uint32_t value = islet_get_3(db, pos); if (value == ISLET_MISS) { printf("No entry at (10,20,30)\\n"); } else { printf("Value at (10,20,30) = %u\\n", value); } .fi .PP .PP \fBSee also\fP .RS 4 \fBislet_put_3\fP .PP \fBislet_del_3\fP .PP \fBISLET_MISS\fP .PP corm_get .RE .PP .SS "uint32_t islet_get_multi_1 (uint32_t pdb_hd, int16_t * p)" .PP Create an iterator for all values stored at one coordinate\&. Opens a chain-aware cursor over every value stored at the given point, in insertion order\&. Use \fBislet_cell_next()\fP to retrieve the values\&. .PP \fBParameters\fP .RS 4 \fIpdb_hd\fP Database handle from \fBislet_open()\fP\&. .br \fIp\fP Point coordinate\&. Array of int16_t with at least the dimension count of the function used\&. .RE .PP \fBNote\fP .RS 4 Per-dimension variants islet_get_multi_1\&.\&.4\&. .RE .PP \fBReturns\fP .RS 4 Iterator handle for use with \fBislet_cell_next()\fP, or CM_MISS when the cell holds no values\&. .RE .PP Example: .PP .nf int16_t pos[3] = {10, 20, 30}; uint32_t cur = islet_get_multi_3(db, pos); if (cur != CM_MISS) { uint32_t value; while (islet_cell_next(&value, cur)) printf("value %u\\n", value); } .fi .PP .PP \fBSee also\fP .RS 4 \fBislet_cell_next\fP .PP \fBislet_cell_count_1\fP \fBislet_cell_count_2\fP \fBislet_cell_count_3\fP \fBislet_cell_count_4\fP .RE .PP .SS "void islet_init (void )" .PP Initialize the islet subsystem\&. Registers custom types with libcorm (uint64_t for Morton codes, uint32_t for values) and sets up the Morton code comparator for sorted iteration\&. Also initializes the internal IDM (ID Manager) for iterator handles\&. .PP \fBWarning\fP .RS 4 Must be called before any other islet functions\&. Calling other functions without initialization results in undefined behavior\&. .RE .PP \fBNote\fP .RS 4 This function can be called multiple times safely (idempotent if corm types are already registered)\&. .RE .PP Example: .PP .nf int main() { islet_init(); // Always call first uint32_t db = islet_open(NULL, NULL, 0xFF); // \&.\&.\&. use database return 0; } .fi .PP .PP \fBSee also\fP .RS 4 \fBislet_open\fP .RE .PP .SS "uint32_t islet_iter_1 (uint32_t pdb_hd, int16_t * s, uint16_t * l)" .PP Create an iterator for all points within a rectangular bounding box\&. Queries the spatial database for all entries within the axis-aligned bounding box defined by start point 's' and lengths 'l'\&. The iterator pre-allocates and collects all matching results using Morton code range queries internally\&. .PP \fBParameters\fP .RS 4 \fIpdb_hd\fP Database handle from \fBislet_open()\fP\&. .br \fIs\fP Start point (minimum corner of bounding box)\&. Array of int16_t with at least the dimension count of the function used\&. .br \fIl\fP Lengths of bounding box per dimension (unsigned)\&. Array of uint16_t with at least the dimension count of the function used\&. The box covers s[i]\&.\&.s[i]+l[i] inclusive per dimension\&. .RE .PP \fBNote\fP .RS 4 Per-dimension variants islet_iter_1\&.\&.4; the function name carries the dimension count (1\&.\&.4)\&. .RE .PP \fBReturns\fP .RS 4 Iterator handle for use with \fBislet_next()\fP\&. The handle is automatically freed when \fBislet_next()\fP returns 0\&. .RE .PP \fBNote\fP .RS 4 Results are collected in Morton code order (Z-order space-filling curve), NOT spatial order\&. Nearby points may not be adjacent in iteration sequence\&. .PP Every stored (point, value) pair is returned exactly once, including multiple values stored at the same cell\&. Results are NOT deduplicated\&. .PP Memory: Allocates a flat list that grows with the number of matching entries (not the bounding box volume), so sparse queries over large boxes stay cheap\&. .RE .PP \fBWarning\fP .RS 4 The volume calculation can overflow for very large boxes\&. Reasonable box sizes are recommended (< 1 million points)\&. .RE .PP Example (2D region): .PP .nf int16_t start[2] = {0, 0}; uint16_t lengths[2] = {100, 100}; // 100x100 region uint32_t iter = islet_iter_2(db, start, lengths); .fi .PP .PP Example (3D region): .PP .nf int16_t start[3] = {\-10, \-10, \-10}; uint16_t lengths[3] = {20, 20, 20}; // 20x20x20 cube (8000 points) uint32_t iter = islet_iter_3(db, start, lengths); .fi .PP .PP \fBSee also\fP .RS 4 \fBislet_next\fP .PP \fBmorton_set_1\fP \fBmorton_set_2\fP \fBmorton_set_3\fP \fBmorton_set_4\fP .RE .PP .SS "uint32_t islet_last_scan_count (void )" .PP Diagnostic: index entries examined by the last box walk\&. Returns the number of index entries examined by the most recent islet_iter_N()/rec_axis_fill_bbox_N() box walk in this process\&. Tests and benchmarks use it to prove the Z-interval skip engages (entries examined well below the morton-interval width on sparse boxes)\&. .PP \fBReturns\fP .RS 4 Entry-examination count of the last box walk (0 if none ran yet)\&. .RE .PP .SS "int islet_next (int16_t * p, uint32_t * ref, uint32_t cur)" .PP Advance iterator and retrieve the next point/value pair\&. Retrieves the next entry from the iterator created by islet_iter_N()\&. Skips empty cells in the bounding box\&. When all entries have been returned (or the box was empty), returns 0 and automatically frees the iterator's internal memory\&. .PP \fBParameters\fP .RS 4 \fIp\fP Output point array\&. Must have space for the dimension count of the matching islet_iter_N() call\&. Filled with the coordinates of the next point\&. .br \fIref\fP Output pointer for the stored value (uint32_t)\&. Filled with the value stored at this point\&. .br \fIcur\fP Iterator handle from islet_iter_N()\&. .RE .PP \fBReturns\fP .RS 4 1 if a point/value pair was retrieved (output written to p and ref)\&. 0 when iteration is complete (no more entries)\&. The iterator is automatically freed on return 0\&. .RE .PP \fBNote\fP .RS 4 The iterator is stateful and maintains position\&. Each call advances to the next entry\&. .PP Empty cells in the bounding box are automatically skipped\&. Only coordinates with stored values are returned\&. .RE .PP \fBWarning\fP .RS 4 After this function returns 0, the iterator handle becomes invalid\&. Do not call \fBislet_next()\fP again with the same handle\&. .PP The iterator's internal memory is freed when this returns 0\&. There is no separate "close" or "free" function\&. .RE .PP Typical usage pattern: .PP .nf int16_t start[3] = {0, 0, 0}; uint16_t lengths[3] = {10, 10, 10}; uint32_t iter = islet_iter(db, start, lengths, 3); int16_t point[3]; uint32_t value; while (islet_next(point, &value, iter)) { printf("Point (%d,%d,%d) = %u\\n", point[0], point[1], point[2], value); } // Iterator is automatically freed after loop .fi .PP .PP \fBSee also\fP .RS 4 islet_iter .RE .PP .SS "int islet_next32 (int32_t * p, uint32_t * ref, uint32_t cur)" .PP Advance a 2D x 32-bit iterator (islet_iter_2_32 handle)\&. Same contract as \fBislet_next()\fP, on int32_t lanes\&. Iterators from islet_iter_1\&.\&.4 use \fBislet_next()\fP; 2D x 32-bit iterators use this\&. .PP \fBParameters\fP .RS 4 \fIp\fP Output point array (int32_t[2])\&. .br \fIref\fP Output pointer for the stored value (uint32_t)\&. .br \fIcur\fP Iterator handle from \fBislet_iter_2_32()\fP\&. .RE .PP \fBReturns\fP .RS 4 1 on entry, 0 when complete (handle freed)\&. .RE .PP .SS "uint32_t islet_open (char * filename, char * database, uint32_t mask)" .PP Open or create a spatial database\&. Creates a spatial map backed by libcorm with CM_SORTED for efficient range queries\&. Internally uses Morton codes (uint64_t) as keys and uint32_t for values\&. If a filename is provided, data is automatically loaded from disk if the file exists\&. .PP \fBParameters\fP .RS 4 \fIfilename\fP File path for persistence, or NULL for in-memory only\&. Example: "world\&.db" .br \fIdatabase\fP Logical database name within the file, or NULL to skip file association\&. Multiple databases can share one file\&. Example: "main", "players", "chunks" .br \fImask\fP Hash table mask (initial capacity = mask + 1)\&. Must be 2^n - 1 for optimal performance\&. Examples: 0xFF (256 entries), 0xFFF (4096 entries), 0xFFFF (65536 entries)\&. The map auto-grows past this; pick a mask near your expected entry count\&. .RE .PP \fBReturns\fP .RS 4 Database handle for use with other islet functions\&. .RE .PP \fBNote\fP .RS 4 File Persistence: File-backed databases automatically load existing data when opened\&. Data is automatically saved at process exit via libcorm's destructor\&. Call corm_save() explicitly only if you need mid-execution checkpointing\&. .PP Capacity: The mask sizes the initial table; the map auto-grows by doubling when it fills\&. Nothing terminates on growth\&. .PP The database is created with CM_SORTED | CM_MULTIVALUE: ordered iteration by Morton code for efficient spatial range queries, with multi-value cells (see the Value Semantics note above)\&. .RE .PP \fBWarning\fP .RS 4 The filename and database parameters are not copied\&. If providing string literals, they must remain valid for the database lifetime\&. .RE .PP Example (in-memory): .PP .nf islet_init(); uint32_t db = islet_open(NULL, NULL, 0xFF); // 256\-entry initial table .fi .PP .PP Example (persistent): .PP .nf islet_init(); uint32_t db = islet_open("world\&.db", "main", 0xFFF); // 4096\-entry initial table .fi .PP .PP \fBSee also\fP .RS 4 \fBislet_init\fP .PP corm_open .PP corm_save .PP corm_close .RE .PP .SS "void islet_put_1 (uint32_t pdb_hd, int16_t * p, uint32_t thing)\fR [inline]\fP, \fR [static]\fP" .PP Store a value at a spatial coordinate (append)\&. Per-dimension variants (islet_put_1\&.\&.4)\&. Appends the value at the given point in the database\&. Internally converts the coordinate to a Morton code and calls corm_put()\&. If entries already exist at this coordinate, the new value is ADDED alongside them (multi-value cell) - nothing is replaced\&. Use islet_set_N() for replace semantics, islet_get_multi_N() to read all values back\&. .PP \fBParameters\fP .RS 4 \fIpdb_hd\fP Database handle from \fBislet_open()\fP\&. .br \fIp\fP Point coordinate\&. Array of int16_t with at least the dimension count of the function used\&. Coordinates are signed 16-bit integers ranging from -32768 to 32767\&. .br \fIthing\fP Value to store (uint32_t)\&. Can be any 32-bit value including 0\&. Avoid using CM_MISS (0xFFFFFFFF) as it may cause confusion, though it's technically valid\&. .RE .PP \fBNote\fP .RS 4 If the database is file-backed (filename provided to \fBislet_open()\fP), changes are automatically saved at process exit\&. Call corm_save() explicitly for mid-execution persistence\&. .RE .PP Example (store single value): .PP .nf int16_t pos[3] = {10, 20, 30}; islet_put_3(db, pos, 42); // Store value 42 at (10,20,30) .fi .PP .PP Example (update existing value): .PP .nf int16_t pos[3] = {10, 20, 30}; uint32_t old = islet_get_3(db, pos); if (old != ISLET_MISS) { islet_set_3(db, pos, old + 1); // Increment (replace) } .fi .PP .PP Example (populate a 2D grid): .PP .nf for (int16_t x = 0; x < 10; x++) { for (int16_t y = 0; y < 10; y++) { int16_t pos[2] = {x, y}; islet_put_2(db, pos, x * 10 + y); } } .fi .PP .PP \fBSee also\fP .RS 4 \fBislet_get_3\fP .PP \fBislet_del_3\fP .PP corm_put .PP corm_save .RE .PP .SS "void islet_set_1 (uint32_t pdb_hd, int16_t * p, uint32_t thing)\fR [inline]\fP, \fR [static]\fP" .PP Store a value at a spatial coordinate (replace)\&. Per-dimension variants (islet_set_1\&.\&.4)\&. Replaces every value at the given point with a single new value: islet_del_all_N() followed by islet_put_N()\&. This preserves the historical single-value overwrite convenience on top of multi-value cells\&. .PP \fBParameters\fP .RS 4 \fIpdb_hd\fP Database handle from \fBislet_open()\fP\&. .br \fIp\fP Point coordinate\&. Array of int16_t with at least the dimension count of the function used\&. .br \fIthing\fP Value to store (uint32_t)\&. .RE .PP Example: .PP .nf int16_t pos[3] = {10, 20, 30}; islet_put_3(db, pos, 42); islet_set_3(db, pos, 99); // Cell now holds exactly {99} .fi .PP .PP \fBSee also\fP .RS 4 \fBislet_put_3\fP .PP \fBislet_del_all_3\fP .PP \fBislet_get_3\fP .RE .PP .SS "uint32_t morton_get_bulk (int16_t points[][3], const uint64_t * codes, uint32_t n)" .PP Batch-decode multiple 3D Morton codes to points using SIMD\&. Inverse of \fBmorton_set_bulk()\fP: decodes 4 codes at a time under AVX2 (dense compact, scalar tail + fallback otherwise)\&. Output points match \fBmorton_get_3()\fP exactly\&. .PP \fBParameters\fP .RS 4 \fIpoints\fP Output points\&. Array of int16_t[3] with 'n' entries\&. .br \fIcodes\fP Input Morton codes\&. Array of uint64_t with 'n' elements\&. .br \fIn\fP Number of codes to decode (0\&.\&.UINT32_MAX)\&. .RE .PP \fBReturns\fP .RS 4 Number of points decoded (always == n)\&. .RE .PP .SS "uint32_t morton_get_bulk4 (int16_t points[][4], const uint64_t * codes, uint32_t n)" .PP Batch-decode multiple 4D Morton codes to points using SIMD\&. 4D analogue of \fBmorton_get_bulk()\fP: decodes 4 codes at a time under AVX2 (dense stride-4 compact), scalar tail + fallback otherwise\&. Output points match \fBmorton_get_4()\fP exactly\&. .PP \fBParameters\fP .RS 4 \fIpoints\fP Output points\&. Array of int16_t[4] with 'n' entries\&. .br \fIcodes\fP Input Morton codes\&. Array of uint64_t with 'n' elements\&. .br \fIn\fP Number of codes to decode (0\&.\&.UINT32_MAX)\&. .RE .PP \fBReturns\fP .RS 4 Number of points decoded (always == n)\&. .RE .PP .SS "uint32_t morton_set_bulk (uint64_t * out, int16_t points[][3], uint32_t n)" .PP Batch-encode multiple 3D points to Morton codes using SIMD\&. Encodes up to 4 points (AVX2) or 2 points (NEON) in parallel, falling back to scalar for remaining points\&. The output array must have space for at least \fRn\fP elements\&. .PP \fBParameters\fP .RS 4 \fIout\fP Output Morton codes\&. Array of uint64_t with 'n' elements\&. .br \fIpoints\fP Input points\&. Array of int16_t[3] with 'n' entries\&. .br \fIn\fP Number of points to encode (0\&.\&.UINT32_MAX)\&. .RE .PP \fBReturns\fP .RS 4 Number of points encoded (always == n)\&. .RE .PP .SS "uint32_t morton_set_bulk4 (uint64_t * out, int16_t points[][4], uint32_t n)" .PP Batch-encode multiple 4D points to Morton codes using SIMD\&. 4D analogue of \fBmorton_set_bulk()\fP: encodes 4 points at a time under AVX2 (dense stride-4 packing), scalar tail + fallback otherwise\&. Output codes match \fBmorton_set_4()\fP exactly\&. .PP \fBParameters\fP .RS 4 \fIout\fP Output Morton codes\&. Array of uint64_t with 'n' elements\&. .br \fIpoints\fP Input points\&. Array of int16_t[4] with 'n' entries\&. .br \fIn\fP Number of points to encode (0\&.\&.UINT32_MAX)\&. .RE .PP \fBReturns\fP .RS 4 Number of points encoded (always == n)\&. .RE .PP .SS "int rec_axis_fill_bbox_1 (uint32_t pdb_hd, int16_t * s, uint16_t * l, rec_set_t * out)" .PP Fill a recall candidate set with the values in a bounding box\&. Per-dimension variants (rec_axis_fill_bbox_1\&.\&.4)\&. Kernel-form space-axis adapter: streams every value stored in the axis-aligned box [s, s+l] into a recall candidate set, then seals it (sort + dedup)\&. Multiple values sharing one cell each enter the set; sealing collapses exact duplicates\&. The walk never materializes the box volume — sparse queries over large boxes stay cheap\&. .PP \fBParameters\fP .RS 4 \fIpdb_hd\fP Database handle from \fBislet_open()\fP\&. .br \fIs\fP Start point (minimum corner)\&. Array of int16_t\&. .br \fIl\fP Lengths per dimension\&. Array of uint16_t\&. .br \fIout\fP Caller-owned candidate set; appended to, then sealed\&. May already hold refs (result is the union, sealed)\&. .RE .PP \fBReturns\fP .RS 4 0 on success (out sealed)\&. -1 when out is NULL, or the box volume exceeds ISLET_FILL_MAX_VOL (note: 4D volumes are 4-way products, so keep each side small)\&. .RE .PP Example: .PP .nf rec_set_t *cands = rec_set_new(); int16_t s[3] = {0, 0, 0}; uint16_t l[3] = {16, 16, 16}; if (rec_axis_fill_bbox_3(db, s, l, cands) == 0) { // rec_set_count(cands) distinct refs, sorted } rec_set_free(cands); .fi .PP .PP \fBSee also\fP .RS 4 \fBISLET_FILL_MAX_VOL\fP .PP \fBislet_iter_1\fP islet_iter_2 islet_iter_3 islet_iter_4 .RE .PP .SH "Variable Documentation" .PP .SS "const \fBislet_ops_t\fP islet_ops[5]\fR [extern]\fP" .PP The per-dimension operation table (islet_ops[0] = all NULL)\&. NOTE: literal 5 (MAX_DIM + 1) here — MAX_DIM lives in libislet\&.c and this header stays standalone\&. Keep the two in sync\&. .SH "Author" .PP Generated automatically by Doxygen for islet from the source code\&.