-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathoptions.go
78 lines (65 loc) · 1.44 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
77
78
package CouloyDB
import (
"github.com/Kirov7/CouloyDB/meta"
"os"
)
type Options struct {
DirPath string
DataFileSize int64
IndexType meta.MemTableType
SyncWrites bool
BytesPerSync uint64
MergeInterval int64
EnableLuaInterpreter bool
SerializableLua bool
}
type IteratorOptions struct {
Prefix []byte
Reverse bool
}
type WriteBatchOptions struct {
MaxBatchNum uint32
SyncWrites bool
}
func DefaultOptions() Options {
return Options{
DirPath: os.TempDir() + "/couloy",
DataFileSize: 256 * 1024 * 1024, // 256MB
IndexType: meta.Btree,
SyncWrites: true,
}
}
func DefaultBatchOptions() WriteBatchOptions {
return WriteBatchOptions{
MaxBatchNum: 2000,
SyncWrites: true,
}
}
func (o *Options) SetDirPath(path string) *Options {
o.DirPath = path
return o
}
func (o *Options) SetIndexType(typ meta.MemTableType) *Options {
o.IndexType = typ
return o
}
func (o *Options) SetDataFileSizeByte(size int64) *Options {
o.DataFileSize = size
return o
}
func (o *Options) SetDataFileSizeKB(size int64) *Options {
o.DataFileSize = size * 1024
return o
}
func (o *Options) SetDataFileSizeMB(size int64) *Options {
o.DataFileSize = size * 1024 * 1024
return o
}
func (o *Options) SetDataFileSizeGB(size int64) *Options {
o.DataFileSize = size * 1024 * 1024 * 1024
return o
}
func (o *Options) SetSyncWrites(sync bool) *Options {
o.SyncWrites = sync
return o
}