forked from ByteStorage/FlyDB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.go
53 lines (43 loc) · 1.05 KB
/
options.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
41
42
43
44
45
46
47
48
49
50
51
52
53
package flydb
import "os"
type Options struct {
DirPath string //数据库数据目录
DataFileSize int64 //数据文件的大小
SyncWrite bool // 每次写数据是否持久化
IndexType IndexerType
}
// IteratorOptions 索引迭代器配置项
type IteratorOptions struct {
// 遍历前缀为指定值的 Key,默认为空
Prefix []byte
// 是否反向遍历,默认 false 是正向
Reverse bool
}
// WriteBatchOptions 批量写入配置项
type WriteBatchOptions struct {
// 一个批次当中最大的数据量
MaxBatchNum uint
// 提交时是否 sync 持久化
SyncWrites bool
}
type IndexerType = int8
const (
// Btree 索引
Btree IndexerType = iota + 1
// ART (Adpative Radix Tree) 自适应基数树
ART
)
var DefaultOptions = Options{
DirPath: os.TempDir(),
DataFileSize: 256 * 1024 * 1024, // 256MB
SyncWrite: false,
IndexType: Btree,
}
var DefaultIteratorOptions = IteratorOptions{
Prefix: nil,
Reverse: false,
}
var DefaultWriteBatchOptions = WriteBatchOptions{
MaxBatchNum: 10000,
SyncWrites: true,
}