Skip to content

Commit

Permalink
Adapt rocksdb 6.26.1 (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
linxGnu committed Dec 21, 2021
1 parent 37398ca commit d222cc4
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
uses: actions/cache@v2
with:
path: dist
key: v6.25.3
key: v6.26.1

- name: Build
if: steps.cache-built-rocksdb.outputs.cache-hit != 'true'
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ cd $BUILD_PATH && wget https://github.com/facebook/zstd/archive/v${zstd_version}
-DCMAKE_POSITION_INDEPENDENT_CODE=ON -DZSTD_ZLIB_SUPPORT=ON -DZSTD_LZMA_SUPPORT=OFF -DCMAKE_BUILD_TYPE=Release .. && make -j$(nproc) install && \
cd $BUILD_PATH && rm -rf * && ldconfig

rocksdb_version="6.25.3"
rocksdb_version="6.26.1"
cd $BUILD_PATH && wget https://github.com/facebook/rocksdb/archive/v${rocksdb_version}.tar.gz && tar xzf v${rocksdb_version}.tar.gz && cd rocksdb-${rocksdb_version}/ && \
mkdir -p build_place && cd build_place && cmake -DCMAKE_BUILD_TYPE=Release $CMAKE_REQUIRED_PARAMS -DCMAKE_PREFIX_PATH=$INSTALL_PREFIX -DWITH_TESTS=OFF -DWITH_GFLAGS=OFF \
-DWITH_BENCHMARK_TOOLS=OFF -DWITH_TOOLS=OFF -DWITH_MD_LIBRARY=OFF -DWITH_RUNTIME_DEBUG=OFF -DROCKSDB_BUILD_SHARED=OFF -DWITH_SNAPPY=ON -DWITH_LZ4=ON -DWITH_ZLIB=ON \
Expand Down
5 changes: 5 additions & 0 deletions c.h
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,11 @@ extern ROCKSDB_LIBRARY_API void rocksdb_options_set_blob_gc_age_cutoff(
extern ROCKSDB_LIBRARY_API double rocksdb_options_get_blob_gc_age_cutoff(
rocksdb_options_t* opt);

extern ROCKSDB_LIBRARY_API void rocksdb_options_set_blob_gc_force_threshold(
rocksdb_options_t* opt, double val);
extern ROCKSDB_LIBRARY_API double rocksdb_options_get_blob_gc_force_threshold(
rocksdb_options_t* opt);

/* returns a pointer to a malloc()-ed, null terminated string */
extern ROCKSDB_LIBRARY_API char* rocksdb_options_statistics_get_string(
rocksdb_options_t* opt);
Expand Down
2 changes: 1 addition & 1 deletion compaction_filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestCompactionFilter(t *testing.T) {
)
db := newTestDB(t, "TestCompactionFilter", func(opts *Options) {
opts.SetCompactionFilter(&mockCompactionFilter{
filter: func(level int, key, val []byte) (remove bool, newVal []byte) {
filter: func(_ int, key, val []byte) (remove bool, newVal []byte) {
if bytes.Equal(key, changeKey) {
return false, changeValNew
}
Expand Down
14 changes: 7 additions & 7 deletions db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ func TestDBCRUD(t *testing.T) {

// retrieve pinned
for i := 0; i < 1000; i++ {
v3, err := db.GetPinned(ro, givenKey)
require.Nil(t, err)
v3, e := db.GetPinned(ro, givenKey)
require.Nil(t, e)
require.EqualValues(t, v3.Data(), givenVal2)
v3.Destroy()
v3.Destroy()

v3NE, err := db.GetPinned(ro, []byte("justFake"))
require.Nil(t, err)
v3NE, e := db.GetPinned(ro, []byte("justFake"))
require.Nil(t, e)
require.False(t, v3NE.Exists())
v3NE.Destroy()
v3NE.Destroy()
Expand Down Expand Up @@ -203,9 +203,9 @@ func newTestDBPathNames(t *testing.T, name string, names []string, targetSizes [

paths := make([]string, len(names))
for i, name := range names {
dir, err := ioutil.TempDir("", "gorocksdb-"+name)
require.Nil(t, err)
paths[i] = dir
directory, e := ioutil.TempDir("", "gorocksdb-"+name)
require.Nil(t, e)
paths[i] = directory
}

dbpaths := NewDBPathsFromData(paths, targetSizes)
Expand Down
39 changes: 0 additions & 39 deletions docker/Dockerfile

This file was deleted.

21 changes: 21 additions & 0 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -2034,6 +2034,27 @@ func (opts *Options) GetBlobGCAgeCutoff() float64 {
return float64(C.rocksdb_options_get_blob_gc_age_cutoff(opts.c))
}

// SetBlobGCForceThreshold if the ratio of garbage in the oldest blob files exceeds this threshold,
// targeted compactions are scheduled in order to force garbage collecting
// the blob files in question, assuming they are all eligible based on the
// value of blob_garbage_collection_age_cutoff above. This option is
// currently only supported with leveled compactions.
// Note that enable_blob_garbage_collection has to be set in order for this
// option to have any effect.
//
// Default: 1.0
func (opts *Options) SetBlobGCForceThreshold(val float64) {
C.rocksdb_options_set_blob_gc_force_threshold(opts.c, C.double(val))
}

// GetBlobGCForceThreshold get the threshold for ratio of garbage in the oldest blob files.
// See also: `SetBlobGCForceThreshold`
//
// Default: 1.0
func (opts *Options) GetBlobGCForceThreshold() float64 {
return float64(C.rocksdb_options_get_blob_gc_force_threshold(opts.c))
}

// SetMaxWriteBufferNumberToMaintain sets total maximum number of write buffers
// to maintain in memory including copies of buffers that have already been flushed.
// Unlike max_write_buffer_number, this parameter does not affect flushing.
Expand Down
4 changes: 4 additions & 0 deletions options_blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ func TestOptionBlobFile(t *testing.T) {
require.EqualValues(t, 0.25, opt.GetBlobGCAgeCutoff())
opt.SetBlobGCAgeCutoff(0.3)
require.EqualValues(t, 0.3, opt.GetBlobGCAgeCutoff())

require.EqualValues(t, 1.0, opt.GetBlobGCForceThreshold())
opt.SetBlobGCForceThreshold(1.3)
require.EqualValues(t, 1.3, opt.GetBlobGCForceThreshold())
}
4 changes: 2 additions & 2 deletions options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,14 +376,14 @@ func TestOptions(t *testing.T) {
}

func TestOptions2(t *testing.T) {
t.Run("SetUniversalCompactionOpts", func(t *testing.T) {
t.Run("SetUniversalCompactionOpts", func(*testing.T) {
opts := NewDefaultOptions()
defer opts.Destroy()

opts.SetUniversalCompactionOptions(NewDefaultUniversalCompactionOptions())
})

t.Run("SetFifoCompactionOpts", func(t *testing.T) {
t.Run("SetFifoCompactionOpts", func(*testing.T) {
opts := NewDefaultOptions()
defer opts.Destroy()

Expand Down
2 changes: 1 addition & 1 deletion transactiondb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func TestTransactionDBCRUD(t *testing.T) {

func TestTransactionDBGetForUpdate(t *testing.T) {
lockTimeoutMilliSec := int64(50)
applyOpts := func(opts *Options, transactionDBOpts *TransactionDBOptions) {
applyOpts := func(_ *Options, transactionDBOpts *TransactionDBOptions) {
transactionDBOpts.SetTransactionLockTimeout(lockTimeoutMilliSec)
}
db := newTestTransactionDB(t, "TestOpenTransactionDb", applyOpts)
Expand Down

0 comments on commit d222cc4

Please sign in to comment.