2

我正在寻找一些建议,因为我目前正在为集合抽象的命名画一个空白。这可能是一个稍微偏离主题的问题,如果被认为是这种情况,我们深表歉意。

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

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

我目前对该集合抽象的工作名称是“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;
};
4

6 回答 6

4

根据您问题的措辞,显而易见的NestedMap呢?

另一个想到的是HyperMap。根据定义,意味着超越;以上; 超过;过度; 高于 normal,所有这些都可以用来描述 map 存储的不仅仅是普通键/值对的事实。

于 2015-02-26T10:13:36.320 回答
1

基于此集合允许的空间嵌套,HierarchicalMap、HierarchyMap 或 HierMap 怎么样?

于 2015-02-27T04:49:25.443 回答
1

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

于 2015-02-27T09:31:34.600 回答
0

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

或者AlexMapALXmap正如你发明的那样。

于 2015-02-27T14:07:20.737 回答
0

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

会更新更多的想法。

于 2015-02-27T05:01:05.293 回答
0

这是一个SuperMap

由于它是一个可以映射其他 Maps/Collections 的 Map,因此想到的一些名称是CollectionMap, BucketMap,甚至可能BucketTree取决于您的实现。

于 2015-02-27T12:23:04.583 回答