Skip to content

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

Description

@xiaoshi100086

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions