extralite-bundle 2.5 → 2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +34 -13
  4. data/Gemfile +4 -0
  5. data/Gemfile-bundle +1 -1
  6. data/LICENSE +1 -1
  7. data/README.md +1059 -247
  8. data/Rakefile +18 -0
  9. data/TODO.md +0 -7
  10. data/examples/kv_store.rb +49 -0
  11. data/examples/multi_fiber.rb +16 -0
  12. data/examples/on_progress.rb +9 -0
  13. data/examples/pubsub_store_polyphony.rb +194 -0
  14. data/examples/pubsub_store_threads.rb +204 -0
  15. data/ext/extralite/changeset.c +463 -0
  16. data/ext/extralite/common.c +177 -91
  17. data/ext/extralite/database.c +745 -276
  18. data/ext/extralite/extconf-bundle.rb +10 -4
  19. data/ext/extralite/extconf.rb +34 -34
  20. data/ext/extralite/extralite.h +104 -47
  21. data/ext/extralite/extralite_ext.c +6 -0
  22. data/ext/extralite/iterator.c +14 -86
  23. data/ext/extralite/query.c +171 -264
  24. data/extralite-bundle.gemspec +1 -1
  25. data/extralite.gemspec +1 -1
  26. data/gemspec.rb +10 -11
  27. data/lib/extralite/version.rb +1 -1
  28. data/lib/extralite.rb +69 -10
  29. data/lib/sequel/adapters/extralite.rb +1 -1
  30. data/test/helper.rb +9 -1
  31. data/test/perf_argv_transform.rb +74 -0
  32. data/test/perf_ary.rb +14 -12
  33. data/test/perf_hash.rb +17 -15
  34. data/test/perf_hash_prepared.rb +58 -0
  35. data/test/perf_hash_transform.rb +66 -0
  36. data/test/perf_polyphony.rb +74 -0
  37. data/test/test_changeset.rb +161 -0
  38. data/test/test_database.rb +720 -104
  39. data/test/test_extralite.rb +2 -2
  40. data/test/test_iterator.rb +28 -13
  41. data/test/test_query.rb +352 -110
  42. data/test/test_sequel.rb +4 -4
  43. metadata +24 -16
  44. data/Gemfile.lock +0 -37
  45. data/test/perf_prepared.rb +0 -64
@@ -2,9 +2,9 @@
2
2
 
3
3
  require_relative 'helper'
4
4
 
5
- class ExtraliteTest < MiniTest::Test
5
+ class ExtraliteTest < Minitest::Test
6
6
  def test_sqlite3_version
7
- assert_match /^3\.\d+\.\d+$/, Extralite.sqlite3_version
7
+ assert_match(/^3\.\d+\.\d+$/, Extralite.sqlite3_version)
8
8
  end
9
9
 
10
10
  def test_status
@@ -2,7 +2,7 @@
2
2
 
3
3
  require_relative 'helper'
4
4
 
5
- class IteratorTest < MiniTest::Test
5
+ class IteratorTest < Minitest::Test
6
6
  def setup
7
7
  @db = Extralite::Database.new(':memory:')
8
8
  @db.query('create table if not exists t (x,y,z)')
@@ -30,8 +30,20 @@ class IteratorTest < MiniTest::Test
30
30
  assert_equal [{x: 1, y: 2, z: 3},{ x: 4, y: 5, z: 6 }, { x: 7, y: 8, z: 9 }], buf
31
31
  end
32
32
 
33
+ def test_iterator_argv
34
+ @query.mode = :argv
35
+ iter = @query.each
36
+ assert_kind_of Extralite::Iterator, iter
37
+
38
+ buf = []
39
+ v = iter.each { |a, b, c| buf << [a, b, c] }
40
+ assert_equal iter, v
41
+ assert_equal [[1, 2, 3], [4, 5, 6], [7, 8, 9]], buf
42
+ end
43
+
33
44
  def test_iterator_ary
34
- iter = @query.each_ary
45
+ @query.mode = :ary
46
+ iter = @query.each
35
47
  assert_kind_of Extralite::Iterator, iter
36
48
 
37
49
  buf = []
@@ -41,8 +53,8 @@ class IteratorTest < MiniTest::Test
41
53
  end
42
54
 
43
55
  def test_iterator_single_column
44
- query = @db.prepare('select x from t')
45
- iter = query.each_single_column
56
+ query = @db.prepare_argv('select x from t')
57
+ iter = query.each
46
58
  assert_kind_of Extralite::Iterator, iter
47
59
 
48
60
  buf = []
@@ -59,14 +71,15 @@ class IteratorTest < MiniTest::Test
59
71
  assert_nil iter.next
60
72
  assert_nil iter.next
61
73
 
62
- iter = @query.reset.each_ary
74
+ @query.mode = :ary
75
+ @query.reset
63
76
  assert_equal([1, 2, 3], iter.next)
64
77
  assert_equal([4, 5, 6], iter.next)
65
78
  assert_equal([7, 8, 9], iter.next)
66
79
  assert_nil iter.next
67
80
  assert_nil iter.next
68
81
 
69
- iter = @db.prepare('select y from t').each_single_column
82
+ iter = @db.prepare_argv('select y from t').each
70
83
  assert_equal(2, iter.next)
71
84
  assert_equal(5, iter.next)
72
85
  assert_equal(8, iter.next)
@@ -78,10 +91,10 @@ class IteratorTest < MiniTest::Test
78
91
  iter = @query.each
79
92
  assert_equal [{x: 1, y: 2, z: 3},{ x: 4, y: 5, z: 6 }, { x: 7, y: 8, z: 9 }], iter.to_a
80
93
 
81
- iter = @query.each_ary
94
+ @query.mode = :ary
82
95
  assert_equal [[1, 2, 3], [4, 5, 6], [7, 8, 9]], iter.to_a
83
96
 
84
- iter = @db.prepare('select x from t').each_single_column
97
+ iter = @db.prepare_argv('select x from t').each
85
98
  assert_equal [1, 4, 7], iter.to_a
86
99
  end
87
100
 
@@ -89,17 +102,19 @@ class IteratorTest < MiniTest::Test
89
102
  mapped = @query.each.map { |row| row[:x] * 10 }
90
103
  assert_equal [10, 40, 70], mapped
91
104
 
92
- mapped = @query.each_ary.map { |row| row[1] * 10 }
105
+ @query.mode = :ary
106
+ mapped = @query.each.map { |row| row[1] * 10 }
93
107
  assert_equal [20, 50, 80], mapped
94
108
 
95
- query = @db.prepare('select z from t')
96
- mapped = query.each_single_column.map { |v| v * 10 }
109
+ query = @db.prepare_argv('select z from t')
110
+ mapped = query.each.map { |v| v * 10 }
97
111
  assert_equal [30, 60, 90], mapped
98
112
  end
99
113
 
100
114
  def test_iterator_inspect
101
- i = @query.each_ary
102
- assert_match /^\#\<Extralite::Iterator:0x[0-9a-f]+ ary\>$/, i.inspect
115
+ @query.mode = :ary
116
+ i = @query.each
117
+ assert_match(/^\#\<Extralite::Iterator:0x[0-9a-f]+\>$/, i.inspect)
103
118
  end
104
119
 
105
120
  def test_return_from_block_issue_26