hyperloglog 0.3 → 0.3.1
raw patch · 7 files changed
+83/−30 lines, 7 filesdep ~generic-derivingdep ~lensdep ~semigroupoids
Dependency ranges changed: generic-deriving, lens, semigroupoids
Files
- .travis.yml +50/−13
- CHANGELOG.markdown +11/−0
- LICENSE +1/−1
- hyperloglog.cabal +5/−5
- src/Data/HyperLogLog.hs +2/−1
- src/Data/HyperLogLog/Config.hs +1/−4
- src/Data/HyperLogLog/Type.hs +13/−6
.travis.yml view
@@ -1,19 +1,59 @@-language: haskell-before_install:- # Uncomment whenever hackage is down.- # - mkdir -p ~/.cabal && cp travis/config ~/.cabal/config && cabal update- - cabal update+# NB: don't set `language: haskell` here - # Try installing some of the build-deps with apt-get for speed.- - travis/cabal-apt-install $mode+# See also https://github.com/hvr/multi-ghc-travis for more information+env:+ # we have to use CABALVER=1.16 for GHC<7.6 as well, as there's+ # no package for earlier cabal versions in the PPA+ - GHCVER=7.4.2 CABALVER=1.16+ - GHCVER=7.6.3 CABALVER=1.16+ - GHCVER=7.8.4 CABALVER=1.18+ - GHCVER=7.10.1 CABALVER=1.22+ - GHCVER=head CABALVER=1.22 +matrix:+ allow_failures:+ - env: GHCVER=head CABALVER=1.22++# Note: the distinction between `before_install` and `install` is not+# important.+before_install:+ - travis_retry sudo add-apt-repository -y ppa:hvr/ghc+ - travis_retry sudo apt-get update+ - travis_retry sudo apt-get install cabal-install-$CABALVER ghc-$GHCVER+ - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH+ - cabal --version+ install:- - cabal configure -flib-Werror $mode- - cabal build+ - travis_retry cabal update+ - cabal install --only-dependencies+ - travis_retry sudo apt-get -q -y install hlint || cabal install hlint +# Here starts the actual work to be performed for the package under+# test; any command which exits with a non-zero exit code causes the+# build to fail. script:- - $script && hlint src --cpp-define HLINT+ # -v2 provides useful information for debugging+ - cabal configure -v2 --enable-tests + # this builds all libraries and executables+ # (including tests/benchmarks)+ - cabal build+ - cabal test++ # tests that a source-distribution can be generated+ - cabal sdist+ - hlint src --cpp-define HLINT++ # check that the generated source-distribution can be built & installed+ - export SRC_TGZ=$(cabal info . | awk '{print $2 ".tar.gz";exit}') ;+ cd dist/;+ if [ -f "$SRC_TGZ" ]; then+ cabal install --force-reinstalls "$SRC_TGZ";+ else+ echo "expected '$SRC_TGZ' not found";+ exit 1;+ fi+ notifications: irc: channels:@@ -21,6 +61,3 @@ skip_join: true template: - "\x0313hyperloglog\x03/\x0306%{branch}\x03 \x0314%{commit}\x03 %{build_url} %{message}"--env:- - mode="--enable-tests" script="cabal test --show-details=always"
CHANGELOG.markdown view
@@ -1,3 +1,14 @@+0.3.1+-----+* Added `insertHash`. This enables users of the 0.2+ era version of `hyperloglog` to manually pick the+ hash used and load their old data.+* Builds warning-free on GHC 7.10++0.3.0.1+---+* Constraint bumps for `lens` and `generic-deriving`+ 0.3 --- * Switched to `SipHash`, so the package actually works.
LICENSE view
@@ -1,4 +1,4 @@-Copyright 2013 Edward Kmett+Copyright 2013-2015 Edward Kmett All rights reserved.
hyperloglog.cabal view
@@ -1,6 +1,6 @@ name: hyperloglog category: Numeric-version: 0.3+version: 0.3.1 license: BSD3 cabal-version: >= 1.8 license-file: LICENSE@@ -9,9 +9,9 @@ stability: provisional homepage: http://github.com/analytics/hyperloglog bug-reports: http://github.com/analytics/hyperloglog/issues-copyright: Copyright (C) 2013 Edward A. Kmett+copyright: Copyright (C) 2013-2015 Edward A. Kmett build-type: Custom-tested-with: GHC == 7.4.1, GHC == 7.6.1+tested-with: GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.0.20150307 synopsis: An approximate streaming (constant space) unique object counter description: This package provides an approximate streaming (constant space) unique object counter.@@ -58,10 +58,10 @@ comonad >= 4 && < 5, deepseq >= 1.3 && < 1.5, distributive >= 0.3 && < 1,- generic-deriving >= 1.4 && < 1.7,+ generic-deriving >= 1.4 && < 1.8, hashable >= 1.1.2.3 && < 1.3, hashable-extras >= 0.1 && < 1,- lens >= 4 && < 4.5,+ lens >= 4 && < 5, reflection >= 1.3 && < 2, semigroupoids >= 4 && < 5, semigroups >= 0.8.4 && < 1,
src/Data/HyperLogLog.hs view
@@ -1,6 +1,6 @@ -------------------------------------------------------------------- -- |--- Copyright : (c) Edward Kmett 2013+-- Copyright : (c) Edward Kmett 2013-2015 -- License : BSD3 -- Maintainer: Edward Kmett <ekmett@gmail.com> -- Stability : experimental@@ -17,6 +17,7 @@ , size , intersectionSize , insert+ , insertHash , cast -- * Config , Config
src/Data/HyperLogLog/Config.hs view
@@ -1,15 +1,12 @@ {-# LANGUAGE CPP #-}-{-# LANGUAGE BangPatterns #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE NoMonomorphismRestriction #-} {-# LANGUAGE EmptyDataDecls #-} {-# LANGUAGE RankNTypes #-}-{-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE TypeFamilies #-} {-# OPTIONS_GHC -fno-cse #-}@@ -34,7 +31,7 @@ {-# OPTIONS_GHC -fno-warn-missing-signatures #-} -------------------------------------------------------------------- -- |--- Copyright : (c) Edward Kmett 2013+-- Copyright : (c) Edward Kmett 2013-2015 -- License : BSD3 -- Maintainer: Edward Kmett <ekmett@gmail.com> -- Stability : experimental
src/Data/HyperLogLog/Type.hs view
@@ -7,7 +7,6 @@ {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE NoMonomorphismRestriction #-} {-# LANGUAGE RankNTypes #-}-{-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-}@@ -26,7 +25,7 @@ -------------------------------------------------------------------- -- |--- Copyright : (c) Edward Kmett 2013+-- Copyright : (c) Edward Kmett 2013-2015 -- License : BSD3 -- Maintainer: Edward Kmett <ekmett@gmail.com> -- Stability : experimental@@ -45,11 +44,15 @@ , HasHyperLogLog(..) , size , insert+ , insertHash , intersectionSize , cast ) where +#if __GLASGOW_HASKELL__ < 710 import Control.Applicative+#endif+ import Control.Lens import Control.Monad import Crypto.MAC.SipHash@@ -135,21 +138,25 @@ sipKey :: SipKey sipKey = SipKey 4 7 -siphash :: (Serial a) => a -> Word64+siphash :: Serial a => a -> Word64 siphash a = h where !bs = runPutS (serialize a) (SipHash !h) = hash sipKey bs {-# INLINE siphash #-} insert :: (ReifiesConfig s, Serial a) => a -> HyperLogLog s -> HyperLogLog s-insert a m@(HyperLogLog v) = HyperLogLog $ V.modify (\x -> do+insert = insertHash . w32 . siphash+{-# INLINE insert #-}++-- | Insert a value that has already been hashed by whatever user defined hash function you want.+insertHash :: ReifiesConfig s => Word32 -> HyperLogLog s -> HyperLogLog s+insertHash h m@(HyperLogLog v) = HyperLogLog $ V.modify (\x -> do old <- MV.read x bk when (rnk > old) $ MV.write x bk rnk ) v where- !h = w32 (siphash a) !bk = calcBucket m h !rnk = calcRank m h-{-# INLINE insert #-}+{-# INLINE insertHash #-} -- | Approximate size of our set size :: ReifiesConfig p => HyperLogLog p -> Approximate Int64