/usr/lib/ruby/1.8/continuum_native.rb is in libmemcache-client-ruby1.8 1.7.8-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | module Continuum
class << self
# Native extension to perform the binary search within the continuum
# space. There's a pure ruby version in memcache.rb so this is purely
# optional for performance and only necessary if you are using multiple
# memcached servers.
begin
require 'inline'
inline do |builder|
builder.c <<-EOM
int binary_search(VALUE ary, unsigned int r) {
int upper = RARRAY_LEN(ary) - 1;
int lower = 0;
int idx = 0;
ID value = rb_intern("value");
while (lower <= upper) {
idx = (lower + upper) / 2;
VALUE continuumValue = rb_funcall(RARRAY_PTR(ary)[idx], value, 0);
unsigned int l = NUM2UINT(continuumValue);
if (l == r) {
return idx;
}
else if (l > r) {
upper = idx - 1;
}
else {
lower = idx + 1;
}
}
return upper;
}
EOM
end
rescue Exception => e
end
end
end
|