sessionm-cassandra_object 2.2.38 → 2.2.39

Sign up to get free protection for your applications and to get access to all the features.
@@ -67,7 +67,33 @@ module CassandraObject
67
67
  multi_get_by_expression(expression, options).values
68
68
  end
69
69
 
70
+ # Selecting a slice of a super column is not supported by default with the cassandra gem
71
+ # TODO: move this to Cassandra gem.
72
+ def get_slice(key, start, finish, opts={})
73
+ parent = CassandraThrift::ColumnParent.new(:column_family => column_family)
74
+ predicate = CassandraThrift::SlicePredicate.
75
+ new(:slice_range =>
76
+ CassandraThrift::SliceRange.new(:start => start,
77
+ :finish => finish,
78
+ :count => opts[:count] || 100,
79
+ :reversed => opts[:reversed] || false))
80
+
81
+ ActiveSupport::Notifications.instrument("get_slice.cassandra_object", column_family: column_family, key: key, start: start, finish: finish) do
82
+ {}.tap do |result|
83
+ connection.send(:client).get_slice(key, parent, predicate, opts[:consistency] || Cassandra::Consistency::ONE).each do |column|
84
+ result[column.counter_super_column.name] = _columns_to_hash(column.counter_super_column.columns)
85
+ end
86
+ end
87
+ end
88
+ end
89
+
70
90
  private
91
+ def _columns_to_hash(columns)
92
+ {}.tap do |hsh|
93
+ columns.each { |column| hsh[column.name] = column.value }
94
+ end
95
+ end
96
+
71
97
  def instantiate_many(attribute_results)
72
98
  attribute_results.inject({}) do |memo, (key, attributes)|
73
99
  if attributes.empty?
@@ -50,6 +50,12 @@ module CassandraObject
50
50
 
51
51
  debug " #{name} (#{event.payload[:count]}) '#{event.payload[:start]}' => '#{event.payload[:finish]}'"
52
52
  end
53
+
54
+ def get_slice(event)
55
+ name = '%s get_slice (%.1fms)' % [event.payload[:column_family], event.duration]
56
+
57
+ debug " #{name} #{event.payload[:key]} '#{event.payload[:start]}' => '#{event.payload[:finish]}'"
58
+ end
53
59
  end
54
60
  end
55
61
  CassandraObject::LogSubscriber.attach_to :cassandra_object
@@ -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.38'
5
+ s.version = '2.2.39'
6
6
  s.description = 'Cassandra ActiveModel'
7
7
  s.summary = 'Cassandra ActiveModel'
8
8
 
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: 2.2.38
4
+ version: 2.2.39
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-03-09 00:00:00.000000000Z
14
+ date: 2012-03-21 00:00:00.000000000Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
18
- requirement: &70194630622300 !ruby/object:Gem::Requirement
18
+ requirement: &70092495048800 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ~>
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: '3.0'
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *70194630622300
26
+ version_requirements: *70092495048800
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: cassandra
29
- requirement: &70194630621820 !ruby/object:Gem::Requirement
29
+ requirement: &70092495048280 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ! '>='
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: 0.11.3
35
35
  type: :runtime
36
36
  prerelease: false
37
- version_requirements: *70194630621820
37
+ version_requirements: *70092495048280
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: bundler
40
- requirement: &70194630621360 !ruby/object:Gem::Requirement
40
+ requirement: &70092495047600 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ~>
@@ -45,7 +45,7 @@ dependencies:
45
45
  version: 1.0.0
46
46
  type: :development
47
47
  prerelease: false
48
- version_requirements: *70194630621360
48
+ version_requirements: *70092495047600
49
49
  description: Cassandra ActiveModel
50
50
  email: klange@sessionm.com
51
51
  executables: []