forked from tecbot/gorocksdb
-
Notifications
You must be signed in to change notification settings - Fork 2
/
options_read.go
89 lines (76 loc) · 3.14 KB
/
options_read.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
77
78
79
80
81
82
83
84
85
86
87
88
89
package rdb
// #include "rocksdb/c.h"
import "C"
import "unsafe"
// ReadTier controls fetching of data during a read request.
// An application can issue a read request (via Get/Iterators) and specify
// if that read should process data that ALREADY resides on a specified cache
// level. For example, if an application specifies BlockCacheTier then the
// Get call will process data that is already processed in the memtable or
// the block cache. It will not page in data from the OS cache or data that
// resides in storage.
type ReadTier uint
const (
// ReadAllTier reads data in memtable, block cache, OS cache or storage.
ReadAllTier = ReadTier(0)
// BlockCacheTier reads data in memtable or block cache.
BlockCacheTier = ReadTier(1)
)
// ReadOptions represent all of the available options when reading from a
// database.
type ReadOptions struct {
c *C.rocksdb_readoptions_t
}
// NewDefaultReadOptions creates a default ReadOptions object.
func NewDefaultReadOptions() *ReadOptions {
return NewNativeReadOptions(C.rocksdb_readoptions_create())
}
// NewNativeReadOptions creates a ReadOptions object.
func NewNativeReadOptions(c *C.rocksdb_readoptions_t) *ReadOptions {
return &ReadOptions{c}
}
// UnsafeGetReadOptions returns the underlying c read options object.
func (opts *ReadOptions) UnsafeGetReadOptions() unsafe.Pointer {
return unsafe.Pointer(opts.c)
}
// SetVerifyChecksums speciy if all data read from underlying storage will be
// verified against corresponding checksums.
// Default: false
func (opts *ReadOptions) SetVerifyChecksums(value bool) {
C.rocksdb_readoptions_set_verify_checksums(opts.c, boolToChar(value))
}
// SetFillCache specify whether the "data block"/"index block"/"filter block"
// read for this iteration should be cached in memory?
// Callers may wish to set this field to false for bulk scans.
// Default: true
func (opts *ReadOptions) SetFillCache(value bool) {
C.rocksdb_readoptions_set_fill_cache(opts.c, boolToChar(value))
}
// SetSnapshot sets the snapshot which should be used for the read.
// The snapshot must belong to the DB that is being read and must
// not have been released.
// Default: nil
func (opts *ReadOptions) SetSnapshot(snap *Snapshot) {
C.rocksdb_readoptions_set_snapshot(opts.c, snap.c)
}
// SetReadTier specify if this read request should process data that ALREADY
// resides on a particular cache. If the required data is not
// found at the specified cache, then Status::Incomplete is returned.
// Default: ReadAllTier
func (opts *ReadOptions) SetReadTier(value ReadTier) {
C.rocksdb_readoptions_set_read_tier(opts.c, C.int(value))
}
// SetTailing specify if to create a tailing iterator.
// A special iterator that has a view of the complete database
// (i.e. it can also be used to read newly added data) and
// is optimized for sequential reads. It will return records
// that were inserted into the database after the creation of the iterator.
// Default: false
func (opts *ReadOptions) SetTailing(value bool) {
C.rocksdb_readoptions_set_tailing(opts.c, boolToChar(value))
}
// Destroy deallocates the ReadOptions object.
func (opts *ReadOptions) Destroy() {
C.rocksdb_readoptions_destroy(opts.c)
opts.c = nil
}