![]() |
Signet Forge 0.1.0
C++20 Parquet library with AI-native extensions
|
DEMO |
Z-order curve (Morton code) utilities for spatial sort keys. More...
Classes | |
| struct | ZOrderColumn |
| Descriptor for a single column of raw typed data used by ZOrderSorter. More... | |
| struct | ZOrderSorter |
| Computes a permutation vector that reorders rows by Z-order (Morton) key. More... | |
Functions | |
| uint32_t | normalize_int32 (int32_t v) |
| Normalize a signed 32-bit integer to an unsigned 32-bit integer that preserves the original sort order (flip the sign bit). | |
| uint64_t | normalize_int64 (int64_t v) |
| Normalize a signed 64-bit integer to uint64_t (flip sign bit). | |
| uint32_t | normalize_float (float v) |
| Normalize a 32-bit float to uint32_t preserving total order. | |
| uint64_t | normalize_double (double v) |
| Normalize a 64-bit double to uint64_t preserving total order. | |
| uint32_t | normalize_string (std::string_view v) |
| Normalize a string to uint32_t by taking the first 4 bytes in big-endian order. | |
| uint32_t | truncate_to_32 (uint64_t v) |
| Truncate a uint64_t to uint32_t by extracting the upper 32 bits. | |
| uint64_t | morton_2d (uint32_t x, uint32_t y) |
| Interleave bits of two uint32_t values into a single uint64_t Morton code (2D). | |
| void | deinterleave_2d (uint64_t code, uint32_t &x, uint32_t &y) |
| Deinterleave a 2D Morton code back into its two uint32_t components. | |
| std::vector< uint8_t > | morton_nd (const std::vector< uint32_t > &normalized, size_t bits_per_col=32) |
| Generalized N-column Morton code via round-robin bit interleaving (MSB-first). | |
Z-order curve (Morton code) utilities for spatial sort keys.
|
inline |
Deinterleave a 2D Morton code back into its two uint32_t components.
Inverse of morton_2d(): extracts even-positioned bits into x and odd-positioned bits into y.
| code | 64-bit Morton code produced by morton_2d(). | |
| [out] | x | First column value (even bit positions). |
| [out] | y | Second column value (odd bit positions). |
Definition at line 155 of file z_order.hpp.
|
inline |
Interleave bits of two uint32_t values into a single uint64_t Morton code (2D).
This is the fast path for 2-column Z-ordering. Uses the parallel bit-deposit "magic bits" technique to spread each 32-bit input across alternating bit positions in the 64-bit result.
| x | First column's normalized uint32_t value (occupies even bit positions). |
| y | Second column's normalized uint32_t value (occupies odd bit positions). |
Definition at line 134 of file z_order.hpp.
|
inline |
Generalized N-column Morton code via round-robin bit interleaving (MSB-first).
Supports 2-8 columns, each providing a uint32_t normalized value. Bits are interleaved in round-robin order starting from the most significant bit of each column, producing a byte-array sort key suitable for lexicographic comparison.
The output length is ceil(N * bits_per_col / 8) bytes.
| normalized | Vector of N normalized uint32_t values (one per column). |
| bits_per_col | Number of bits to interleave per column (default 32). |
normalized is empty. Definition at line 183 of file z_order.hpp.
|
inline |
Normalize a 64-bit double to uint64_t preserving total order.
Same IEEE 754 sign-magnitude trick as normalize_float(), but for doubles.
| v | Double input value. |
Definition at line 83 of file z_order.hpp.
|
inline |
Normalize a 32-bit float to uint32_t preserving total order.
Uses the IEEE 754 sign-magnitude trick: negative floats have all bits flipped; non-negative floats have only the sign bit flipped. The result sorts identically to the original float values when compared as unsigned.
| v | Float input value. |
Definition at line 70 of file z_order.hpp.
|
inline |
Normalize a signed 32-bit integer to an unsigned 32-bit integer that preserves the original sort order (flip the sign bit).
| v | Signed input value. |
Definition at line 51 of file z_order.hpp.
|
inline |
Normalize a signed 64-bit integer to uint64_t (flip sign bit).
| v | Signed input value. |
Definition at line 58 of file z_order.hpp.
|
inline |
Normalize a string to uint32_t by taking the first 4 bytes in big-endian order.
Strings shorter than 4 bytes are zero-padded on the right, so "AB" becomes 0x41420000. This provides a coarse sort-preserving key suitable for Morton interleaving (lexicographic order is preserved for the first 4 chars).
| v | String input (only the first 4 bytes are used). |
Definition at line 102 of file z_order.hpp.
|
inline |
Truncate a uint64_t to uint32_t by extracting the upper 32 bits.
Used to reduce 64-bit normalized values (int64, double) to 32-bit Morton inputs. The upper bits carry the most significant information for sorting.
| v | 64-bit normalized value. |
v. Definition at line 117 of file z_order.hpp.