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

database/gdb: enhance the underlying data transformation when querying data #3557

Open
wants to merge 37 commits into
base: master
Choose a base branch
from

Conversation

wln32
Copy link
Member

@wln32 wln32 commented May 1, 2024

本次改动只修改了Scan方法的底层的类型转换实现,会走新的逻辑,依旧是先把数据转换到map,然后在转到结构体上,

和之前的行为保持一致,不会导致不兼容。
从map到结构体的转换和之前不同的是,由于在底层转换时已经转成了具体类型,不需要调用gconv来做转换,可以直接使用循环赋值


未修改之前的

1

修改后的

3333


性能方面大幅提升,如果是直接一步赋值到结构体上,只需要600ms,但这样会导致有些api不兼容

一些建议

  1. 不建议对一整个结构体实现UnmarshalValue接口来做赋值,例如

3

  1. 和orm的转换有关的接口,应当实现Scan和Value这两个接口来做,和标准库保持一致

  2. 建议废弃掉All,One之类的方法,一点都不好用,如果查询的是单个字段,或者是一个[]int,还需要再次转换才能使用,不如直接把Scan方法加强,支持 int , []int 这种类型的参数,一步赋值到目标字段,而不是走中间变量来回重复的转换

  3. 关于HookFuncSelect 的Next方法的返回值,不应该把原始的数据结构暴漏出去让用户操作,应当封装到结构体内部,通过方法去操作


@wln32 wln32 linked an issue May 1, 2024 that may be closed by this pull request
@wln32 wln32 requested review from gqcn and hailaz and removed request for gqcn May 1, 2024 08:06
@wln32 wln32 changed the title database/gdb: Improve/gdb scan typeconvert database/gdb: enhance the underlying data transformation when querying data May 1, 2024
@wln32 wln32 marked this pull request as ready for review May 7, 2024 07:02
@wln32 wln32 added the wip label May 7, 2024
@wln32 wln32 added enhancement and removed wip labels May 9, 2024
@wln32 wln32 linked an issue May 9, 2024 that may be closed by this pull request
@gqcn
Copy link
Member

gqcn commented May 10, 2024

代码量有点多,需要花点时间review。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


The amount of code is a bit large and it will take some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants