Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-12421

Use strongly typed keys to access compiled configurations

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • Storage Engines

      WT-11126 uses IDs for every key.  That means a lookup like

      WT_ERR(__wt_conf_gets_def(session, conf, isolation, 0, &cval)) 

      translates (via a macro) into a function call to look up integer id WT_CONF_ID_isolation.

      y.ershov@mongodb.com made a great suggestion during the review that instead of declaring

        WT_CONF *conf

      we could declare:

        WT_CONF_session_begin_transaction *conf

      That structure could be something like:

        typedef struct {
             WT_CONFIG_ITEM isolation;
             WT_CONFIG_ITEM sync;
             struct {
                WT_CONFIG_ITEM prepared;
                WT_CONFIG_ITEM read;
            } roundup_timestamps;
        } WT_CONF_session_begin_transaction;

      Then getting value amounts to:

         cval = conf->isolation;

      This is all hidden by a macro, so the WT code remains as:

      WT_ERR(__wt_conf_gets_def(session, conf, isolation, 0, &cval)) 

      It's not entirely that simple, we do need to do something a bit different with bound arguments.

      The only drawback I see is how we deal with sets of keys that are shared among multiple APIs. If there is a common function that parses the configs for say, open_session and session->reconfigure, how do we share that? I think there are solutions to this.

            donald.anderson@mongodb.com Donald Anderson
            donald.anderson@mongodb.com Donald Anderson
            0 Vote for this issue
            3 Start watching this issue