class FDB::Subspace
Attributes
raw_prefix[R]
Public Class Methods
new(prefix_tuple=[], raw_prefix='')
click to toggle source
# File lib/fdbsubspace.rb, line 32 def initialize(prefix_tuple=[], raw_prefix='') @raw_prefix = raw_prefix.dup.force_encoding('BINARY') + FDB::Tuple.pack(prefix_tuple) end
Public Instance Methods
[](name)
click to toggle source
# File lib/fdbsubspace.rb, line 37 def [](name) Subspace.new([name], @raw_prefix) end
as_foundationdb_key()
click to toggle source
# File lib/fdbsubspace.rb, line 63 def as_foundationdb_key key end
contains?(key)
click to toggle source
# File lib/fdbsubspace.rb, line 59 def contains?(key) key.start_with? @raw_prefix end
key()
click to toggle source
# File lib/fdbsubspace.rb, line 41 def key @raw_prefix end
pack(tuple)
click to toggle source
# File lib/fdbsubspace.rb, line 45 def pack(tuple) @raw_prefix + FDB::Tuple.pack(tuple) end
range(tuple=[])
click to toggle source
# File lib/fdbsubspace.rb, line 54 def range(tuple=[]) rng = FDB::Tuple.range(tuple) [@raw_prefix + rng[0], @raw_prefix + rng[1]] end
subspace(tuple)
click to toggle source
# File lib/fdbsubspace.rb, line 67 def subspace(tuple) Subspace.new(tuple, @raw_prefix) end
unpack(key)
click to toggle source
# File lib/fdbsubspace.rb, line 49 def unpack(key) raise ArgumentError, 'Cannot unpack key that is not in subspace.' if not contains? key FDB::Tuple.unpack(key[@raw_prefix.length..-1]) end