sessionm-cassandra_object 2.6.0 → 2.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -68,15 +68,29 @@ module CassandraObject
68
68
  datacenter = datacenter.to_s
69
69
  ring.map do |t|
70
70
  {
71
- :start_token => sprintf('%032x', t.start_token.to_i),
72
- :end_token => t.end_token.to_i == 0 ? ('f' * 32) : sprintf('%032x', t.end_token.to_i - 1),
71
+ :start_token => t.start_token.to_i,
72
+ :end_token => t.end_token.to_i == 0 ? 0xffffffffffffffffffffffffffffffff : (t.end_token.to_i - 1),
73
73
  :servers => t.endpoint_details.select { |d| d.datacenter == datacenter }.map { |d| "#{d.host}:9160" }
74
74
  }
75
75
  end
76
76
  end
77
77
 
78
+ NEGATIVE_TEST = 0x80000000000000000000000000000000
79
+ FLIP_BITS_MASK = 0xffffffffffffffffffffffffffffffff
78
80
  def self.ranged_connection_pool_key_algo
79
- Proc.new { |key| Digest::MD5.hexdigest key.to_s }
81
+ Proc.new do |key|
82
+ key = Digest::MD5.hexdigest(key.to_s).to_i(16)
83
+
84
+ # https://github.com/datastax/java-driver/blob/2.0/driver-core/src/main/java/com/datastax/driver/core/Token.java:259
85
+ # test to see if the unsigned integer is a negative singed value
86
+ if (key & NEGATIVE_TEST) != 0
87
+ # need to flip all the bits
88
+ # abs
89
+ (key ^ FLIP_BITS_MASK) + 1
90
+ else
91
+ key
92
+ end
93
+ end
80
94
  end
81
95
 
82
96
  def self.new_ranged_connection_pool(async)
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'sessionm-cassandra_object'
5
- s.version = '2.6.0'
5
+ s.version = '2.6.1'
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.6.0
4
+ version: 2.6.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-10-07 00:00:00.000000000 Z
14
+ date: 2013-10-23 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails