-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.go
40 lines (34 loc) · 928 Bytes
/
index.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Indexes for key []byte -> value byte[], single key (i.e. not a
// multimap)
package indexes
type Iter interface {
// return consecutive keys and values. ok is false (key abd
// value are nil) when done.
Next() (key []byte, value []byte, ok bool)
}
// Read-only index
type ROIndex interface {
Get(key []byte) (value []byte, ok bool)
Start(keyPrefix []byte) Iter
Size() int64
Dispose()
}
// Index that can put
type Putable interface {
// put or override a key. returns true if it had to replace
// one.
Put(key []byte, value []byte) (replaced bool)
// Append bytes to the value of a key. Reduces to Put if the
// key does not exist.
Append(key []byte, value []byte)
}
// Index that can put in strict increasing order
type PutableInOrder interface {
// put or override a key. panics if key arrive out of order.
PutNext(key []byte, value []byte)
}
// General index
type Index interface {
ROIndex
Putable
}