extralite-bundle 2.5 → 2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +34 -13
- data/Gemfile +4 -0
- data/Gemfile-bundle +1 -1
- data/LICENSE +1 -1
- data/README.md +1059 -247
- data/Rakefile +18 -0
- data/TODO.md +0 -7
- data/examples/kv_store.rb +49 -0
- data/examples/multi_fiber.rb +16 -0
- data/examples/on_progress.rb +9 -0
- data/examples/pubsub_store_polyphony.rb +194 -0
- data/examples/pubsub_store_threads.rb +204 -0
- data/ext/extralite/changeset.c +463 -0
- data/ext/extralite/common.c +177 -91
- data/ext/extralite/database.c +745 -276
- data/ext/extralite/extconf-bundle.rb +10 -4
- data/ext/extralite/extconf.rb +34 -34
- data/ext/extralite/extralite.h +104 -47
- data/ext/extralite/extralite_ext.c +6 -0
- data/ext/extralite/iterator.c +14 -86
- data/ext/extralite/query.c +171 -264
- data/extralite-bundle.gemspec +1 -1
- data/extralite.gemspec +1 -1
- data/gemspec.rb +10 -11
- data/lib/extralite/version.rb +1 -1
- data/lib/extralite.rb +69 -10
- data/lib/sequel/adapters/extralite.rb +1 -1
- data/test/helper.rb +9 -1
- data/test/perf_argv_transform.rb +74 -0
- data/test/perf_ary.rb +14 -12
- data/test/perf_hash.rb +17 -15
- data/test/perf_hash_prepared.rb +58 -0
- data/test/perf_hash_transform.rb +66 -0
- data/test/perf_polyphony.rb +74 -0
- data/test/test_changeset.rb +161 -0
- data/test/test_database.rb +720 -104
- data/test/test_extralite.rb +2 -2
- data/test/test_iterator.rb +28 -13
- data/test/test_query.rb +352 -110
- data/test/test_sequel.rb +4 -4
- metadata +24 -16
- data/Gemfile.lock +0 -37
- data/test/perf_prepared.rb +0 -64
data/test/test_extralite.rb
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
require_relative 'helper'
|
4
4
|
|
5
|
-
class ExtraliteTest <
|
5
|
+
class ExtraliteTest < Minitest::Test
|
6
6
|
def test_sqlite3_version
|
7
|
-
assert_match
|
7
|
+
assert_match(/^3\.\d+\.\d+$/, Extralite.sqlite3_version)
|
8
8
|
end
|
9
9
|
|
10
10
|
def test_status
|
data/test/test_iterator.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative 'helper'
|
4
4
|
|
5
|
-
class IteratorTest <
|
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
|
-
|
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.
|
45
|
-
iter = query.
|
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
|
-
|
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.
|
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
|
-
|
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.
|
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
|
-
|
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.
|
96
|
-
mapped = query.
|
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
|
-
|
102
|
-
|
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
|