-
Notifications
You must be signed in to change notification settings - Fork 156
refactor(memory): convert the allocator into an interface #4539
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
Conversation
c598315 to
84f2940
Compare
onelson
left a comment
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.
The diff looks good. Questions for my own edification.
I was a little unsure about when we should be favoring GoAllocator versus ResourceAllocator or even relying on the Allocator interface. Maybe there could be a short explainer in the module-level docstring for memory.
In the diff, you change to use ResourceAllocator some of the time, but not all of the time. Some text about the rationale might help.
| // Allocator defines how memory is allocated and released within | ||
| // the flux engine. | ||
| type Allocator interface { | ||
| memory.Allocator |
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.
Go lang question: seems like this is saying "this interface should match the fields on this other struct" with this line. Is this sort of like serde's flatten attribute?
Also, I was a little confused since this is the memory package, so it seemed ambiguous as to what was going on here. My guess is memory.Allocator here is referring to arrow's memory, but it took me a beat to realize this.
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.
Yes, memory references arrow's memory package. What this is saying is "This interface needs to implement this other interface and can be used in places that are expecting that interface." It's not really like flatten but it's a builtin part of the language.
You can read about it in the language spec: https://go.dev/ref/spec#Interface_types.
|
|
84f2940 to
1e13eed
Compare
3a47f85 to
ee61ce0
Compare
This converts the allocator to an interface so we can wrap it in different locations. It expands on the arrow allocator to add a direct access to the account method of the underlying resource allocator. The original plan was to separate these two so the allocator would not have an `Account()` method. This proved to be too difficult as the `Account()` method is used in some very deep places in the code and changing all of those locations was just not practical.
ee61ce0 to
f42eba2
Compare
This follows the changes from influxdata/flux#4539.
This follows the changes from influxdata/flux#4539.
This follows the changes from influxdata/flux#4539.
This follows the changes from influxdata/flux#4539.
This converts the allocator to an interface so we can wrap it in
different locations. It expands on the arrow allocator to add a direct
access to the account method of the underlying resource allocator.
The original plan was to separate these two so the allocator would not
have an
Account()method. This proved to be too difficult as theAccount()method is used in some very deep places in the code andchanging all of those locations was just not practical.
Fixes #4472.
Done checklist