-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkfs.go
54 lines (45 loc) · 1.22 KB
/
kfs.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
package kfs
import ldb "github.com/syndtr/goleveldb/leveldb/opt"
import "github.com/luckcolors/gokfs/opt"
import "github.com/luckcolors/gokfs/btable"
import "github.com/luckcolors/gokfs/constants"
import "github.com/luckcolors/gokfs/sbucket"
import "github.com/luckcolors/gokfs/blockstream"
import "github.com/luckcolors/gokfs/utils"
type Kfs struct {
Opt *opt.Options
BTable btable.BTable
sBuckets []sbucket.SBucket
}
func Open(dbPath string, ldbOpt *ldb.Options, kfsOpt *opt.Options) *Kfs, error {
if ldbOpt == nil {
ldbOpt = &ldb.Options{
OpenFilesCacheCapacity: 1000,
Compression: ldb.NoCompression,
BlockCacheCapacity: 8 * ldb.MiB,
WriteBuffer: 4 * ldb.MiB,
ErrorIfMissing: false,
ErrorIfExist: false,
BlockSize: 4096,
BlockRestartInterval: 16,
}
}
if kfsOpt == nil {
rid, err := utils.CreateReferenceId(nil)
if err != nil {
panic(err)
}
kfsOpt = &opt.Options{
Rid: rid,
MaxTableSize: constants.S * constants.B,
SBucketOpt: sbucket.Options{
MaxSize: constants.S,
ChunkSize: constants.C,
},
BlockStreamOpt: blockstream.Options{
ChunkSize: constants.C,
PadLastChunk: false,
},
}
}
}