-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
76 lines (58 loc) · 1.45 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package bitcask_kv_go
import "os"
type Options struct {
// 数据库数据目录
DirPath string
// 数据文件的大小
DataFileSize int64
// 持久化策略:每次写数据是否持久化
SyncWrites bool
// 累计写到多少字节后进行持久化
BytesPerSync uint
// 索引类型
IndexType IndexerType
// 启动时是否使用 MMap 加载数据
MMapAtStartup bool
// 数据文件合并的阈值
DataFileMergeRatio float32
}
// 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 Adaptive Radix Tree 自适应基数树索引
ART
// BPlusTree B+ 树索引,将索引存储到磁盘上
BPlusTree
)
var DefaultOptions = Options{
DirPath: os.TempDir(),
DataFileSize: 256 * 1024 * 1024, // 256MB
SyncWrites: false,
IndexType: Btree,
BytesPerSync: 0,
MMapAtStartup: true,
DataFileMergeRatio: 0.5,
}
var DefaultIteratorOptions = IteratorOptions{
Prefix: nil,
Reverse: false,
}
var DefaultWriteBatchOptions = WriteBatchOptions{
MaxBatchNum: 10000,
SyncWrites: true,
}