fix: make typeOf() in generic thrift write compatible with int and int-based maps#1910
Open
eat-swap wants to merge 5 commits intocloudwego:mainfrom
Open
fix: make typeOf() in generic thrift write compatible with int and int-based maps#1910eat-swap wants to merge 5 commits intocloudwego:mainfrom
eat-swap wants to merge 5 commits intocloudwego:mainfrom
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:
|
AsterDY
reviewed
Jan 16, 2026
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 { |
Contributor
There was a problem hiding this comment.
这里val也用模板呗。然后顺便把之前写的一堆 writeInt16代码整合到这里面
Author
There was a problem hiding this comment.
问题比较大,换成模板之后在 int32 的 case 有 2%-3% 的劣化,int64 有 3%-4% 的劣化,根源是做 T 的 type assertion 的时候多一个去寄存器拿 T 的步骤
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: