Skip to content

Commit

Permalink
Merge pull request #10 from ajiyoshi-vg/doublebyte
Browse files Browse the repository at this point in the history
Doublebyte
  • Loading branch information
ajiyoshi-vg authored Sep 30, 2024
2 parents cf91571 + 3b9f4e8 commit 75161c3
Show file tree
Hide file tree
Showing 68 changed files with 2,627 additions and 1,778 deletions.
23 changes: 19 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ show_cover: generate
open cover.html

clean:
-rm *.dat *.dict
-rm *.dat *.dict *.trie

generate:
$(MAKE) -C doublearray $@
Expand All @@ -31,14 +31,29 @@ bench.dat: jawiki-latest-all-titles.gz
tiny_data:
cat LICENSE| tr ' ' '\n' | grep -v "^$$" | sort -u | uniq > head.dat

head.dat: bench.dat Makefile
SOURCE := uuid.dat

head.dat: $(SOURCE) Makefile
tail -n 100000 $< > $@

uuid.dat:
go run cmd/gen/main.go > $@

%.trie: head.dat
go run cmd/dump/main.go -o $@ -in $< -kind $*
go run cmd/dump/main.go -o $@ -in $< -kind $* -v

bench: generate codec-data
go test -benchmem -bench BenchmarkCodec

bench: generate byte.trie rune.trie darts.trie dict.trie
all-bench: generate codec-data data
go test -benchmem -bench .

data: byte.trie rune.trie darts.trie dict.trie

codec-data: bytes-m.trie bytes-a.trie bytes-i.trie \
u16s-m.trie u16s-a.trie u16s-i.trie \
runes-m.trie runes-i.trie \
darts.trie

test_overhead: generate byte.trie
go test -bench Overhead
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ func TestByteTrie(t *testing.T) {
[]byte{math.MaxUint8, 0, math.MaxInt8},
}

trie, err := hairetsu.NewByteTrieBuilder().BuildSlice(data)
x, err := composer.NewBytes(bytes.NewIdentityDict()).ComposeFromSlice(data)
assert.NoError(t, err)
trie := x.Searcher()

for i, x := range data {
actual, err := trie.ExactMatchSearch(x)
Expand Down Expand Up @@ -97,8 +98,9 @@ func TestRuneTrie(t *testing.T) {
"日本語",
}

trie, err := hairetsu.NewRuneTrieBuilder().BuildSlice(data)
x, err := composer.NewRunes(runes.NewIdentityDict()).ComposeFromSlice(data)
assert.NoError(t, err)
trie := x.Searcher()

for i, x := range data {
actual, err := trie.ExactMatchSearch(x)
Expand Down
Loading

0 comments on commit 75161c3

Please sign in to comment.