Class: Tarantool16::DumbDB

Inherits:
DB
  • Object
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

Methods inherited from DB

#_call, #_call16, #_delete, #_eval, #_fill_indices, #_fill_spaces, #_insert, #_ping, #_replace, #_select, #_space_future, #_update, #_upsert, #_with_space, #define_fields, #initialize

Constructor Details

This class inherits a constructor from Tarantool16::DB

Instance Method Details

#_norm_key(key) ⇒ Object



84
85
86
87
88
89
90
91
92
93
# File 'lib/tarantool16/dumb_db.rb', line 84

def _norm_key(key)
  case key
  when Array
    key
  when Hash
    key
  else
    [key]
  end
end

#_synchronizedObject



80
81
82
# File 'lib/tarantool16/dumb_db.rb', line 80

def _synchronized
  yield
end

#call(name, args) ⇒ Object



68
69
70
# File 'lib/tarantool16/dumb_db.rb', line 68

def call(name, args)
  _call(name, args, RETURN_OR_RAISE)
end

#call16(name, args) ⇒ Object



72
73
74
# File 'lib/tarantool16/dumb_db.rb', line 72

def call16(name, args)
  _call16(name, args, RETURN_OR_RAISE)
end

#delete(sno, key, opts = {}) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/tarantool16/dumb_db.rb', line 46

def delete(sno, key, opts = {})
  key_hash = Hash === key
  ino = opts[:index] || (key_hash ? nil : 0)
  need_hash = opts.fetch(:hash, key_hash)
  key = _norm_key(key)
  _delete(sno, ino, key, need_hash, RETURN_OR_RAISE)
end

#eval(expr, args) ⇒ Object



76
77
78
# File 'lib/tarantool16/dumb_db.rb', line 76

def eval(expr, args)
  _eval(expr, args, RETURN_OR_RAISE)
end

#get(sno, key, opts = {}) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/tarantool16/dumb_db.rb', line 28

def get(sno, key, opts={})
  ino = opts[:index]
  iterator = opts[:iterator]
  need_hash = opts.fetch(:hash, Hash === key)
  key = _norm_key(key)
  _select(sno, ino, key, 0, 1, iterator, need_hash, RETURN_ONE_OR_RAISE)
end

#insert(sno, tuple, opts = {}) ⇒ Object



36
37
38
39
# File 'lib/tarantool16/dumb_db.rb', line 36

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



41
42
43
44
# File 'lib/tarantool16/dumb_db.rb', line 41

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
# 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.fetch(:hash, Hash === key)
  key = _norm_key(key)
  _select(sno, ino, key, offset, limit, iterator, need_hash, RETURN_OR_RAISE)
end

#update(sno, key, ops, opts = {}) ⇒ Object



54
55
56
57
58
59
60
# File 'lib/tarantool16/dumb_db.rb', line 54

def update(sno, key, ops, opts = {})
  key_hash = Hash === key
  ino = opts[:index] || (key_hash ? nil : 0)
  need_hash = opts.fetch(:hash, key_hash)
  key = _norm_key(key)
  _update(sno, ino, key, ops, need_hash, RETURN_OR_RAISE)
end

#upsert(sno, tuple_key, ops, opts = {}) ⇒ Object



62
63
64
65
66
# File 'lib/tarantool16/dumb_db.rb', line 62

def upsert(sno, tuple_key, ops, opts = {})
  ino = opts[:index] || 0
  need_hash = opts.fetch(:hash, Hash === tuple_key)
  _upsert(sno, ino, tuple_key, ops, need_hash, RETURN_OR_RAISE)
end