My keys are URLs, and many are exceeding max key size (511 bytes). Maybe I could make a hash of the URL, as the key, and the URL itself as the value. Would be nice to have an adjustable key size.
According to AI:
The maximum key size in LMDB (Lightning Memory-Mapped Database) is generally not configurable through Nim wrapper libraries like limdb at runtime or via simple settings.
Key Points:
Compile-Time Constant: The limit is determined by a compile-time constant, typically named MDB_MAXKEYSIZE, within the underlying C LMDB library itself. This constant is set when the C library is compiled, and it usually defaults to 511 bytes.
Nim Wrapper Role: The Nim wrapper library simply uses the C library it's linked against. It can query the max key size the C library reports, but it cannot change it after the C library has been compiled.
Changing the Limit (Advanced): To increase the limit, you must:
Get the LMDB C library's source code.
Modify the value of the MDB_MAXKEYSIZE constant in the C source files (often in lmdb.h).
Recompile the C library from the modified source.
Ensure your Nim application links against this newly compiled custom C library instead of the standard one.
Considerations: This process is complex, and databases created with different max key sizes might have compatibility issues. It's crucial that all programs accessing the same database use an LMDB C library compiled with the same MDB_MAXKEYSIZE.
Common Alternatives: Due to the complexity and compatibility concerns, it's often more practical to work within the default limit by using techniques like:
Hashing longer keys and using the hash as the database key.
Skipping records with keys that exceed the limit.
Redesigning the key structure to ensure keys fit.
In essence, changing the max key size is a modification to the underlying C library, not a setting within the Nim wrapper.
My keys are URLs, and many are exceeding max key size (511 bytes). Maybe I could make a hash of the URL, as the key, and the URL itself as the value. Would be nice to have an adjustable key size.
According to AI:
The maximum key size in LMDB (Lightning Memory-Mapped Database) is generally not configurable through Nim wrapper libraries like limdb at runtime or via simple settings.
Key Points:
In essence, changing the max key size is a modification to the underlying C library, not a setting within the Nim wrapper.