diff options
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/cmd.go | 16 | ||||
| -rw-r--r-- | cmd/init.go | 63 |
2 files changed, 14 insertions, 65 deletions
@@ -5,7 +5,7 @@ import ( "os" "os/signal" - badger "github.com/dgraph-io/badger/v4" + "github.com/rosedblabs/rosedb/v2" "github.com/urfave/cli/v2" "github.com/justjakka/reencoder/files" @@ -17,7 +17,9 @@ func runCmd(cCtx *cli.Context) error { return err } - db, err := badger.Open(Options(ctx.Value("dbfile").(string))) + options := rosedb.DefaultOptions + options.DirPath = ctx.Value("dbfile").(string) + db, err := rosedb.Open(options) if err != nil { return err } @@ -36,18 +38,13 @@ func runCmd(cCtx *cli.Context) error { return err } - /* db.SetDiscardTs(badger.) */ - if err = files.ReencodeFlacs(ctx); err != nil { return err } - db.RunValueLogGC(0.2) - if err := db.Sync(); err != nil { return err } - return nil } @@ -71,6 +68,11 @@ func Start() { Usage: "Path to database", Aliases: []string{"d"}, }, + &cli.StringSliceFlag{ + Name: "flac", + Usage: "Flac arguments to use when reencoding, can be used multiple times", + Aliases: []string{"a"}, + }, }, Action: runCmd, } diff --git a/cmd/init.go b/cmd/init.go index 63a87e6..2852565 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -8,10 +8,7 @@ import ( "path/filepath" "runtime" "strings" - "time" - badger "github.com/dgraph-io/badger/v4" - "github.com/dgraph-io/badger/v4/options" "github.com/urfave/cli/v2" ) @@ -76,62 +73,12 @@ func initArgs(cCtx *cli.Context) (context.Context, error) { return nil, err } - return context.WithValue(ctx, "encoder", strings.ReplaceAll(strings.Split(string(encoder), " ")[1], "\n", "")), nil -} - -func Options(path string) badger.Options { - return badger.Options{ - Dir: path, - ValueDir: path, - - MemTableSize: 64 << 20, - BaseTableSize: 2 << 20, - BaseLevelSize: 10 << 20, - TableSizeMultiplier: 2, - LevelSizeMultiplier: 10, - MaxLevels: 7, - NumGoroutines: 8, - MetricsEnabled: false, - - NumCompactors: 4, // Run at least 2 compactors. Zero-th compactor prioritizes L0. - NumLevelZeroTables: 5, - NumLevelZeroTablesStall: 15, - NumMemtables: 5, - BloomFalsePositive: 0.01, - BlockSize: 4 * 1024, - SyncWrites: false, - NumVersionsToKeep: 1, - CompactL0OnClose: true, - VerifyValueChecksum: false, - Compression: options.Snappy, - BlockCacheSize: 256 << 20, - IndexCacheSize: 0, - - // The following benchmarks were done on a 4 KB block size (default block size). The - // compression is ratio supposed to increase with increasing compression level but since the - // input for compression algorithm is small (4 KB), we don't get significant benefit at - // level 3. - // NOTE: The benchmarks are with DataDog ZSTD that requires CGO. Hence, no longer valid. - // no_compression-16 10 502848865 ns/op 165.46 MB/s - - // zstd_compression/level_1-16 7 739037966 ns/op 112.58 MB/s 2.93 - // zstd_compression/level_3-16 7 756950250 ns/op 109.91 MB/s 2.72 - // zstd_compression/level_15-16 1 11135686219 ns/op 7.47 MB/s 4.38 - // Benchmark code can be found in table/builder_test.go file - ZSTDCompressionLevel: 1, - - // (2^30 - 1)*2 when mmapping < 2^31 - 1, max int32. - // -1 so 2*ValueLogFileSize won't overflow on 32-bit systems. - ValueLogFileSize: 1<<30 - 1, - - ValueLogMaxEntries: 1000000, + ctx = context.WithValue(ctx, "encoder", strings.ReplaceAll(strings.Split(string(encoder), " ")[1], "\n", "")) - VLogPercentile: 0.0, - ValueThreshold: (1 << 20), + defargs := []string{"-8f", "-j4"} - Logger: nil, - EncryptionKey: []byte{}, - EncryptionKeyRotationDuration: 10 * 24 * time.Hour, // Default 10 days. - DetectConflicts: true, - NamespaceOffset: -1, + if cCtx.Value("flac") == nil { + return context.WithValue(ctx, "flac", defargs), nil } + return context.WithValue(ctx, "flac", cCtx.StringSlice("flac")), nil } |
