Class: SlateDb::Reader
- Inherits:
-
Object
- Object
- SlateDb::Reader
- Defined in:
- lib/slatedb/reader.rb
Class Method Summary collapse
-
.open(path, url: nil, checkpoint_id: nil, manifest_poll_interval: nil, checkpoint_lifetime: nil, max_memtable_bytes: nil, cache_root: nil, max_open_file_handles: nil, merge_operator: nil) {|reader| ... } ⇒ Reader
Open a read-only reader at the given path.
Instance Method Summary collapse
-
#get(key, durability_filter: nil, dirty: nil, cache_blocks: nil) ⇒ String?
Get a value by key.
-
#scan(start_key, end_key = nil, durability_filter: nil, dirty: nil, read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil) ⇒ Iterator
Scan a range of keys.
-
#scan_prefix(prefix, durability_filter: nil, dirty: nil, read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil) ⇒ Iterator
Scan all keys with a given prefix.
Class Method Details
.open(path, url: nil, checkpoint_id: nil, manifest_poll_interval: nil, checkpoint_lifetime: nil, max_memtable_bytes: nil, cache_root: nil, max_open_file_handles: nil, merge_operator: nil) {|reader| ... } ⇒ Reader
Open a read-only reader at the given path.
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 |
# File 'lib/slatedb/reader.rb', line 43 def open(path, url: nil, checkpoint_id: nil, manifest_poll_interval: nil, checkpoint_lifetime: nil, max_memtable_bytes: nil, cache_root: nil, max_open_file_handles: nil, merge_operator: nil) opts = {} opts[:manifest_poll_interval] = manifest_poll_interval if manifest_poll_interval opts[:checkpoint_lifetime] = checkpoint_lifetime if checkpoint_lifetime opts[:max_memtable_bytes] = max_memtable_bytes if max_memtable_bytes opts[:cache_root] = cache_root if cache_root opts[:max_open_file_handles] = max_open_file_handles if max_open_file_handles opts[:merge_operator] = merge_operator.to_s if merge_operator reader = _open(path, url, checkpoint_id, opts) if block_given? begin yield reader ensure begin reader.close rescue StandardError nil end end else reader end end |
Instance Method Details
#get(key, durability_filter: nil, dirty: nil, cache_blocks: nil) ⇒ String?
Get a value by key.
81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/slatedb/reader.rb', line 81 def get(key, durability_filter: nil, dirty: nil, cache_blocks: nil) opts = {} opts[:durability_filter] = durability_filter.to_s if durability_filter opts[:dirty] = dirty unless dirty.nil? opts[:cache_blocks] = cache_blocks unless cache_blocks.nil? if opts.empty? _get(key) else (key, opts) end end |
#scan(start_key, end_key = nil, durability_filter: nil, dirty: nil, read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil) ⇒ Iterator
Scan a range of keys.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/slatedb/reader.rb', line 100 def scan(start_key, end_key = nil, durability_filter: nil, dirty: nil, read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil, &) opts = {} opts[:durability_filter] = durability_filter.to_s if durability_filter opts[:dirty] = dirty unless dirty.nil? opts[:read_ahead_bytes] = read_ahead_bytes if read_ahead_bytes opts[:cache_blocks] = cache_blocks unless cache_blocks.nil? opts[:max_fetch_tasks] = max_fetch_tasks if max_fetch_tasks iter = if opts.empty? _scan(start_key, end_key) else (start_key, end_key, opts) end if block_given? iter.each(&) else iter end end |
#scan_prefix(prefix, durability_filter: nil, dirty: nil, read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil) ⇒ Iterator
Scan all keys with a given prefix.
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/slatedb/reader.rb', line 132 def scan_prefix(prefix, durability_filter: nil, dirty: nil, read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil, &) opts = {} opts[:durability_filter] = durability_filter.to_s if durability_filter opts[:dirty] = dirty unless dirty.nil? opts[:read_ahead_bytes] = read_ahead_bytes if read_ahead_bytes opts[:cache_blocks] = cache_blocks unless cache_blocks.nil? opts[:max_fetch_tasks] = max_fetch_tasks if max_fetch_tasks iter = if opts.empty? _scan_prefix(prefix) else (prefix, opts) end if block_given? iter.each(&) else iter end end |