Skip to content

Instantly share code, notes, and snippets.

@mpenet
Created November 8, 2019 12:24
Show Gist options
  • Save mpenet/4c2e5ecd95b90aaf426e9113e810d9fc to your computer and use it in GitHub Desktop.
Save mpenet/4c2e5ecd95b90aaf426e9113e810d9fc to your computer and use it in GitHub Desktop.
(defn deterministic-sampler
[rate]
(let [bound (Integer/divideUnsigned -1 rate)] ;; -1 as int is 0xffffffff
(fn [s]
(pos? (Integer/compareUnsigned bound (hash s))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment