Skip to content
  • Sivert Sorumgard's avatar
    f2adb043
    Bug#27309072: Need a stable api for handling dd::properties. · f2adb043
    Sivert Sorumgard authored
    This patch does some refactoring of the dd::Properties interface and
    implementation, and introduces a way of defining which keys are
    valid for a given Property object. Upon the definition of such a set,
    the validity of the keys will be checked upon setting or getting the
    value of the key.
    
    In more detail, the patch implements the following:
    
    1.  Change iterator type names to conform to STL, thus allowing
        e.g. range based loops.
    2.  Remove the type specific get()/set() functions and introduce
        templates and overloads instead.
    3.  Make all get() variants work in the same way regarding non-existing
        keys: Assert in debug builds, return 'true' in non-debug builds.
        Previously, the behavior was not uniform.
    4.  Remove the value() methods, support only get() instead.
    5.  Embed the std::map into the Properties_impl class directly without
        using a unique_ptr.
    6.  Add a std::set to Properties_impl for storing valid key names.
    7.  When calling the set() and get() variants, verify that the submitted
        key is valid, unless the set of valid keys is empty. If the key is
        invalid, write a warning to the error log, assert in debug builds,
        return 'true' to the caller in release builds. Note that an error is
        not reported here, just written to the error log. It is up to the
        caller to decide how to handle this.
    8.  Filter out any invalid keys when generating a raw string. This might
        be relevant in e.g. an upgrade/downgrade situation.
    9.  Filter out invalid keys when assignning from another property object
        or from a raw string, using the copy_values() methods. This is done
        silently without error reporting or asserts, since it is likely to
        happen e.g. when reading persistent meta data in an upgrade/downgrade
        situation. Note that copy_values() will copy only the key-value pairs,
        the set of valid keys in the source object are not copied.
    10. In the DD objects using Properties, we now embed the property objects
        as proper data members instead of using a unique_ptr. This also makes
        object cloning simpler.
    11. There is no custom copy constructor, the default will apply, and this
        will copy both the set of valid keys and the key-value pairs
        themselves.
    
    Sets of valid keys are added for the Properties that are currently used
    by the DD object classes, i.e.:
    
        dd::Abstract_table_impl::m_options
        dd::Column_impl::m_options
        dd::Column_impl::m_se_private_data
        dd::Index_impl::m_options
        dd::Index_impl::m_se_private_data
        dd::Parameter_impl::m_options
        dd::Partition_impl::m_options
        dd::Partition_impl::m_se_private_data
        dd::Partition_index_impl::m_se_private_data
        dd::Tablespace_impl::m_options
        dd::Tablespace_impl::m_se_private_data
        dd::Table_impl::m_se_private_data
    
    The infrastructure implemented in this patch also allows similar sets of
    valid keys to be collected and defined for other classes making use of
    the dd::Properties implementation.
    
    Change-Id: I9c80cc3cbea1fb00bf5b96be77b8ebf471954f23
    f2adb043
    Bug#27309072: Need a stable api for handling dd::properties.
    Sivert Sorumgard authored
    This patch does some refactoring of the dd::Properties interface and
    implementation, and introduces a way of defining which keys are
    valid for a given Property object. Upon the definition of such a set,
    the validity of the keys will be checked upon setting or getting the
    value of the key.
    
    In more detail, the patch implements the following:
    
    1.  Change iterator type names to conform to STL, thus allowing
        e.g. range based loops.
    2.  Remove the type specific get()/set() functions and introduce
        templates and overloads instead.
    3.  Make all get() variants work in the same way regarding non-existing
        keys: Assert in debug builds, return 'true' in non-debug builds.
        Previously, the behavior was not uniform.
    4.  Remove the value() methods, support only get() instead.
    5.  Embed the std::map into the Properties_impl class directly without
        using a unique_ptr.
    6.  Add a std::set to Properties_impl for storing valid key names.
    7.  When calling the set() and get() variants, verify that the submitted
        key is valid, unless the set of valid keys is empty. If the key is
        invalid, write a warning to the error log, assert in debug builds,
        return 'true' to the caller in release builds. Note that an error is
        not reported here, just written to the error log. It is up to the
        caller to decide how to handle this.
    8.  Filter out any invalid keys when generating a raw string. This might
        be relevant in e.g. an upgrade/downgrade situation.
    9.  Filter out invalid keys when assignning from another property object
        or from a raw string, using the copy_values() methods. This is done
        silently without error reporting or asserts, since it is likely to
        happen e.g. when reading persistent meta data in an upgrade/downgrade
        situation. Note that copy_values() will copy only the key-value pairs,
        the set of valid keys in the source object are not copied.
    10. In the DD objects using Properties, we now embed the property objects
        as proper data members instead of using a unique_ptr. This also makes
        object cloning simpler.
    11. There is no custom copy constructor, the default will apply, and this
        will copy both the set of valid keys and the key-value pairs
        themselves.
    
    Sets of valid keys are added for the Properties that are currently used
    by the DD object classes, i.e.:
    
        dd::Abstract_table_impl::m_options
        dd::Column_impl::m_options
        dd::Column_impl::m_se_private_data
        dd::Index_impl::m_options
        dd::Index_impl::m_se_private_data
        dd::Parameter_impl::m_options
        dd::Partition_impl::m_options
        dd::Partition_impl::m_se_private_data
        dd::Partition_index_impl::m_se_private_data
        dd::Tablespace_impl::m_options
        dd::Tablespace_impl::m_se_private_data
        dd::Table_impl::m_se_private_data
    
    The infrastructure implemented in this patch also allows similar sets of
    valid keys to be collected and defined for other classes making use of
    the dd::Properties implementation.
    
    Change-Id: I9c80cc3cbea1fb00bf5b96be77b8ebf471954f23
Loading