erthink / libmdbx

One of the fastest embeddable key-value ACID database without WAL. libmdbx surpasses the legendary LMDB in terms of reliability, features and performance.
https://erthink.github.io/libmdbx/
Other
1.16k stars 111 forks source link

Question: how to get original flags a map was created with ? #211

Closed AndreaLanfranchi closed 3 years ago

AndreaLanfranchi commented 3 years ago

Though I think the question is pretty explicative here a scenario. Say I want to create a clone of a map (or bucket or table ... the naming is fancy) and I need to derive original key_mode and value_mode so I can properly insert data in target. How can I do that ?

AndreaLanfranchi commented 3 years ago

Suggestion ... can we get map flags being reported as result of txn.get_map_stat(...) ?

erthink commented 3 years ago

Basically: open dbi with MDBX_DB_ACCEDE flag and get star, but for now "accede" not available in the C++ API.

AndreaLanfranchi commented 3 years ago

But from my understanding MDBX_Accede inherits the flags of the already opened ENV. It has nothing to do with map flags. Also I want to create a clone of the table in the same DB (so accede is not relevant IMHO)

AndreaLanfranchi commented 3 years ago

And get stat from map does not return creation flags (checked in core.c)

erthink commented 3 years ago

I'm on my way now and can't answer in detail. Briefly:

AndreaLanfranchi commented 3 years ago

Sorry for delayed response
Yes sorry I have confused MDBX_ACCEDE (which is env related) with MDBX_DB_ACCEDE (which is dbi related). To be honest the confusion is also due to the fact MDBX_DB_ACCEDE = MDBX_ACCEDE whilest being in two different enums.

Thank you.

AndreaLanfranchi commented 3 years ago

Just for reference it is possible to do this using C++ API

        auto named_map{txn.open_map("whatever")};
        auto info{txn.get_handle_info(named_map)};

Info struct contains both flags and two helper methods to get valuemode and keymode