sessionm-cassandra_object 4.0.26 → 4.0.27
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c93aa37334ac497b7c97b5c0a1c04350502e230
|
4
|
+
data.tar.gz: 894c0e7ffac48271d0efa1b75defe0c67f7c3b47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4162a2b08feefbe4ed8cffa60826421344b6982f4e82b31627495dcf2e6dcfbe2f3af4cc666051918a868d2e410a9d97077f34c14e2d651c164206870a24684d
|
7
|
+
data.tar.gz: 936877179c08b6e3b3ffdf4d74d7384bc3da5e32dbafb29f4d361daa10b2a417be76e20fee99139858a7db7399aa495400112aee04a4882258eef77d9e899c70
|
@@ -99,13 +99,18 @@ module CassandraObject
|
|
99
99
|
|
100
100
|
insert_into_options = ttl ? " USING TTL #{ttl}" : ''
|
101
101
|
|
102
|
-
|
103
|
-
|
104
|
-
" INSERT INTO \"#{column_family}\" (#{KEY_FIELD}, #{NAME_FIELD}, #{VALUE_FIELD}) VALUES (#{escape(key, key_type(column_family))}, #{escape(name, name_type(column_family))}, #{escape(value, value_type(column_family))})#{insert_into_options}"
|
102
|
+
insert_query = values.map do |name, value|
|
103
|
+
" INSERT INTO \"#{column_family}\" (#{KEY_FIELD}, #{NAME_FIELD}, #{VALUE_FIELD}) VALUES (#{escape(key, key_type(column_family))}, #{escape(name, name_type(column_family))}, #{escape(value, value_type(column_family))})#{insert_into_options}"
|
105
104
|
end.join("\n")
|
106
|
-
query << "\nAPPLY BATCH;"
|
107
105
|
|
108
|
-
|
106
|
+
if batch_mode?
|
107
|
+
@batched_queries << insert_query
|
108
|
+
else
|
109
|
+
query = "BEGIN BATCH\n"
|
110
|
+
query << insert_query
|
111
|
+
query << "\nAPPLY BATCH;"
|
112
|
+
async ? self.execute_async(query, execute_options(opts)) : self.execute(query, execute_options(opts))
|
113
|
+
end
|
109
114
|
end
|
110
115
|
|
111
116
|
def get(column_family, key, *columns_options)
|
@@ -261,8 +266,28 @@ module CassandraObject
|
|
261
266
|
@column_families ||= self.cluster.keyspace(session.keyspace).tables.inject({}) { |hsh, table| hsh[table.name] = table; hsh }
|
262
267
|
end
|
263
268
|
|
264
|
-
def
|
265
|
-
|
269
|
+
def batch_mode?
|
270
|
+
!! @batched_queries
|
271
|
+
end
|
272
|
+
|
273
|
+
def batch(opts=false)
|
274
|
+
if @batched_queries
|
275
|
+
yield
|
276
|
+
else
|
277
|
+
begin
|
278
|
+
async = opts.try(:[], :async)
|
279
|
+
@batched_queries ||= []
|
280
|
+
yield
|
281
|
+
query = "BEGIN BATCH\n"
|
282
|
+
query << @batched_queries.join("\n")
|
283
|
+
query << "\nAPPLY BATCH;"
|
284
|
+
async ? self.execute_async(query, execute_options(opts)) : self.execute(query, execute_options(opts))
|
285
|
+
rescue Exception => e
|
286
|
+
raise e
|
287
|
+
ensure
|
288
|
+
@batched_queries = nil
|
289
|
+
end
|
290
|
+
end
|
266
291
|
end
|
267
292
|
|
268
293
|
def schema(reload=false)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sessionm-cassandra_object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Doug Youch
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-12-
|
12
|
+
date: 2017-12-05 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Cassandra ActiveModel
|
15
15
|
email: doug@sessionm.com
|