我正在寻找一些建议,因为我目前正在为集合抽象的命名画一个空白。这可能是一个稍微偏离主题的问题,如果被认为是这种情况,我们深表歉意。
我正在开发一个提供 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;
};