refactor: support multi-column ordered index, optimize code#139
refactor: support multi-column ordered index, optimize code#139
Conversation
5bd8097 to
810d61b
Compare
68c628f to
f11b8f9
Compare
| @@ -131,6 +138,9 @@ func ParseOrderedMapKeyType(fd protoreflect.FieldDescriptor) string { | |||
| return "double" | |||
| case protoreflect.StringKind: | |||
| return "std::string" | |||
| case protoreflect.EnumKind: | |||
| protoFullName := string(fd.Enum().FullName()) | |||
| return strings.ReplaceAll(protoFullName, ".", "::") | |||
There was a problem hiding this comment.
The Map, OrderedMap, Index, and OrderedIndex all should process the enum key in the same way.
There was a problem hiding this comment.
Only for ordered index currently, so rename this function to ParseOrderedIndexKeyType.
| } | ||
| } | ||
| keys = append(keys, MapKey{ParseMapKeyType(fd.MapKey()), name}) | ||
| keys = append(keys, newKey) |
There was a problem hiding this comment.
Should not write back to slice receiver, as it's error-prone.
| @@ -0,0 +1,306 @@ | |||
| package orderedindex | |||
There was a problem hiding this comment.
Rename dir to be consistent with package name:
ordered_index->orderedindexordered_map->orderedmap
| } | ||
| } | ||
|
|
||
| func (x *Generator) Generate() bool { |
| using OrderedMap_Hero_AttrMap = std::map<std::string, const protoconf::HeroConf::Hero::Attr*>; | ||
| const OrderedMap_Hero_AttrMap* GetOrderedMap(const std::string& name) const; | ||
|
|
||
| using Hero_OrderedMapValue = std::pair<Hero_Attr_OrderedMap, const protoconf::HeroConf::Hero*>; | ||
| using Hero_OrderedMap = std::map<std::string, Hero_OrderedMapValue>; | ||
| const Hero_OrderedMap* GetOrderedMap() const; | ||
| using OrderedMap_HeroValue = std::pair<OrderedMap_Hero_AttrMap, const protoconf::HeroConf::Hero*>; | ||
| using OrderedMap_HeroMap = std::map<std::string, OrderedMap_HeroValue>; | ||
| const OrderedMap_HeroMap* GetOrderedMap() const; | ||
|
|
||
| private: | ||
| Hero_OrderedMap ordered_map_; | ||
| OrderedMap_HeroMap ordered_map_; |
There was a problem hiding this comment.
Should not change this. Keep compatible, and its naming is ok.
There was a problem hiding this comment.
Naming convention: <Package>_<Message>_[OrderedMap|Index|OrederedIndex]_[Levels]
| // Index types. | ||
| // Index: Title | ||
| type HeroConf_Index_AttrMap = map[string][]*protoconf.HeroConf_Hero_Attr | ||
| type Index_HeroConf_AttrMap = map[string][]*protoconf.HeroConf_Hero_Attr |
There was a problem hiding this comment.
The original name means in the namespace HeroConf.
| indexItemDefaultInfoMap Index_ItemConf_ItemDefaultInfoMap | ||
| indexItemExtInfoMap Index_ItemConf_ItemExtInfoMap | ||
| indexAwardItemMap Index_ItemConf_AwardItemMap | ||
| indexSpecialItemMap Index_ItemConf_SpecialItemMap | ||
| indexItemPathDirMap Index_ItemConf_ItemPathDirMap | ||
| indexItemPathNameMap Index_ItemConf_ItemPathNameMap | ||
| indexItemPathFriendIdMap Index_ItemConf_ItemPathFriendIDMap | ||
| indexUseEffectTypeMap Index_ItemConf_UseEffectTypeMap | ||
| orderedIndexExtTypeMap *OrderedIndex_ItemConf_ExtTypeMap | ||
| orderedIndexParamExtTypeMap *OrderedIndex_ItemConf_ParamExtTypeMap |
There was a problem hiding this comment.
The original naming is more better and self-evident.
| using OrderedMap_Hero_AttrMap = std::map<std::string, const protoconf::HeroConf::Hero::Attr*>; | ||
| const OrderedMap_Hero_AttrMap* GetOrderedMap(const std::string& name) const; | ||
|
|
||
| using Hero_OrderedMapValue = std::pair<Hero_Attr_OrderedMap, const protoconf::HeroConf::Hero*>; | ||
| using Hero_OrderedMap = std::map<std::string, Hero_OrderedMapValue>; | ||
| const Hero_OrderedMap* GetOrderedMap() const; | ||
| using OrderedMap_HeroValue = std::pair<OrderedMap_Hero_AttrMap, const protoconf::HeroConf::Hero*>; | ||
| using OrderedMap_HeroMap = std::map<std::string, OrderedMap_HeroValue>; | ||
| const OrderedMap_HeroMap* GetOrderedMap() const; | ||
|
|
||
| private: | ||
| Hero_OrderedMap ordered_map_; | ||
| OrderedMap_HeroMap ordered_map_; |
There was a problem hiding this comment.
Naming convention: <Package>_<Message>_[OrderedMap|Index|OrederedIndex]_[Levels]
Uh oh!
There was an error while loading. Please reload this page.