cequel 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cequel/model/dictionary.rb +29 -16
- data/lib/cequel/version.rb +1 -1
- metadata +91 -19
@@ -97,9 +97,8 @@ module Cequel
|
|
97
97
|
if @loaded
|
98
98
|
@row.slice(*columns)
|
99
99
|
else
|
100
|
-
|
101
|
-
|
102
|
-
row.each { |col, value| slice[col] = deserialize_value(col, value) }
|
100
|
+
row = scope.select(*columns).first.except(self.class.key_alias)
|
101
|
+
deserialize_row(row).tap do |slice|
|
103
102
|
slice.merge!(@row.slice(*columns))
|
104
103
|
@deleted_columns.each { |column| slice.delete(column) }
|
105
104
|
end
|
@@ -126,27 +125,18 @@ module Cequel
|
|
126
125
|
def each_pair(options = {}, &block)
|
127
126
|
return Enumerator.new(self, :each_pair, options) unless block
|
128
127
|
return @row.each_pair(&block) if @loaded
|
129
|
-
batch_size = options[:batch_size] || self.class.default_batch_size
|
130
|
-
batch_scope = scope.select(:first => batch_size)
|
131
|
-
key_alias = self.class.key_alias
|
132
|
-
last_key = nil
|
133
128
|
new_columns = @changed_columns.dup
|
134
|
-
|
135
|
-
|
136
|
-
batch_results.delete(key_alias)
|
137
|
-
result_length = batch_results.length
|
138
|
-
batch_results.delete(last_key) unless last_key.nil?
|
129
|
+
batch_size = options[:batch_size] || self.class.default_batch_size
|
130
|
+
each_slice(batch_size) do |batch_results|
|
139
131
|
batch_results.each_pair do |key, value|
|
140
132
|
if @changed_columns.include?(key)
|
141
133
|
new_columns.delete(key)
|
142
134
|
yield key, @row[key]
|
143
135
|
elsif !@deleted_columns.include?(key)
|
144
|
-
yield key,
|
136
|
+
yield key, value
|
145
137
|
end
|
146
138
|
end
|
147
|
-
|
148
|
-
batch_scope = batch_scope.select(:from => last_key)
|
149
|
-
end while result_length == batch_size
|
139
|
+
end
|
150
140
|
new_columns.each do |key|
|
151
141
|
yield key, @row[key]
|
152
142
|
end
|
@@ -156,6 +146,21 @@ module Cequel
|
|
156
146
|
each_pair(&block)
|
157
147
|
end
|
158
148
|
|
149
|
+
def each_slice(batch_size)
|
150
|
+
batch_scope = scope.select(:first => batch_size)
|
151
|
+
key_alias = self.class.key_alias
|
152
|
+
last_key = nil
|
153
|
+
begin
|
154
|
+
batch_results = batch_scope.first
|
155
|
+
batch_results.delete(key_alias)
|
156
|
+
result_length = batch_results.length
|
157
|
+
batch_results.delete(last_key) unless last_key.nil?
|
158
|
+
yield deserialize_row(batch_results)
|
159
|
+
last_key = batch_results.keys.last
|
160
|
+
batch_scope = batch_scope.select(:from => last_key)
|
161
|
+
end while result_length == batch_size
|
162
|
+
end
|
163
|
+
|
159
164
|
def load
|
160
165
|
@row = {}
|
161
166
|
each_pair { |column, value| @row[column] = value }
|
@@ -195,6 +200,14 @@ module Cequel
|
|
195
200
|
value
|
196
201
|
end
|
197
202
|
|
203
|
+
def deserialize_row(row)
|
204
|
+
{}.tap do |slice|
|
205
|
+
row.each_pair do |column, value|
|
206
|
+
slice[column] = deserialize_value(column, value)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
198
211
|
end
|
199
212
|
|
200
213
|
end
|
data/lib/cequel/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cequel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '3.1'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.1'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: activemodel
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ~>
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '3.1'
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '3.1'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: cassandra-cql
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ~>
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: '1.0'
|
44
54
|
type: :runtime
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: i18n
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ! '>='
|
@@ -54,10 +69,15 @@ dependencies:
|
|
54
69
|
version: '0'
|
55
70
|
type: :runtime
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
79
|
name: rspec
|
60
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
82
|
requirements:
|
63
83
|
- - ~>
|
@@ -65,10 +85,15 @@ dependencies:
|
|
65
85
|
version: '2.0'
|
66
86
|
type: :development
|
67
87
|
prerelease: false
|
68
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '2.0'
|
69
94
|
- !ruby/object:Gem::Dependency
|
70
95
|
name: debugger
|
71
|
-
requirement:
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
72
97
|
none: false
|
73
98
|
requirements:
|
74
99
|
- - ! '>='
|
@@ -76,10 +101,15 @@ dependencies:
|
|
76
101
|
version: '0'
|
77
102
|
type: :development
|
78
103
|
prerelease: false
|
79
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
80
110
|
- !ruby/object:Gem::Dependency
|
81
111
|
name: yard
|
82
|
-
requirement:
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
83
113
|
none: false
|
84
114
|
requirements:
|
85
115
|
- - ~>
|
@@ -87,10 +117,31 @@ dependencies:
|
|
87
117
|
version: '0.6'
|
88
118
|
type: :development
|
89
119
|
prerelease: false
|
90
|
-
version_requirements:
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ~>
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0.6'
|
91
126
|
- !ruby/object:Gem::Dependency
|
92
127
|
name: geminabox
|
93
|
-
requirement:
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: rocco
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
94
145
|
none: false
|
95
146
|
requirements:
|
96
147
|
- - ! '>='
|
@@ -98,7 +149,28 @@ dependencies:
|
|
98
149
|
version: '0'
|
99
150
|
type: :development
|
100
151
|
prerelease: false
|
101
|
-
version_requirements:
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: redcarpet
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - <
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '2.0'
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - <
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '2.0'
|
102
174
|
description: ! 'Cequel is a lightweight query abstraction layer for Cassandra''s CQL
|
103
175
|
language. It
|
104
176
|
|
@@ -204,7 +276,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
204
276
|
requirements:
|
205
277
|
- Cassandra 1.0+
|
206
278
|
rubyforge_project:
|
207
|
-
rubygems_version: 1.8.
|
279
|
+
rubygems_version: 1.8.24
|
208
280
|
signing_key:
|
209
281
|
specification_version: 3
|
210
282
|
summary: Query abstraction layer and object-row mapper for Cassandra and CQL
|