Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/recoilme/art
Adaptive Radix Tree done right
https://github.com/recoilme/art
art datastructures prefix-tree radixtree
Last synced: about 2 months ago
JSON representation
Adaptive Radix Tree done right
- Host: GitHub
- URL: https://github.com/recoilme/art
- Owner: recoilme
- License: mit
- Created: 2022-07-02T18:27:36.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-07-22T10:26:39.000Z (over 2 years ago)
- Last Synced: 2024-06-19T19:48:31.607Z (7 months ago)
- Topics: art, datastructures, prefix-tree, radixtree
- Language: Go
- Homepage:
- Size: 4.33 MB
- Stars: 7
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Art
Adaptive Radix Tree done right## Simple & perfomant adaptive radix tree implementation
### Description
Unlike other implementations in Go/C this version store only different parts of keys. Which leads to dramatically reducing of memory usage in case of storing keys with repeatable fragments### Advantages
- Optimized memory usage, correct implementation of compact/prefix tree
- Minimized allocations on Set/Get (GC friendly)
- Perfomant
- Store the data in sorted order### Disadvantages
- Binary comparator only### Status
WIP### Storage format
In this example:
```
tree := art.New()tree.Set([]byte("http://example.com/tag/10"), []byte("a"))
tree.Set([]byte("http://example.com/tag/20"), []byte("b"))
tree.Set([]byte("http://some.com"), []byte("c"))t.Log(tree.StringKeys(true))
```
Tree will looks like:
```
key:http:// val:
key:example.com/tag/ val:
key:10 val:a
key:20 val:b
key:some.com val:c
```
### Benchmarks (Art vs HashMap)```
$ go test -bench=. -benchmem -count=3 -timeout=1m > x.txt
$ benchstat x.txt
```
Note: in this benchmark keys are:
- ints - (in bigendian encodings, many common bytes)
- words (more realistic)```
name time/op
SetArt-8 115ns ±16%
SetHashMap-8 277ns ±10%
GetArt-8 48.5ns ± 1%
AscendArt-8 182ns ± 8%
DescendArt-8 401ns ± 3%
ScanArt-8 176ns ± 4%
GetHashMap-8 116ns ± 8%
GetWordsArt-8 155ns ± 7%
GetWordsHashMap-8 116ns ± 7%name alloc/op
SetArt-8 90.0B ± 0%
SetHashMap-8 8.00B ± 0%
GetArt-8 0.00B
AscendArt-8 0.00B
DescendArt-8 263B ± 2%
ScanArt-8 0.00B
GetHashMap-8 0.00B
GetWordsArt-8 0.00B
GetWordsHashMap-8 0.00Bname allocs/op
SetArt-8 1.00 ± 0%
SetHashMap-8 1.00 ± 0%
GetArt-8 0.00
AscendArt-8 0.00
DescendArt-8 0.00
ScanArt-8 0.00
GetHashMap-8 0.00
GetWordsArt-8 0.00
GetWordsHashMap-8 0.00
```[More benchmarks](https://github.com/recoilme/bench_sortedsets)
### Usage
see tests
### Credits
- [The Adaptive Radix Tree: ARTful Indexing for Main-Memory Databases (Specification)](https://db.in.tum.de/~leis/papers/ART.pdf)
### Author
[Kulibaba Vadim](https://github.com/recoilme)