tarantool 0.3.0.7 → 0.4.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/Gemfile +2 -3
  2. data/README.md +90 -30
  3. data/Rakefile +6 -1
  4. data/lib/tarantool.rb +93 -18
  5. data/lib/tarantool/base_record.rb +97 -10
  6. data/lib/tarantool/block_db.rb +104 -6
  7. data/lib/tarantool/callback_db.rb +7 -0
  8. data/lib/tarantool/core-ext.rb +24 -8
  9. data/lib/tarantool/em_db.rb +189 -20
  10. data/lib/tarantool/exceptions.rb +4 -0
  11. data/lib/tarantool/fiber_db.rb +15 -1
  12. data/lib/tarantool/light_record.rb +17 -0
  13. data/lib/tarantool/query.rb +15 -9
  14. data/lib/tarantool/record/select.rb +21 -3
  15. data/lib/tarantool/request.rb +130 -43
  16. data/lib/tarantool/response.rb +70 -7
  17. data/lib/tarantool/serializers.rb +26 -5
  18. data/lib/tarantool/serializers/ber_array.rb +14 -0
  19. data/lib/tarantool/shards_support.rb +204 -0
  20. data/lib/tarantool/space_array.rb +38 -13
  21. data/lib/tarantool/space_hash.rb +49 -27
  22. data/lib/tarantool/util.rb +96 -10
  23. data/lib/tarantool/version.rb +2 -1
  24. data/test/helper.rb +154 -4
  25. data/test/{tarant/init.lua → init.lua} +0 -0
  26. data/test/run_all.rb +2 -2
  27. data/test/shared_record.rb +59 -0
  28. data/test/shared_replicated_shard.rb +1018 -0
  29. data/test/shared_reshard.rb +380 -0
  30. data/test/tarantool.cfg +2 -0
  31. data/test/test_light_record.rb +2 -0
  32. data/test/test_light_record_callback.rb +92 -0
  33. data/test/test_query_block.rb +1 -0
  34. data/test/test_query_fiber.rb +1 -0
  35. data/test/test_reshard_block.rb +7 -0
  36. data/test/test_reshard_fiber.rb +11 -0
  37. data/test/test_shard_replication_block.rb +7 -0
  38. data/test/test_shard_replication_fiber.rb +11 -0
  39. data/test/test_space_array_block.rb +1 -0
  40. data/test/test_space_array_callback.rb +50 -121
  41. data/test/test_space_array_callback_nodef.rb +39 -96
  42. data/test/test_space_array_fiber.rb +1 -0
  43. data/test/test_space_hash_block.rb +1 -0
  44. data/test/test_space_hash_fiber.rb +1 -0
  45. metadata +54 -17
  46. data/lib/tarantool/record.rb +0 -164
  47. data/test/box.pid +0 -1
  48. data/test/tarantool.log +0 -6
  49. data/test/tarantool_repl.cfg +0 -53
  50. data/test/test_record.rb +0 -88
  51. data/test/test_record_composite_pk.rb +0 -77
@@ -1,77 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require File.expand_path('../helper.rb', __FILE__)
3
- require 'tarantool/record'
4
- require 'yajl'
5
- require 'tarantool/serializers/bson'
6
-
7
- describe Tarantool::Record do
8
- DB = Tarantool.new(TCONFIG.merge(type: :block))
9
- before{ truncate }
10
-
11
- describe "primary key" do
12
- before do
13
- @primary_key_size = 2
14
- end
15
-
16
- let(:address_class) do
17
- Class.new(Tarantool::Record) do
18
- set_tarantool DB
19
- set_space_no 2
20
-
21
- def self.name # For naming
22
- "Adress"
23
- end
24
-
25
- field :city, :string
26
- field :street, :string
27
- field :index, :integer
28
- field :name, :string
29
- field :citizens, :integer, default: 1
30
- index :city, :street, primary: true
31
- index :index
32
- end
33
- end
34
-
35
- describe "composite primary key" do
36
-
37
- before do
38
- address_class.create city: "Moscow", street: "Leningradskii", index: 123, name: "Pedro"
39
- address_class.create city: "Moscow", street: "Mohovaya", index: 123, name: "Pedro"
40
- end
41
-
42
- it "should return objects by second index" do
43
- a1 = address_class.where(index: 123)
44
- a1.all.size.must_equal 2
45
- end
46
-
47
- it "should work with increment" do
48
- a1 = address_class.where(city: "Moscow", street: "Leningradskii").first
49
- citizens = a1.citizens
50
- a1.increment :citizens
51
- a1.reload.citizens.must_equal(citizens+1)
52
- end
53
-
54
- it "should return all objects" do
55
- a1 = address_class.where city: "Moscow"
56
- a1.all.size.must_equal 2
57
- a1.all.map(&:street).must_equal ["Leningradskii", "Mohovaya"]
58
- end
59
-
60
- it "should return right object" do
61
- a1 = address_class.where city: "Moscow", street: "Leningradskii"
62
- a1.first.street.must_equal "Leningradskii"
63
- end
64
-
65
- it "should destroy object" do
66
- a1 = address_class.where city: "Moscow", street: "Leningradskii"
67
- a1.first.destroy
68
- end
69
-
70
- it "should return id" do
71
- a1 = address_class.where city: "Moscow", street: "Leningradskii"
72
- a1.first.id.must_equal ["Moscow", "Leningradskii"]
73
- end
74
-
75
- end
76
- end
77
- end