-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
56 lines (50 loc) · 1.45 KB
/
config.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
package bitcask
import "os"
type DBConfig struct {
// 数据库数据目录
DirPath string
// 数据文件大小
DataFileSize int64
// 每次写入数据后是否持久化
// TODO 改成 有xx概率进行持久化?
SyncWrite bool
//索引类型
IndexType IndexerType
}
type IndexerType = int8
const (
// Btree 索引
Btree IndexerType = iota + 1
// ART 自适应基数树索引
ART
BPTree //B+树索引,将索引存储到磁盘上
)
// IteratorConfig 索引迭代器配置项
type IteratorConfig struct {
// 遍历前缀为指定值的 Key,默认为空
Prefix []byte
// 是否反向遍历,默认 false 是正向
Reverse bool
}
// WriteBatchConfig represents the configuration for a write batch.
type WriteBatchConfig struct {
// MaxBatchNum is the maximum number of data in a batch.
MaxBatchNum uint
// SyncWrites determines whether to persist the transaction when committing.
SyncWrites bool
}
// DefaultConfig is the default configuration for the DB.
var DefaultConfig = DBConfig{
DirPath: os.TempDir(), // Set the directory path to the temporary directory.
DataFileSize: 512 * 1024 * 1024, // Set the data file size to 512 MB.
SyncWrite: false, // Disable synchronous write.
IndexType: BPTree, // Use Btree/ART/BPTree index type.
}
var DefaultIteratorConfig = IteratorConfig{
Prefix: nil,
Reverse: false,
}
var DefaultWriteBatchConfig = WriteBatchConfig{
MaxBatchNum: 10000,
SyncWrites: true,
}