如何命名同时充当其他集合容器的B+树键/值映射集合

How to name a B+Tree key/value map collection that also acts as the container for other collections

本文关键字:集合 树键 映射 其他 何命名      更新时间:2023-10-16

我正在寻求一些建议,因为我目前对集合抽象的命名一无所知。这可能是一个稍微偏离主题的问题,所以如果认为是这样的话,请道歉。

我正在开发一个库,该库提供B+树存储,并支持该B+树上的几种集合接口,例如键/值映射和排序集。

一种特殊类型的集合除了允许常规映射键/值存储外,还显式支持嵌套子集合。这提供了名称空间/表空间/键空间支持的方法。

我目前对这个集合抽象的工作名称是"MultiMap"。但这感觉不对,也与STL多映射不太一致。但到目前为止,我还没能想出更好的办法。

任何关于更好的名字的建议都将不胜感激。

作为额外信息,请参阅我现在正在考虑的接口定义如下:

/** Represents a map that can be the container for nested collections. 
 *  This allows having arbitrarily deep nesting for collections to support
 *  organization into (hierarchies of) separate name, key or table spaces. 
 *  So instead of for example having a map that contains variable length 
 *  keys such as "users/1", "users/2", etc. a nested collection "users" 
 *  could be created that has fixed size integer keys (1, 2, ...). Note 
 *  that storage for collections can be expensive. If not stored as a 
 *  small embedded collection with only a few items, it will take up at 
 *  least one physical storage page. Like in a regular map, all keys must 
 *  be unique and items are stored in sorted key order. */
class IMultiMapCursor : public virtual IMapCursor {
public:
    /** Positions the cursor at the first nested child collection, if any */
    virtual bool SeekFirstNestedCollection() = 0;
    /** Moves the cursor to the next nested child collection, if any */
    virtual bool SeekNextNestedCollection() = 0;
    /** Opens or creates a key/value map with the given @map_id under the
     *  map for this cursor, and returns a cursor to the nested map. */
    virtual IMapCursor* OpenNestedMap(
        const Slice& map_id, 
        const MapOptions& map_options = MapOptions::kOpenExisting) = 0;
    /** Opens or creates a key/value map with the given @path_to_map, 
     *  relative to the map for this cursor, and returns a cursor to the 
     *  nested map. */
    virtual IMapCursor* OpenNestedMap(
        const CollectionPath& path_to_map,
        const MapOptions& map_options = MapOptions::kOpenExisting) = 0;
    /** Opens or creates a key/value multi-map with the given @map_id under 
     *  the map for this cursor, and returns a cursor to the nested map. */
    virtual IMultiMapCursor* OpenNestedMultiMap(
        const Slice& map_id, 
        const MapOptions& map_options = MapOptions::kOpenExisting) = 0;
    /** Opens or creates a key/value multi-map with the given @path_to_map,
     *  relative to the map for this cursor, and returns a cursor to the
     *  nested map. */
    virtual IMultiMapCursor* OpenNestedMultiMap(
        const CollectionPath& path_to_map,
        const MapOptions& map_options = MapOptions::kOpenExisting) = 0;
    /** Opens or creates a sorted set with the given @set_id under the map
     *  for this cursor, and returns a cursor to the nested set. */
    virtual ISortedSetCursor* OpenNestedSortedSet(
        const Slice& set_id, 
        const SetOptions& set_options = SetOptions::kOpenExisting) = 0;
    /** Opens or creates a sorted set with the given @path_to_set,
     *  relative to the map for this cursor, and returns a cursor to the
     *  nested set. */
    virtual ISortedSetCursor* OpenNestedSortedSet(
        const CollectionPath& path_to_set,
        const SetOptions& set_options = SetOptions::kOpenExisting) = 0;
    /** Opens or creates a non-sorted set with the given @set_id under the 
     *  map for this cursor, and returns a cursor to the nested set. */
    virtual ISetCursor* OpenNestedSet(
        const Slice& set_id, 
        const SetOptions& set_options = SetOptions::kOpenExisting) = 0;
    /** Opens or creates a non-sorted set with the given @path_to_set, relative to the 
     *  map for this cursor, and returns a cursor to the nested set. */
    virtual ISetCursor* OpenNestedSet(
        const CollectionPath& path_to_set,
        const SetOptions& set_options = SetOptions::kOpenExisting) = 0;
    /** Opens or creates a list with the given @list_id under this map, and 
     *  returns a cursor to the nested list. */
    virtual IListCursor* OpenNestedList(
        const Slice& list_id, 
        const ListOptions& list_options = ListOptions::kOpenExisting) = 0;
    /** Opens or creates a list with the given @path_to_list under this map, 
     *  and returns a cursor to the nested list. */
    virtual IListCursor* OpenNestedList(
        const CollectionPath& path_to_list, 
        const ListOptions& list_options = ListOptions::kOpenExisting) = 0;
    /** Renames the existing collection with id @current_id to @new_id. 
     *  Requires (a) @new_id to be available. (b) the collection not to 
     *  have an open cursor. */
    virtual bool RenameNestedChildCollection(const Slice& current_id, const Slice& new_id) = 0;
};

根据问题的措辞,显而易见的NestedMap如何?

脑海中浮现的另一个是HyperMap。根据定义,hyper意味着超越;在上面超过;过度;高于正常,所有这些都可以用来描述映射存储的不仅仅是正常的键/值对。

TreeMap怎么样?映射的值可以是表示键/值对的单节点树(叶),也可以是表示其他值的非单节点树。每个值都将完全满足树的定义,允许一致的命名,前提是这些结构实际上是树(即没有到兄弟的互连)。请注意,即使是没有值的键也是有效的树。

基于此集合允许的空间嵌套,HierarchicalMap、HierarchyMap或HierMap如何?

因为它映射树中的键/值:KeyTree/MapTree,CollectionTree或者由于值可以被认为是离散的:DiscreteTree/DiscreteStructureTree

会随着更多的思考而更新。

这是一个SuperMap

由于它是一个可以映射其他Maps/Collections的Map,因此根据您的实现,您会想到一些名称是CollectionMapBucketMap,甚至可能是BucketTree

FlexMap作为您的集合抽象具有灵活性。

或者AlexMapALXmap,就像你发明的那样。