{"id":41154450,"url":"https://github.com/ajiyoshi-vg/hairetsu","last_synced_at":"2026-01-22T19:12:48.937Z","repository":{"id":57649963,"uuid":"446309419","full_name":"ajiyoshi-vg/hairetsu","owner":"ajiyoshi-vg","description":"hairetsu is a TRIE implementation by double array.","archived":false,"fork":false,"pushed_at":"2024-03-04T11:35:12.000Z","size":320,"stargazers_count":6,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-20T06:38:26.570Z","etag":null,"topics":["double-array","go","trie"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ajiyoshi-vg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2022-01-10T06:44:06.000Z","updated_at":"2022-03-20T14:57:51.000Z","dependencies_parsed_at":"2024-06-20T05:54:54.692Z","dependency_job_id":"e91195ae-f88d-47fc-8274-cc60ac6bbb2a","html_url":"https://github.com/ajiyoshi-vg/hairetsu","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/ajiyoshi-vg/hairetsu","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajiyoshi-vg%2Fhairetsu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajiyoshi-vg%2Fhairetsu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajiyoshi-vg%2Fhairetsu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajiyoshi-vg%2Fhairetsu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ajiyoshi-vg","download_url":"https://codeload.github.com/ajiyoshi-vg/hairetsu/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajiyoshi-vg%2Fhairetsu/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28669088,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T17:07:18.858Z","status":"ssl_error","status_checked_at":"2026-01-22T17:05:02.040Z","response_time":144,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["double-array","go","trie"],"created_at":"2026-01-22T19:10:20.898Z","updated_at":"2026-01-22T19:12:48.926Z","avatar_url":"https://github.com/ajiyoshi-vg.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hairetsu\n\nhairetsu is a TRIE implementation by double array.\n\n**alpha quality** : things would change.\n\n## feature\n\n* support ExactMatchSearch CommonPrefixSearch\n* can use any binary as a label\n  * including `\\0`\n  * Some other implementations treat `\\0` as the end of string, so that they can't use keys including `\\0` as a label.\n* can customize the character code of the label\n* can use as a key value store\n  * can store 30bit uint value as a leaf\n\n## how to use\n\nbuild byte based TRIE and query\n\n```go\nfunc TestByteTrie(t *testing.T) {\n\tdata := [][]byte{\n\t\t[]byte(\"aa\"),\n\t\t[]byte(\"aaa\"),\n\t\t[]byte(\"ab\"),\n\t\t[]byte(\"abb\"),\n\t\t[]byte(\"abc\"),\n\t\t[]byte(\"abcd\"),\n\t\t[]byte(\"b\"),\n\t\t[]byte(\"ba\"),\n\t\t[]byte(\"bb\"),\n\t\t[]byte(\"c\"),\n\t\t[]byte(\"cd\"),\n\t\t[]byte(\"cddd\"),\n\t\t[]byte(\"ccd\"),\n\t\t[]byte(\"ddd\"),\n\t\t[]byte(\"eab\"),\n\t\t[]byte(\"日本語\"),\n\t\t[]byte{math.MaxUint8, 0, math.MaxInt8},\n\t}\n\n\tx, err := composer.NewBytes(bytes.NewIdentityDict()).ComposeFromSlice(data)\n\tassert.NoError(t, err)\n\ttrie := x.Searcher()\n\n\tfor i, x := range data {\n\t\tactual, err := trie.ExactMatchSearch(x)\n\t\tassert.NoError(t, err, x)\n\t\tassert.Equal(t, node.Index(i), actual)\n\t}\n\n\tng := [][]byte{\n\t\t[]byte(\"a\"),\n\t\t[]byte(\"aac\"),\n\t}\n\n\tfor _, x := range ng {\n\t\t_, err := trie.ExactMatchSearch(x)\n\t\tassert.Error(t, err, x)\n\t}\n\n\ttarget := []byte(\"abcedfg\")\n\tis, err := trie.CommonPrefixSearch(target)\n\tassert.NoError(t, err)\n\n\tn := 0\n\tfor _, x := range data {\n\t\tif bytes.HasPrefix(target, x) {\n\t\t\tn++\n\t\t}\n\t}\n\n\tassert.Equal(t, n, len(is))\n}\n```\n\nbuild rune based trie and query\n\n```go\nfunc TestRuneTrie(t *testing.T) {\n\tdata := []string{\n\t\t\"aa\",\n\t\t\"aaa\",\n\t\t\"ab\",\n\t\t\"abb\",\n\t\t\"abc\",\n\t\t\"abcd\",\n\t\t\"b\",\n\t\t\"ba\",\n\t\t\"bb\",\n\t\t\"c\",\n\t\t\"cd\",\n\t\t\"cddd\",\n\t\t\"ccd\",\n\t\t\"ddd\",\n\t\t\"eab\",\n\t\t\"日本語\",\n\t}\n\n\tx, err := composer.NewRunes(runes.NewIdentityDict()).ComposeFromSlice(data)\n\tassert.NoError(t, err)\n\ttrie := x.Searcher()\n\n\tfor i, x := range data {\n\t\tactual, err := trie.ExactMatchSearch(x)\n\t\tassert.NoError(t, err, x)\n\t\tassert.Equal(t, node.Index(i), actual)\n\t}\n\n\tng := []string{\n\t\t\"a\",\n\t\t\"aac\",\n\t}\n\n\tfor _, x := range ng {\n\t\t_, err := trie.ExactMatchSearch(x)\n\t\tassert.Error(t, err, x)\n\t}\n\n\ttarget := \"abcedfg\"\n\tis, err := trie.CommonPrefixSearch(target)\n\tassert.NoError(t, err)\n\n\tn := 0\n\tfor _, x := range data {\n\t\tif strings.HasPrefix(target, x) {\n\t\t\tn++\n\t\t}\n\t}\n\n\tassert.Equal(t, n, len(is))\n}\n```\n\n## test\n\n```bash\n$ make test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajiyoshi-vg%2Fhairetsu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fajiyoshi-vg%2Fhairetsu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajiyoshi-vg%2Fhairetsu/lists"}