Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

mdlayher/rb-hlld

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 

Repository files navigation

rb-hlld

Ruby class for interacting with a hlld server (https://github.com/armon/hlld). MIT Licensed.

Example

All commands accepted by hlld are implemented in rb-hlld. Here is a basic example script.

# rb-hlld - Example basic usage script
require_relative 'lib/HlldClient.rb'

# Establish a connection to a local hlld with client
hlld = HlldClient.new

# Create a HyperLogLog set
unless hlld.create "ruby"
	puts "example: failed to create HLL set"
	exit
end

# Create a set object to use more concise, object-oriented interface
hll = hlld.get "ruby"

# Add some numbers into set
(1..500).each do |n|
	hlld.set("ruby", n)
end

# Add some numbers into set using HllSet interface
# Either method may be used for all functions which accept a set name as first parameter
(501..1000).each do |n|
	hll.set n
end

# Bulk add an array of values into set
hll.bulk(["foo", "bar", "baz"])
hll.bulk((1001..5000).to_a)

# Check the approximate cardinality of set
printf("%s: ~%d\n", hll.name, hll.count)

# Drop set, disconnect
hll.drop

About

Ruby class for interacting with a hlld server. MIT Licensed.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages