Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache columeToIndexFieldMap #131

Merged
merged 1 commit into from
Mar 31, 2024
Merged

Conversation

zolstein
Copy link
Contributor

No description provided.

Copy link

codecov bot commented Mar 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.02%. Comparing base (041a992) to head (aaeacbd).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #131      +/-   ##
==========================================
+ Coverage   80.72%   81.02%   +0.30%     
==========================================
  Files           5        5              
  Lines         555      564       +9     
==========================================
+ Hits          448      457       +9     
  Misses         92       92              
  Partials       15       15              
Flag Coverage Δ
unittests 81.02% <100.00%> (+0.30%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

type API struct {
structTagKey string
columnSeparator string
fieldMapperFn NameMapperFunc
scannableTypesOption []interface{}
scannableTypesReflect []reflect.Type
allowUnknownColumns bool
// columnToIndexFieldMapCache stores a map of reflect.Type -> map[string][]int
columnToIndexFieldMapCache sync.Map
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went back and forth on whether this should store a sync.Map itself or a pointer to a (heap-allocated) one. IMO both ways have risk of improper use. If we store the Map directly, the user could copy the API while the map is being updated. On the other hand, if we use a pointer, the value might not get initialized. (Or we would need to initialize it lazily, which adds some complexity and synchronization overhead.) I'm happy to change to another solution if you feel strongly.

@georgysavva
Copy link
Owner

This looks great, thank you. This PR fixes #25.

@georgysavva georgysavva merged commit d706b62 into georgysavva:master Mar 31, 2024
5 checks passed
@georgysavva
Copy link
Owner

@zolstein zolstein deleted the cache-fields branch August 22, 2024 21:01
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.

2 participants