Skip to content

Commit

Permalink
Adapt RocksDB v8.11.3 (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
linxGnu authored Mar 21, 2024
1 parent 08001ea commit 36c5311
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ cd $BUILD_PATH && wget https://github.com/facebook/zstd/archive/v${zstd_version}

# Note: if you don't have a good reason, please do not set -DPORTABLE=ON
# This one is set here on purpose of compatibility with github action runtime processor
rocksdb_version="8.10.2"
rocksdb_version="8.11.3"
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 -DWITH_LIBURING=OFF \
Expand Down
3 changes: 3 additions & 0 deletions c.h
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,9 @@ rocksdb_options_set_max_bytes_for_level_multiplier_additional(
rocksdb_options_t*, int* level_values, size_t num_levels);
extern ROCKSDB_LIBRARY_API void rocksdb_options_enable_statistics(
rocksdb_options_t*);
extern ROCKSDB_LIBRARY_API void rocksdb_options_set_ttl(rocksdb_options_t*,
uint64_t);
extern ROCKSDB_LIBRARY_API uint64_t rocksdb_options_get_ttl(rocksdb_options_t*);
extern ROCKSDB_LIBRARY_API void rocksdb_options_set_periodic_compaction_seconds(
rocksdb_options_t*, uint64_t);
extern ROCKSDB_LIBRARY_API uint64_t
Expand Down
44 changes: 44 additions & 0 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -1791,6 +1791,50 @@ func (opts *Options) EnableStatistics() {
C.rocksdb_options_enable_statistics(opts.c)
}

// SetTTL sets TTL. This option has different meanings for different compaction styles:
//
// Leveled: Non-bottom-level files with all keys older than TTL will go
//
// through the compaction process. This usually happens in a cascading
// way so that those entries will be compacted to bottommost level/file.
// The feature is used to remove stale entries that have been deleted or
// updated from the file system.
//
// FIFO: Files with all keys older than TTL will be deleted. TTL is only
//
// supported if option max_open_files is set to -1.
//
// Universal: users should only set the option `periodic_compaction_seconds`
//
// below instead. For backward compatibility, this option has the same
// meaning as `periodic_compaction_seconds`. See more in comments for
// `periodic_compaction_seconds` on the interaction between these two
// options.
//
// This option only supports block based table format for any compaction
// style.
//
// unit: seconds. Ex: 1 day = 1 * 24 * 60 * 60
// 0 means disabling.
// UINT64_MAX - 1 (0xfffffffffffffffe) is special flag to allow RocksDB to
// pick default.
//
// Default: 30 days if using block based table. 0 (disable) otherwise.
//
// Dynamically changeable through SetOptions() API
// Note that dynamically changing this option only works for leveled and FIFO
// compaction. For universal compaction, dynamically changing this option has
// no effect, users should dynamically change `periodic_compaction_seconds`
// instead.
func (opts *Options) SetTTL(seconds uint64) {
C.rocksdb_options_set_ttl(opts.c, C.uint64_t(seconds))
}

// GetTTL gets TTL option.
func (opts *Options) GetTTL() uint64 {
return uint64(C.rocksdb_options_get_ttl(opts.c))
}

// SetPeriodicCompactionSeconds sets periodic_compaction_seconds option.
//
// This option has different meanings for different compaction styles:
Expand Down
4 changes: 4 additions & 0 deletions options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,10 @@ func TestOptions(t *testing.T) {
opts.SetPeriodicCompactionSeconds(123)
require.EqualValues(t, 123, opts.GetPeriodicCompactionSeconds())

require.EqualValues(t, uint64(0xfffffffffffffffe), opts.GetTTL())
opts.SetTTL(123)
require.EqualValues(t, uint64(123), opts.GetTTL())

opts.SetWriteBufferManager(wbm)

// cloning
Expand Down

0 comments on commit 36c5311

Please sign in to comment.