From 475adf63fbaa2156cf37166f5c7a4b6ac5f5a1c0 Mon Sep 17 00:00:00 2001 From: CPUchain Date: Fri, 23 May 2025 05:12:28 +0000 Subject: [PATCH] Fix for windows support --- db/dboptions.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/db/dboptions.go b/db/dboptions.go index 90f4b02eb2..47f8df55fc 100644 --- a/db/dboptions.go +++ b/db/dboptions.go @@ -2,6 +2,7 @@ package db // #include "rocksdb/c.h" import "C" +import "flag" import "github.com/linxGnu/grocksdb" /* @@ -38,6 +39,10 @@ func boolToChar(b bool) C.uchar { } */ +var ( + noCompression = flag.Bool("noCompression", false, "disable rocksdb compression when rocksdb library can't find compression library linked with binary") +) + func createAndSetDBOptions(bloomBits int, c *grocksdb.Cache, maxOpenFiles int) *grocksdb.Options { blockOpts := grocksdb.NewDefaultBlockBasedTableOptions() blockOpts.SetBlockSize(32 << 10) // 32kB @@ -57,6 +62,11 @@ func createAndSetDBOptions(bloomBits int, c *grocksdb.Cache, maxOpenFiles int) * opts.SetWriteBufferSize(1 << 27) // 128MB opts.SetMaxBytesForLevelBase(1 << 27) // 128MB opts.SetMaxOpenFiles(maxOpenFiles) - opts.SetCompression(grocksdb.LZ4HCCompression) + if *noCompression { + // resolve error rocksDB: Invalid argument: Compression type LZ4HC is not linked with the binary + opts.SetCompression(grocksdb.NoCompression) + } else { + opts.SetCompression(grocksdb.LZ4HCCompression) + } return opts }