Sha256: ce2f441c1262d0c99e409b417f6d44afe8328a628b9abd1525ff393a27bdbba7
Contents?: true
Size: 1022 Bytes
Versions: 1
Compression:
Stored size: 1022 Bytes
Contents
require "minuteman/keys_methods" require "minuteman/bit_operations/data" class Minuteman module BitOperations # Public: The class to handle operations with datasets # # redis: The Redis connection # type: The operation type # data: The data to be permuted # source_key: The original key to do the operation # class WithData < Struct.new(:redis, :type, :data, :source_key) include KeysMethods def call normalized_data = Array(data) key = destination_key("data-#{type}", normalized_data) command = case type when "AND" then :select when "MINUS" then :reject end intersected_data = normalized_data.send(command) do |id| redis.getbit(source_key, id) == 1 end if !redis.exists(key) intersected_data.each { |id| redis.setbit(key, id, 1) } end Data.new(redis, key, intersected_data) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
minuteman-1.0.0.pre | lib/minuteman/bit_operations/with_data.rb |