Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Added to the API #6

Open
wants to merge 13 commits into
from

Conversation

Projects
None yet
2 participants
Contributor

natemueller commented Jul 7, 2012

I want to be able to merge together estimators and stick the result in memcache. Needed the following methods to do that:

HyperEstimator#merge!
HyperEstimator#_dump
HyperEstimator.load

I also changed HyperEstimator.estimate to take an array of estimators as well as a list

natemueller added some commits Jul 4, 2012

@natemueller natemueller Fixed estimator merging
Previously, if you passed in n estimators it would merge n[0] with
itself n-1 times.
812c29c
@natemueller natemueller Ruby 1.9 support
Tests still pass on 1.8
eb0c751
@natemueller natemueller Merge branch 'merge-fix' into nb-master
Conflicts:
	ext/hyperloglog.cpp
	spec/hyperloglog_spec.rb
548d297
@natemueller natemueller Merge branch 'builder-restore' into nb-master
Conflicts:
	spec/hyperloglog_spec.rb
fd3f130
@natemueller natemueller Fixed builds on Ubuntu 11.04 110eb1a
@natemueller natemueller Merge branch 'linux-builds' into nb-master 95d2d34
@natemueller natemueller Merge branch 'builder-restore' into nb-master 6848522
@natemueller natemueller HyperEstimator.estimate can take an array of estimators
You could do HyperEstimator.estimate(*estimators) but that will blow
the stack on long lists.
42495a2
@natemueller natemueller Added HyperEstimator#merge!
I want to pull a bunch of estimators out of the database,
merge them and cache the result
946c988
@natemueller natemueller Cleaned up warnings, build with -Werror 40a7871
@natemueller natemueller You can marshal and unmarshal HyperEstimators
My primary use case is stuffing these into memcache
518dba5
@natemueller natemueller Fixed linux builds 1214023
@natemueller natemueller Linux warning cleanup 2a4355b

@jnunemaker jnunemaker commented on the diff Nov 16, 2012

spec/hyperloglog_spec.rb
+
+ array_estimate = HyperEstimator.estimate([builder_a.estimator, builder_b.estimator])
+ array_estimate.should == estimate
+
+ estimator = builder_a.estimator
+ estimator.merge!(builder_b.estimator)
+ merged_estimate = HyperEstimator.estimate(estimator)
+ merged_estimate.should == estimate
+ end
+ end
+
+ it 'should marshal and load' do
+ builder = HyperBuilder.new(12)
+ 10.times { builder.offer(rand.to_s) }
+
+ se = 10 * (1.04 / Math.sqrt(2**12))
@jnunemaker

jnunemaker Nov 16, 2012

se variable isn't even used, is it?

@natemueller

natemueller Nov 16, 2012

Contributor

No, that looks like a leftover

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment