Skip to content

Commit 234451a

Browse files
author
Alex Gaetano Padula
committed
update read me
1 parent 20cb321 commit 234451a

File tree

1 file changed

+67
-12
lines changed

1 file changed

+67
-12
lines changed

README.md

+67-12
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# GO BTree
2-
A fast, simple persistent BTree implementation in Go.
2+
A fast, simple disk based BTree implementation in Go.
33

44
https://pkg.go.dev/github.com/guycipher/btree
55

66
## Features
77
- Easy to use API with `Put`, `Get`, `Delete`, `Remove`, `Iterator`, `Range` methods
8-
- Disk based storage
8+
- Disk based storage with underlying pager
99
- Supports keys with multiple values
1010
- Supports large keys and values
1111

@@ -31,7 +31,7 @@ import "github.com/guycipher/btree"
3131

3232
You can use the ``Open`` method to open an existing btree or create a new one.
3333
You can specify the file, permission and T(degree)
34-
```
34+
```go
3535
// name of the file, flags, file mode, T(degree)
3636
bt, err := btree.Open("btree.db", os.O_CREATE|os.O_RDWR, 0644, 3)
3737
if err != nil {
@@ -42,7 +42,7 @@ if err != nil {
4242
### Inserting a key-value pair
4343

4444
You can insert a value into a key using the ``Put`` method. Keys can store many values.
45-
```
45+
```go
4646
err := bt.Put([]byte("key"), []byte("value"))
4747
if err != nil {
4848
..
@@ -52,17 +52,62 @@ if err != nil {
5252
### Getting a value
5353

5454
To get a value you can you the ``Get`` method. The get method will return all the keys values.
55-
```
55+
```go
5656
values, err := bt.Get([]byte("key"))
5757
if err != nil {
5858
..
5959
}
6060
```
6161

62+
#### NGet
63+
To get all keys not equal to the key you can use the ``NGet`` method.
64+
```go
65+
keys, err := bt.NGet([]byte("key"))
66+
if err != nil {
67+
..
68+
}
69+
```
70+
71+
### GreaterThan
72+
To get all keys greater than the key you can use the ``GreaterThan`` method.
73+
```go
74+
keys, err := bt.GreaterThan([]byte("key"))
75+
if err != nil {
76+
..
77+
}
78+
```
79+
80+
### GreaterThanEq
81+
To get all keys greater than or equal to the key you can use the ``GreaterThanEq`` method.
82+
```go
83+
keys, err := bt.GreaterThanEq([]byte("key"))
84+
if err != nil {
85+
..
86+
}
87+
```
88+
89+
### LessThan
90+
To get all keys less than the key you can use the ``LessThan`` method.
91+
```go
92+
keys, err := bt.LessThan([]byte("key"))
93+
if err != nil {
94+
..
95+
}
96+
```
97+
98+
### LessThanEq
99+
To get all keys less than or equal to the key you can use the ``LessThanEq`` method.
100+
```go
101+
keys, err := bt.LessThanEq([]byte("key"))
102+
if err != nil {
103+
..
104+
}
105+
```
106+
62107
### Deleting a key
63108

64109
To delete a key and all of it's values you can use the ``Delete`` method.
65-
```
110+
```go
66111
err := bt.Delete([]byte("key"))
67112
if err != nil {
68113
..
@@ -72,18 +117,18 @@ if err != nil {
72117
### Removing a value within key
73118

74119
To remove a value from a key you can use the ``Remove`` method.
75-
```
120+
```go
76121
err := bt.Remove([]byte("key"), []byte("value"))
77122
if err != nil {
78123
..
79124
}
80125
```
81126

82-
### Iterator
127+
### Key Iterator
83128

84129
The iterator is used to iterate over values of a key
85130

86-
```
131+
```go
87132
iterator := key.Iterator()
88133

89134
for {
@@ -104,18 +149,28 @@ value3
104149
```
105150

106151
### Range query
107-
```
152+
Get all keys between key1 and key3
153+
```go
108154
keys, err := bt.Range([]byte("key1"), []byte("key3"))
109155
if err != nil {
110156
..
111157
}
112158
```
113159

160+
### Not Range query
161+
Get all keys not between key1 and key3
162+
```go
163+
keys, err := bt.NRange([]byte("key1"), []byte("key3"))
164+
if err != nil {
165+
..
166+
}
167+
```
168+
114169
### Closing the BTree
115170

116171
You can close the BTree by calling the Close function.
117-
118-
```
172+
This will close the underlying file and free up resources.
173+
```go
119174
err := bt.Close()
120175
if err != nil {
121176
..

0 commit comments

Comments
 (0)