Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kapitan-k committed Jun 12, 2017
1 parent 29a1149 commit b73dcdf
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 18 deletions.
4 changes: 3 additions & 1 deletion checkpoint.go
Expand Up @@ -9,6 +9,8 @@ import (
"unsafe"
)

// Checkpoint provides Checkpoint functionality.
// Checkpoints provide persistent snapshots of RocksDB databases.
type Checkpoint struct {
c *C.rocksdb_checkpoint_t
}
Expand All @@ -18,7 +20,7 @@ func NewNativeCheckpoint(c *C.rocksdb_checkpoint_t) *Checkpoint {
return &Checkpoint{c}
}

// Builds an openable snapshot of RocksDB on the same disk, which
// CreateCheckpoint builds an openable snapshot of RocksDB on the same disk, which
// accepts an output directory on the same disk, and under the directory
// (1) hard-linked SST files pointing to existing live SST files
// SST files will be copied if output directory is on a different filesystem
Expand Down
2 changes: 1 addition & 1 deletion db.go
Expand Up @@ -653,7 +653,7 @@ func (db *DB) IngestExternalFileCF(handle *ColumnFamilyHandle, filePaths []strin
return nil
}

// Creates a new Checkpoint for this db
// NewCheckpoint creates a new Checkpoint for this db.
func (db *DB) NewCheckpoint() (*Checkpoint, error) {
var (
cErr *C.char
Expand Down
1 change: 1 addition & 0 deletions options.go
Expand Up @@ -778,6 +778,7 @@ func (opts *Options) SetFIFOCompactionOptions(value *FIFOCompactionOptions) {
C.rocksdb_options_set_fifo_compaction_options(opts.c, value.c)
}

// SetRateLimiter sets the rate limiter of the options.
// Use to control write rate of flush and compaction. Flush has higher
// priority than compaction. Rate limiting is disabled if nullptr.
// If rate limiter is enabled, bytes_per_sync is set to 1MB by default.
Expand Down
19 changes: 10 additions & 9 deletions options_transaction.go
Expand Up @@ -3,6 +3,8 @@ package gorocksdb
// #include "rocksdb/c.h"
import "C"

// TransactionOptions represent all of the available options options for
// a transaction on the database.
type TransactionOptions struct {
c *C.rocksdb_transaction_options_t
}
Expand All @@ -17,43 +19,42 @@ func NewNativeTransactionOptions(c *C.rocksdb_transaction_options_t) *Transactio
return &TransactionOptions{c}
}

// Setting set_snapshot=true is the same as calling
// SetSetSnapshot to true is the same as calling
// Transaction::SetSnapshot().
func (opts *TransactionOptions) SetSetSnapshot(value bool) {
C.rocksdb_transaction_options_set_set_snapshot(opts.c, boolToChar(value))
}

// Setting to true means that before acquiring locks, this transaction will
// SetDeadlockDetect to true means that before acquiring locks, this transaction will
// check if doing so will cause a deadlock. If so, it will return with
// Status::Busy. The user should retry their transaction.
func (opts *TransactionOptions) SetDeadlockDetect(value bool) {
C.rocksdb_transaction_options_set_deadlock_detect(opts.c, boolToChar(value))
}

// If positive, specifies the wait timeout in milliseconds when
// SetLockTimeout positive, specifies the wait timeout in milliseconds when
// a transaction attempts to lock a key.
//
// If 0, no waiting is done if a lock cannot instantly be acquired.
// If negative, TransactionDBOptions::transaction_lock_timeout will be used
func (opts *TransactionOptions) SetLockTimeout(lock_timeout int64) {
C.rocksdb_transaction_options_set_lock_timeout(opts.c, C.int64_t(lock_timeout))
}

// Expiration duration in milliseconds. If non-negative, transactions that
// last longer than this many milliseconds will fail to commit. If not set,
// a forgotten transaction that is never committed, rolled back, or deleted
// SetExpiration sets the Expiration duration in milliseconds.
// If non-negative, transactions that last longer than this many milliseconds will fail to commit.
// If not set, a forgotten transaction that is never committed, rolled back, or deleted
// will never relinquish any locks it holds. This could prevent keys from
// being written by other writers.
func (opts *TransactionOptions) SetExpiration(expiration int64) {
C.rocksdb_transaction_options_set_expiration(opts.c, C.int64_t(expiration))
}

// The number of traversals to make during deadlock detection.
// SetDeadlockDetectDepth sets the number of traversals to make during deadlock detection.
func (opts *TransactionOptions) SetDeadlockDetectDepth(depth int64) {
C.rocksdb_transaction_options_set_deadlock_detect_depth(opts.c, C.int64_t(depth))
}

// The maximum number of bytes used for the write batch. 0 means no limit.
// SetMaxWriteBatchSize sets the maximum number of bytes used for the write batch. 0 means no limit.
func (opts *TransactionOptions) SetMaxWriteBatchSize(size uint64) {
C.rocksdb_transaction_options_set_max_write_batch_size(opts.c, C.size_t(size))
}
Expand Down
13 changes: 7 additions & 6 deletions options_transactiondb.go
Expand Up @@ -3,6 +3,8 @@ package gorocksdb
// #include "rocksdb/c.h"
import "C"

// TransactionDBOptions represent all of the available options when opening a transactional database
// with OpenTransactionDb.
type TransactionDBOptions struct {
c *C.rocksdb_transactiondb_options_t
}
Expand All @@ -17,7 +19,7 @@ func NewNativeTransactionDBOptions(c *C.rocksdb_transactiondb_options_t) *Transa
return &TransactionDBOptions{c}
}

// Specifies the maximum number of keys that can be locked at the same time
// SetMaxNumLocks sets the maximum number of keys that can be locked at the same time
// per column family.
// If the number of locked keys is greater than max_num_locks, transaction
// writes (or GetForUpdate) will return an error.
Expand All @@ -26,6 +28,7 @@ func (opts *TransactionDBOptions) SetMaxNumLocks(max_num_locks int64) {
C.rocksdb_transactiondb_options_set_max_num_locks(opts.c, C.int64_t(max_num_locks))
}

// SetNumStripes sets the concurrency level.
// Increasing this value will increase the concurrency by dividing the lock
// table (per column family) into more sub-tables, each with their own
// separate
Expand All @@ -34,20 +37,19 @@ func (opts *TransactionDBOptions) SetNumStripes(num_stripes uint64) {
C.rocksdb_transactiondb_options_set_num_stripes(opts.c, C.size_t(num_stripes))
}

// If positive, specifies the default wait timeout in milliseconds when
// SetTransactionLockTimeout if positive, specifies the default wait timeout in milliseconds when
// a transaction attempts to lock a key if not specified by
// TransactionOptions::lock_timeout.
//
// If 0, no waiting is done if a lock cannot instantly be acquired.
// If negative, there is no timeout. Not using a timeout is not recommended
// as it can lead to deadlocks. Currently, there is no deadlock-detection to
// recover
// from a deadlock.
// recover from a deadlock.
func (opts *TransactionDBOptions) SetTransactionLockTimeout(txn_lock_timeout int64) {
C.rocksdb_transactiondb_options_set_transaction_lock_timeout(opts.c, C.int64_t(txn_lock_timeout))
}

// If positive, specifies the wait timeout in milliseconds when writing a key
// SetDefaultLockTimeout if posititve, specifies the wait timeout in milliseconds when writing a key
// OUTSIDE of a transaction (ie by calling DB::Put(),Merge(),Delete(),Write()
// directly).
// If 0, no waiting is done if a lock cannot instantly be acquired.
Expand All @@ -59,7 +61,6 @@ func (opts *TransactionDBOptions) SetTransactionLockTimeout(txn_lock_timeout int
// cannot deadlock with other DB writes, they can deadlock with a transaction.
// A negative timeout should only be used if all transactions have a small
// expiration set.

func (opts *TransactionDBOptions) SetDefaultLockTimeout(default_lock_timeout int64) {
C.rocksdb_transactiondb_options_set_default_lock_timeout(opts.c, C.int64_t(default_lock_timeout))
}
Expand Down
2 changes: 2 additions & 0 deletions ratelimiter.go
Expand Up @@ -4,6 +4,8 @@ package gorocksdb
// #include "rocksdb/c.h"
import "C"

// RateLimiter, is used to control write rate of flush and
// compaction.
type RateLimiter struct {
c *C.rocksdb_ratelimiter_t
}
Expand Down
2 changes: 2 additions & 0 deletions transaction.go
Expand Up @@ -9,10 +9,12 @@ import (
"unsafe"
)

// Transaction is used with TransactionDB for transaction support.
type Transaction struct {
c *C.rocksdb_transaction_t
}

// NewNativeTransaction creates a Transaction object.
func NewNativeTransaction(c *C.rocksdb_transaction_t) *Transaction {
return &Transaction{c}
}
Expand Down
3 changes: 2 additions & 1 deletion transactiondb.go
Expand Up @@ -8,6 +8,7 @@ import (
"unsafe"
)

// TransactionDB is a reusable handle to a RocksDB transactional database on disk, created by OpenTransactionDb.
type TransactionDB struct {
c *C.rocksdb_transactiondb_t
name string
Expand Down Expand Up @@ -119,7 +120,7 @@ func (db *TransactionDB) Delete(opts *WriteOptions, key []byte) error {
return nil
}

// Creates a new Checkpoint for this db
// NewCheckpoint creates a new Checkpoint for this db.
func (db *TransactionDB) NewCheckpoint() (*Checkpoint, error) {
var (
cErr *C.char
Expand Down

0 comments on commit b73dcdf

Please sign in to comment.