-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathoptions_wait_for_compact.go
76 lines (64 loc) · 2.66 KB
/
options_wait_for_compact.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package grocksdb
// #include "rocksdb/c.h"
import "C"
type WaitForCompactOptions struct {
p *C.rocksdb_wait_for_compact_options_t
}
func NewWaitForCompactOptions() *WaitForCompactOptions {
return &WaitForCompactOptions{
p: C.rocksdb_wait_for_compact_options_create(),
}
}
// Destroy the object.
func (w *WaitForCompactOptions) Destroy() {
C.rocksdb_wait_for_compact_options_destroy(w.p)
w.p = nil
}
// SetAbortOnPause toggles the abort_on_pause flag, to abort waiting in case of
// a pause (PauseBackgroundWork() called).
//
// - If true, Status::Aborted will be returned immediately.
// - If false, ContinueBackgroundWork() must be called to resume the background jobs.
//
// Otherwise, jobs that were queued, but not scheduled yet may never finish
// and WaitForCompact() may wait indefinitely (if timeout is set, it will
// expire and return Status::TimedOut).
func (w *WaitForCompactOptions) SetAbortOnPause(v bool) {
C.rocksdb_wait_for_compact_options_set_abort_on_pause(w.p, boolToChar(v))
}
// IsAbortOnPause checks if abort_on_pause flag is on.
func (w *WaitForCompactOptions) AbortOnPause() bool {
return charToBool(C.rocksdb_wait_for_compact_options_get_abort_on_pause(w.p))
}
// SetFlush toggles the "flush" flag to flush all column families before starting to wait.
func (w *WaitForCompactOptions) SetFlush(v bool) {
C.rocksdb_wait_for_compact_options_set_flush(w.p, boolToChar(v))
}
// IsFlush checks if "flush" flag is on.
func (w *WaitForCompactOptions) Flush() bool {
return charToBool(C.rocksdb_wait_for_compact_options_get_flush(w.p))
}
// SetCloseDB toggles the "close_db" flag to call Close() after waiting is done.
// By the time Close() is called here, there should be no background jobs in progress
// and no new background jobs should be added.
//
// DB may not have been closed if Close() returned Aborted status due to unreleased snapshots
// in the system.
func (w *WaitForCompactOptions) SetCloseDB(v bool) {
C.rocksdb_wait_for_compact_options_set_close_db(w.p, boolToChar(v))
}
// CloseDB checks if "close_db" flag is on.
func (w *WaitForCompactOptions) CloseDB() bool {
return charToBool(C.rocksdb_wait_for_compact_options_get_close_db(w.p))
}
// SetTimeout in microseconds for waiting for compaction to complete.
// Status::TimedOut will be returned if timeout expires.
// when timeout == 0, WaitForCompact() will wait as long as there's background
// work to finish.
func (w *WaitForCompactOptions) SetTimeout(microseconds uint64) {
C.rocksdb_wait_for_compact_options_set_timeout(w.p, C.uint64_t(microseconds))
}
// GetTimeout in microseconds.
func (w *WaitForCompactOptions) GetTimeout() uint64 {
return uint64(C.rocksdb_wait_for_compact_options_get_timeout(w.p))
}