I need to store and manage some data on the STM32F1. Up to a few GB. I
want to store the data on a SD Card.
Why an STM32F1? The fact that you intend to fill multiple gigabytes show
that power consumption doesn't really matter. The time to create the
data, let alone write over the F1's SDIO interface, rule out a battery
powered installation. At that point, just chose a more capable MCU.
So, I searched for some databases to use them within RIOT. Wasn't that
successful.
I'd research how the available file systems implement their directory
indexes. They might already use optimized datastructures for that. Then
just use them with nested folders.
E.g., if your key is "foobar", hash that into "ABCDEFGFOOHASH" (always
same hash length), then store it into "/AB/CD/EF/GF/OOHASH". Create
folders as needed. Depending on the used indexing, nest deeper or less
deep. To get a key, try to open the file belonging to the hashed key
string. Let the file system do the work.