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

struct value design #77

Closed
ZENOTME opened this issue Oct 12, 2023 · 4 comments
Closed

struct value design #77

ZENOTME opened this issue Oct 12, 2023 · 4 comments

Comments

@ZENOTME
Copy link
Contributor

ZENOTME commented Oct 12, 2023

Use lookup will make the memory cost if we have multiple struct with same type.

One solve way is to use Arc<StructType> in Struct. I try this design in icelake-io/icelake#136.

Anyway I think it's ok to solve this Problem in another PR. If this desgin looks work, I'm glad to port it.

Originally posted by @ZENOTME in #20 (comment)

@ZENOTME
Copy link
Contributor Author

ZENOTME commented Oct 12, 2023

I find that our struct value didn't include type info. Do we want include type info in it?

  1. If we include info in struct, the struct value may look like
struct Struct {
   type: Arc<StructType>
   ...
}
  • The benefit of it is we can look up field info directly by struct.
  • The drawback is that extra 8 bytes pointer cost.
  1. Another solution is pass struct type as another parameter when we need it, e.g.
fn write(struct_value: Struct,struct_type: StructType)
  • The benefit of it is save memory cost.
  • The drawback is that I'm not sure whether the struct type is hard available in some case .

For now, I'm working on serialize/deserialize value. And both process seem can solve by second way. (pass a struct type as parameter)

But I'm not sure whether there is some scenario we must include info in struct value.

@ZENOTME
Copy link
Contributor Author

ZENOTME commented Oct 13, 2023

@liurenjie1024
Copy link
Contributor

Another solution is pass struct type as another parameter when we need it, e.g.

I prefer this approach. It's weird for me to store types with values, and we can always to attach type to it when necessary.

@liurenjie1024
Copy link
Contributor

Tracked in #96

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

No branches or pull requests

2 participants