Skip to content

refactor: support multi-column ordered index, optimize code#139

Merged
wenchy merged 8 commits intomasterfrom
multi-ordered-index
Nov 17, 2025
Merged

refactor: support multi-column ordered index, optimize code#139
wenchy merged 8 commits intomasterfrom
multi-ordered-index

Conversation

@Kybxd
Copy link
Copy Markdown
Collaborator

@Kybxd Kybxd commented Nov 14, 2025

@Kybxd Kybxd force-pushed the multi-ordered-index branch from 5bd8097 to 810d61b Compare November 14, 2025 12:01
@Kybxd Kybxd force-pushed the multi-ordered-index branch from 68c628f to f11b8f9 Compare November 14, 2025 12:54
Comment on lines 127 to +143
@@ -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, ".", "::")
Copy link
Copy Markdown
Member

@wenchy wenchy Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Map, OrderedMap, Index, and OrderedIndex all should process the enum key in the same way.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only for ordered index currently, so rename this function to ParseOrderedIndexKeyType.

}
}
keys = append(keys, MapKey{ParseMapKeyType(fd.MapKey()), name})
keys = append(keys, newKey)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not write back to slice receiver, as it's error-prone.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -0,0 +1,306 @@
package orderedindex
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename dir to be consistent with package name:

  • ordered_index -> orderedindex
  • ordered_map -> orderedmap

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
}

func (x *Generator) Generate() bool {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generate -> NeedGenerate

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines +36 to +44
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_;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not change this. Keep compatible, and its naming is ok.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming convention: <Package>_<Message>_[OrderedMap|Index|OrederedIndex]_[Levels]

Comment thread test/cpp-tableau-loader/src/protoconf/item_conf.pc.cc
// Index types.
// Index: Title
type HeroConf_Index_AttrMap = map[string][]*protoconf.HeroConf_Hero_Attr
type Index_HeroConf_AttrMap = map[string][]*protoconf.HeroConf_Hero_Attr
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original name means in the namespace HeroConf.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines +97 to +106
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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original naming is more better and self-evident.

Comment on lines +36 to +44
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_;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming convention: <Package>_<Message>_[OrderedMap|Index|OrederedIndex]_[Levels]

@wenchy wenchy changed the title feat: support multi-column ordered index, optimize code refactor: support multi-column ordered index, optimize code Nov 17, 2025
@wenchy wenchy merged commit 9403427 into master Nov 17, 2025
@wenchy wenchy deleted the multi-ordered-index branch November 17, 2025 14:41
@wenchy wenchy mentioned this pull request Dec 11, 2025
42 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OrderedIndex: support multiple-column ordered index

2 participants