sessionm-cassandra_object 2.2.16 → 2.2.18

Sign up to get free protection for your applications and to get access to all the features.
@@ -48,12 +48,12 @@ module CassandraObject
48
48
  results.size <= 1 && !expects_array ? results.first : results
49
49
  end
50
50
 
51
- private
52
- def multi_get(keys, options={})
53
- attribute_results = ActiveSupport::Notifications.instrument("multi_get.cassandra_object", column_family: column_family, keys: keys) do
54
- connection.multi_get(column_family, keys.map(&:to_s), consistency: thrift_read_consistency)
55
- end
51
+ def find_all_by_expression(expression)
52
+ multi_get_by_expression(expression).values
53
+ end
56
54
 
55
+ private
56
+ def instantiate_many(attribute_results)
57
57
  attribute_results.inject({}) do |memo, (key, attributes)|
58
58
  if attributes.empty?
59
59
  memo[key] = nil
@@ -64,6 +64,23 @@ module CassandraObject
64
64
  end
65
65
  end
66
66
 
67
+ def multi_get(keys, options={})
68
+ attribute_results = ActiveSupport::Notifications.instrument("multi_get.cassandra_object", column_family: column_family, keys: keys) do
69
+ connection.multi_get(column_family, keys.map(&:to_s), consistency: thrift_read_consistency)
70
+ end
71
+
72
+ instantiate_many(attribute_results)
73
+ end
74
+
75
+ def multi_get_by_expression(expression)
76
+ attribute_results = ActiveSupport::Notifications.instrument("multi_get_by_expression.cassandra_object", column_family: column_family, expression: expression) do
77
+ intermediate_results = connection.get_indexed_slices(column_family, expression, consistency: thrift_read_consistency)
78
+ connection.send(:multi_columns_to_hash!, column_family, intermediate_results)
79
+ end
80
+
81
+ instantiate_many(attribute_results)
82
+ end
83
+
67
84
  def get(key, options={})
68
85
  multi_get([key], options).values.first
69
86
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'sessionm-cassandra_object'
5
- s.version = '2.2.16'
5
+ s.version = '2.2.18'
6
6
  s.description = 'Cassandra ActiveModel'
7
7
  s.summary = 'Cassandra ActiveModel'
8
8
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 2
7
7
  - 2
8
- - 16
9
- version: 2.2.16
8
+ - 18
9
+ version: 2.2.18
10
10
  platform: ruby
11
11
  authors:
12
12
  - Michael Koziarski
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-08-12 00:00:00 -04:00
19
+ date: 2011-08-15 00:00:00 -04:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency