Skip to content

Commit

Permalink
Readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zejun Li committed Dec 24, 2017
1 parent bf4f258 commit 96067dc
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ language: go

go:
- 1.9.x

before_install:
- go get github.com/mattn/goveralls

script:
- $GOPATH/bin/goveralls -service=travis-ci
57 changes: 56 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,56 @@
# Optimistic Adaptive Radix Tree
# Optimistic Adaptive Radix Tree

[![Go Report Card](https://goreportcard.com/badge/github.com/bobotu/opt-art)](https://goreportcard.com/report/github.com/bobotu/opt-art)
[![Build Status](https://travis-ci.org/bobotu/opt-art.svg?branch=master)](https://travis-ci.org/bobotu/opt-art)
[![Coverage Status](https://coveralls.io/repos/github/bobotu/opt-art/badge.svg?branch=master)](https://coveralls.io/github/bobotu/opt-art?branch=master)

This is a Go implementation of ART.

## What is ART
As mentioned in the origin paper, ART is a powerful indexing data structure.

> Its lookup performance surpasses highly tuned, read-only search trees, while supporting very efficient insertions and
deletions as well. At the same time, ART is very space efficient and solves the problem of excessive worst-case space
consumption, which plagues most radix trees, by adaptively choosing compact and efficient data structures for internal
nodes. Even though ART’s performance is comparable to hash tables, it maintains the data in sorted order, which
enables additional operations like range scan and prefix lookup.

## Concurrent Operation
The main difference compared to other implementations (like [plar/go-adaptive-radix-tree](https://github.com/plar/go-adaptive-radix-tree))
is that this implementation support concurrent Read/Write operation.

Using the method described in `V. Leis, et al., The ART of Practical Synchronization, in DaMoN, 2016`.

## Usage

```go
package main

import (
"fmt"
"github.com/bobotu/opt-art"
)

func main() {
art := art.NewART()
art.Put([]byte("hello"), "world")
fmt.Println(art.Get([]byte("hello")))
art.Delete([]byte("hello"))
}
```

You can check out [godoc.org](https://godoc.org/github.com/bobotu/opt-art) for more detailed documentation.

## Performance
Although this is only a rough implementation, there are still some good results on the benchmarks.
Benchmarks performed on the same datasets as [plar/go-adaptive-radix-tree](https://github.com/plar/go-adaptive-radix-tree)

> * Words dataset contains list of 235,886 english words.
> * UUIDs dataset contains 100,000 uuids.
**opt-art**|**#**|**Average time**|**Bytes per operation**|**Allocs per operation**
:-----:|:-----:|:-----:|:-----:|:-----:
BenchmarkPutWords-8|20|69056403 ns/op|43403024 B/op|943544 allocs/op
BenchmarkPutUUID-8|50|27332784 ns/op|18400000 B/op|400000 allocs/op
BenchmarkGetWords-8|20|88016532 ns/op|0 B/op|0 allocs/op
BenchmarkGetUUID-8|100|22887744 ns/op|0 B/op|0 allocs/op
2 changes: 1 addition & 1 deletion art_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,12 @@ func loadTestData(file string, b *testing.B) (data [][]byte) {

func benchPut(file string, b *testing.B) {
b.Helper()
art := NewART()
data := loadTestData(file, b)
b.ResetTimer()

for i := 0; i < b.N; i++ {
for _, d := range data {
art := NewART()
art.Put(d, d)
}
}
Expand Down

0 comments on commit 96067dc

Please sign in to comment.