right_support 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/right_support/db/cassandra_model.rb +21 -28
- data/right_support.gemspec +2 -2
- metadata +4 -4
@@ -273,7 +273,7 @@ module RightSupport::DB
|
|
273
273
|
opt = opt.clone
|
274
274
|
opt[:count] = DEFAULT_COUNT
|
275
275
|
columns = Cassandra::OrderedHash.new
|
276
|
-
|
276
|
+
loop do
|
277
277
|
chunk = do_op(:get, column_family, k, opt)
|
278
278
|
columns.merge!(chunk)
|
279
279
|
if chunk.size == opt[:count]
|
@@ -296,6 +296,10 @@ module RightSupport::DB
|
|
296
296
|
# columns(Array|nil):: Names of columns to be retrieved, defaults to all
|
297
297
|
# opt(Hash):: Request options with only :consistency used
|
298
298
|
#
|
299
|
+
# === Block
|
300
|
+
# Optional block that is yielded each chunk as it is retrieved as an array
|
301
|
+
# like the normally returned result
|
302
|
+
#
|
299
303
|
# === Return
|
300
304
|
# (OrderedHash):: Rows retrieved with each key, value is columns
|
301
305
|
def get_all_indexed_slices(index, key, columns = nil, opt = {})
|
@@ -329,40 +333,29 @@ module RightSupport::DB
|
|
329
333
|
#
|
330
334
|
# === Return
|
331
335
|
# (Array):: Rows retrieved with each member being an instantiated object of the
|
332
|
-
# given class as value, but object only contains values for the columns retrieved
|
336
|
+
# given class as value, but object only contains values for the columns retrieved;
|
337
|
+
# array is always empty if a block is given
|
333
338
|
def get_indexed(index, key, columns = nil, opt = {})
|
334
|
-
|
335
|
-
rows.map do |key, columns|
|
336
|
-
attrs = columns.inject({}) { |a, c| a[c.column.name] = c.column.value; a }
|
337
|
-
new(key, attrs)
|
338
|
-
end
|
339
|
-
else
|
340
|
-
[]
|
341
|
-
end
|
342
|
-
end
|
343
|
-
|
344
|
-
# Get all raw rows for specified secondary key
|
345
|
-
#
|
346
|
-
# === Parameters
|
347
|
-
# index(String):: Name of secondary index
|
348
|
-
# key(String):: Index value that each selected row is required to match
|
349
|
-
# columns(Array|nil):: Names of columns to be retrieved, defaults to all
|
350
|
-
# opt(Hash):: Request options with only :consistency used
|
351
|
-
#
|
352
|
-
# === Return
|
353
|
-
# (Hash):: Rows retrieved with primary key as key and value being an array
|
354
|
-
# of CassandraThrift::ColumnOrSuperColumn with attributes :name, :timestamp,
|
355
|
-
# and :value
|
356
|
-
def real_get_indexed(index, key, columns = nil, opt = {})
|
357
|
-
rows = {}
|
339
|
+
rows = []
|
358
340
|
start = ""
|
359
341
|
count = DEFAULT_COUNT
|
360
342
|
expr = do_op(:create_idx_expr, index, key, "EQ")
|
361
343
|
opt = opt[:consistency] ? {:consistency => opt[:consistency]} : {}
|
362
|
-
|
344
|
+
loop do
|
363
345
|
clause = do_op(:create_idx_clause, [expr], start, count)
|
364
346
|
chunk = do_op(:get_indexed_slices, column_family, clause, columns, opt)
|
365
|
-
|
347
|
+
chunk_rows = []
|
348
|
+
chunk.each do |row_key, row_columns|
|
349
|
+
if row_columns && row_key != start
|
350
|
+
attrs = row_columns.inject({}) { |a, c| a[c.column.name] = c.column.value; a }
|
351
|
+
chunk_rows << new(row_key, attrs)
|
352
|
+
end
|
353
|
+
end
|
354
|
+
if block_given?
|
355
|
+
yield chunk_rows
|
356
|
+
else
|
357
|
+
rows.concat(chunk_rows)
|
358
|
+
end
|
366
359
|
if chunk.size == count
|
367
360
|
# Assume there are more chunks, use last key as start of next get
|
368
361
|
start = chunk.keys.last
|
data/right_support.gemspec
CHANGED
@@ -7,8 +7,8 @@ spec = Gem::Specification.new do |s|
|
|
7
7
|
s.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
|
8
8
|
|
9
9
|
s.name = 'right_support'
|
10
|
-
s.version = '2.
|
11
|
-
s.date = '2012-06-
|
10
|
+
s.version = '2.2.0'
|
11
|
+
s.date = '2012-06-22'
|
12
12
|
|
13
13
|
s.authors = ['Tony Spataro', 'Sergey Sergyenko', 'Ryan Williamson', 'Lee Kirchhoff', 'Sergey Enin']
|
14
14
|
s.email = 'support@rightscale.com'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: right_support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
-
-
|
8
|
+
- 2
|
9
9
|
- 0
|
10
|
-
version: 2.
|
10
|
+
version: 2.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tony Spataro
|
@@ -19,7 +19,7 @@ autorequire:
|
|
19
19
|
bindir: bin
|
20
20
|
cert_chain: []
|
21
21
|
|
22
|
-
date: 2012-06-
|
22
|
+
date: 2012-06-22 00:00:00 Z
|
23
23
|
dependencies: []
|
24
24
|
|
25
25
|
description: A toolkit of useful, reusable foundation code created by RightScale.
|