Skip to content

Commit

Permalink
Add atomic flushes to rocksdb bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
aalda committed Mar 28, 2019
1 parent 968442b commit f682fee
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
5 changes: 5 additions & 0 deletions rocksdb/extended.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ struct rocksdb_statistics_t { std::shared_ptr<Statistics> rep; };
struct rocksdb_histogram_data_t { rocksdb::HistogramData* rep; };
struct rocksdb_options_t { Options rep; };

void rocksdb_options_set_atomic_flush(
rocksdb_options_t* opts, unsigned char value) {
opts->rep.atomic_flush = value;
}

rocksdb_statistics_t* rocksdb_create_statistics() {
rocksdb_statistics_t* result = new rocksdb_statistics_t;
result->rep = rocksdb::CreateDBStatistics();
Expand Down
5 changes: 4 additions & 1 deletion rocksdb/extended.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ extern rocksdb_statistics_t* rocksdb_create_statistics();

/* Options */

extern void rocksdb_options_set_atomic_flush(
rocksdb_options_t*, unsigned char);

extern void rocksdb_options_set_statistics(
rocksdb_options_t* opt,
rocksdb_options_t* opts,
rocksdb_statistics_t* stats);

/* Statistics */
Expand Down
21 changes: 19 additions & 2 deletions rocksdb/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,18 +358,35 @@ func (o *Options) SetKeepLogFileNum(value int) {
C.rocksdb_options_set_keep_log_file_num(o.c, C.size_t(value))
}

// SetAllowMmapReads enable/disable mmap reads for reading sst tables.
// SetAllowMmapReads enables/disables mmap reads for reading sst tables.
// Default: false
func (o *Options) SetAllowMmapReads(value bool) {
C.rocksdb_options_set_allow_mmap_reads(o.c, boolToUchar(value))
}

// SetAllowMmapWrites enable/disable mmap writes for writing sst tables.
// SetAllowMmapWrites enables/disables mmap writes for writing sst tables.
// Default: false
func (o *Options) SetAllowMmapWrites(value bool) {
C.rocksdb_options_set_allow_mmap_writes(o.c, boolToUchar(value))
}

// SetAtomicFlush enables/disables atomic flushes.
// If true, RocksDB supports flushing multiple column families and committing
// their results atomically to MANIFEST. Note that it is not
// necessary to set atomic_flush to true if WAL is always enabled since WAL
// allows the database to be restored to the last persistent state in WAL.
// This option is useful when there are column families with writes NOT
// protected by WAL.
// For manual flush, application has to specify which column families to
// flush atomically in db.Flush.
// For auto-triggered flush, RocksDB atomically flushes ALL column families.
//
// Currently, any WAL-enabled writes after atomic flush may be replayed
// independently if the process crashes later and tries to recover.
func (o *Options) SetAtomicFlush(value bool) {
C.rocksdb_options_set_atomic_flush(o.c, boolToUchar(value))
}

// SetStatistics sets a statistics object to pass to the DB.
func (o *Options) SetStatistics(s *Statistics) {
C.rocksdb_options_set_statistics(o.c, s.c)
Expand Down

0 comments on commit f682fee

Please sign in to comment.