{"id":18628129,"url":"https://github.com/dzdx/imstrmap","last_synced_at":"2025-11-04T02:30:24.941Z","repository":{"id":85406150,"uuid":"219472022","full_name":"dzdx/imstrmap","owner":"dzdx","description":"an immutable string map that optimize memory usage","archived":false,"fork":false,"pushed_at":"2019-11-04T14:04:01.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-27T06:41:46.859Z","etag":null,"topics":["golang","immutable","memory-optimization","stringmap"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dzdx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-04T10:12:16.000Z","updated_at":"2019-11-04T14:04:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"1599309e-e867-458a-b861-1dcfb43d5d36","html_url":"https://github.com/dzdx/imstrmap","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzdx%2Fimstrmap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzdx%2Fimstrmap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzdx%2Fimstrmap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dzdx%2Fimstrmap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dzdx","download_url":"https://codeload.github.com/dzdx/imstrmap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239425336,"owners_count":19636346,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","immutable","memory-optimization","stringmap"],"created_at":"2024-11-07T04:45:34.785Z","updated_at":"2025-11-04T02:30:24.895Z","avatar_url":"https://github.com/dzdx.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ImmutableStringMap\n\n\nCompared with the string map, ImmutableStringMap memory usage is small, you can specify the keys for index accelerate Get method.\n\nMore suitable for the map that resident memory, and will not change after initialization \n\n\n## example\n\n```\nvar (\n    indexerFactory = imstrmap.NewIndexerFactory([]string{\"indexkey\"})\n)\n\nfunc run(){\n    m := imstrmap.FromMap(map[string]string{...}, indexerFactory)\n    value, ok := m.Get(\"a\")\n    m.Range(func(key string, value string){\n        fmt.Println(key, value)\n    }\n    for k, v := range m.Map(){\n        fmt.Println(k, v)\n\n    }\n}\n```\n\n## benchmark\n\ngoos: darwin\n\ngoarch: amd64\n\n\n### testdata:\n```\n{\n    \"locality\": \"vlocality\",\n    \"a\": \"a\", \n    \"b\": \"b\", \n    \"c\": \"c\", \n    \"das\": \"das\", \n    \"huhqw\": \"huhqw\", \n    \"uyoqw\": \"uyoqw\", \n    \"y9qw\": \"y9qw\", \n    \"juioq\": \"juioq\", \n    \"qqeq\": \"qqeq\", \n    \"vqrqasas\": \"vqrqasas\", \n    \"hqw\": \"hqw\", \n    \"asdqw\": \"asdqw\", \n    \"asqwqwe\": \"asqwqwe\"\n}\n```\n\n### memory\n\n| count | ImmutableStringMap | map[string]string |\n|---|---|---|\n| 10000 |  3735552 | 12820480 |\n\n### time\n\n|action | ImmutableStringMap | map[string]string |\n|---|---|---|\n| indexkey get | 77.2 ns/op | 28.5 ns/op |\n| noindexkey get | 324 ns/op | 28.5 ns/op |\n| range | 445 ns/op | 167 ns/op |\n| toMap | 1096 ns/op |  |\n\n\n### API\n\n|name | intro |\n|---|---|\n| NewIndexerFactory | specify keys to create an index factory that can accelerate Get method|\n| FromMap | create an ImmutableStringMap from a map[string]string and an indexerfactory|\n| .Get | get value by key store in this map |\n| .Range | iterate pass k, v to the func in args |\n| .Map | convert current ImmutableStringMap to a map[string]string |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdzdx%2Fimstrmap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdzdx%2Fimstrmap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdzdx%2Fimstrmap/lists"}