-
Notifications
You must be signed in to change notification settings - Fork 894
fix: make typeOf() in generic thrift write compatible with int and int-based maps #1910
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1910 +/- ##
==========================================
- Coverage 61.37% 51.52% -9.86%
==========================================
Files 388 324 -64
Lines 35063 22663 -12400
==========================================
- Hits 21521 11677 -9844
+ Misses 12247 9670 -2577
- Partials 1295 1316 +21
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
pkg/generic/thrift/write.go
Outdated
| return fmt.Errorf("need int type, but got: %s", t.Type) | ||
| } | ||
|
|
||
| func writeInt(ctx context.Context, val interface{}, out *thrift.BufferWriter, t *descriptor.TypeDescriptor, opt *writerOption) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里val也用模板呗。然后顺便把之前写的一堆 writeInt16代码整合到这里面
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
问题比较大,换成模板之后在 int32 的 case 有 2%-3% 的劣化,int64 有 3%-4% 的劣化,根源是做 T 的 type assertion 的时候多一个去寄存器拿 T 的步骤
What type of PR is this?
fix
Check the PR title.
(Optional) Translate the PR title into Chinese.
(Optional) More detailed description for this PR(en: English/zh: Chinese).
en: In generic call of thrift protocol, the tool does not accept some basic go types such as int and int-based maps (like map[int32]interface{}). This PR make the tool accepting them.
zh(optional): 修复 thrift 泛化调用不接受诸如 int, map[int32]interface{} 这样的基础 go 类型
(Optional) Which issue(s) this PR fixes:
(optional) The PR that updates user documentation: