Class: Tarantool16::DumbDB
- Inherits:
-
DB
- Object
- DB
- Tarantool16::DumbDB
show all
- Defined in:
- lib/tarantool16/dumb_db.rb
Defined Under Namespace
Classes: SchemaFuture
Constant Summary
collapse
- Connection =
Tarantool16::Connection::Dumb
- RETURN_OR_RAISE =
lambda{|r|
raise r.error unless r.ok?
r.data
}
- RETURN_ONE_OR_RAISE =
lambda{|r|
raise r.error unless r.ok?
r.data[0]
}
- HUGE_LIMIT =
2**30
Constants inherited
from DB
Tarantool16::DB::UNDEF
Instance Attribute Summary
Attributes inherited from DB
#conn
Instance Method Summary
collapse
-
#_synchronized ⇒ Object
-
#delete(sno, key, opts = {}) ⇒ Object
-
#get(sno, key, opts = {}) ⇒ Object
-
#insert(sno, tuple, opts = {}) ⇒ Object
-
#replace(sno, tuple, opts = {}) ⇒ Object
-
#select(sno, key, opts = {}) ⇒ Object
-
#update(sno, key, ops, opts = {}) ⇒ Object
Methods inherited from DB
#_call, #_delete, #_fill_indices, #_fill_spaces, #_fill_standard_spaces, #_insert, #_ping, #_replace, #_select, #_space_future, #_update, #_with_space, #define_fields, #initialize
Instance Method Details
#_synchronized ⇒ Object
78
79
80
|
# File 'lib/tarantool16/dumb_db.rb', line 78
def _synchronized
yield
end
|
#delete(sno, key, opts = {}) ⇒ Object
66
67
68
69
70
|
# File 'lib/tarantool16/dumb_db.rb', line 66
def delete(sno, key, opts = {})
ino = opts[:index]
need_hash = opts[:hash] || tkey.is_a?(Hash)
_delete(sno, ino, key, need_hash, RETURN_OR_RAISE)
end
|
#get(sno, key, opts = {}) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/tarantool16/dumb_db.rb', line 38
def get(sno, key, opts={})
ino = opts[:index]
iterator = opts[:iterator]
need_hash = opts[:hash]
key = case key
when nil
[]
when Array
key
when Hash
need_hash = true
key
else
[key]
end
_select(sno, ino, key, 0, 1, iterator, need_hash, RETURN_ONE_OR_RAISE)
end
|
#insert(sno, tuple, opts = {}) ⇒ Object
56
57
58
59
|
# File 'lib/tarantool16/dumb_db.rb', line 56
def insert(sno, tuple, opts = {})
need_hash = opts[:hash] || tuple.is_a?(Hash)
_insert(sno, tuple, need_hash, RETURN_OR_RAISE)
end
|
#replace(sno, tuple, opts = {}) ⇒ Object
61
62
63
64
|
# File 'lib/tarantool16/dumb_db.rb', line 61
def replace(sno, tuple, opts = {})
need_hash = opts[:hash] || tuple.is_a?(Hash)
_replace(sno, tuple, need_hash, RETURN_OR_RAISE)
end
|
#select(sno, key, opts = {}) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/tarantool16/dumb_db.rb', line 18
def select(sno, key, opts={})
ino = opts[:index]
offset = opts[:offset] || 0
limit = opts[:limit] || 2**30
iterator = opts[:iterator]
need_hash = opts[:hash]
key = case key
when nil
[]
when Array
key
when Hash
need_hash = true
key
else
[key]
end
_select(sno, ino, key, offset, limit, iterator, need_hash, RETURN_OR_RAISE)
end
|
#update(sno, key, ops, opts = {}) ⇒ Object
72
73
74
75
76
|
# File 'lib/tarantool16/dumb_db.rb', line 72
def update(sno, key, ops, opts = {})
ino = opts[:index]
need_hash = opts[:hash] || key.is_a?(Hash)
_update(sno, ino, key, ops, need_hash, RETURN_OR_RAISE)
end
|