Module: Oxblood::Commands::HyperLogLog

Included in:
Oxblood::Commands
Defined in:
lib/oxblood/commands/hyper_log_log.rb

Instance Method Summary collapse

Instance Method Details

#pfadd(key, *elements) ⇒ Integer

Adds the specified elements to the specified HyperLogLog.

Parameters:

  • key (String)
  • elements (String, Array<String>)

Returns:

  • (Integer)

    1 if at least 1 HyperLogLog internal register was altered and 0 otherwise.

See Also:



12
13
14
# File 'lib/oxblood/commands/hyper_log_log.rb', line 12

def pfadd(key, *elements)
  run(*elements.unshift(:PFADD, key))
end

#pfcount(*keys) ⇒ Integer

Return the approximated cardinality of the set(s) observed by the HyperLogLog at key(s).

Parameters:

  • keys (String, Array<String>)

Returns:

  • (Integer)

    the approximated number of unique elements observed via #pfadd.

See Also:



24
25
26
# File 'lib/oxblood/commands/hyper_log_log.rb', line 24

def pfcount(*keys)
  run(*keys.unshift(:PFCOUNT))
end

#pfmerge(destkey, *sourcekeys) ⇒ String

Merge N different HyperLogLogs into a single one.

Parameters:

  • destkey (String)
  • sourcekeys (String, Array<String>)

Returns:

  • (String)

    ‘OK’

See Also:



35
36
37
# File 'lib/oxblood/commands/hyper_log_log.rb', line 35

def pfmerge(destkey, *sourcekeys)
  run(*sourcekeys.unshift(:PFMERGE, destkey))
end