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

why entry use array instead of golang map for storage #113

Open
xiaoshi100086 opened this issue Jul 31, 2022 · 2 comments
Open

why entry use array instead of golang map for storage #113

xiaoshi100086 opened this issue Jul 31, 2022 · 2 comments

Comments

@xiaoshi100086
Copy link

I find entry use array for storage in struct segment.
This approach requires the implementation of get, set interfaces and expansion logic.

type segment struct {
        // ...
	slotLens      [256]int32 // The actual length for every slot.
	slotCap       int32      // max number of entry pointers a slot can hold.
	slotsData     []entryPtr // shared by all 256 slots
}

Why not use golang map?

  1. golang map has achieved hash and expansion logic
  2. if map value is data address offset instead of data pointer, the GC will omit its content.
@coocood
Copy link
Owner

coocood commented Aug 1, 2022

When this project was created, the Go GC didn't omit map value.

@lovegnep
Copy link

map can not solve the problem of hash collisions

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

3 participants