New Upstream Snapshot - golang-github-retailnext-hllpp

Ready changes

Summary

Merged new upstream version: 1.0.0+git20201105.fa21384 (was: 1.0.0+git20170901.6e8b6d3).

Resulting package

Built on 2022-10-25T05:17 (took 8m31s)

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-snapshots golang-github-retailnext-hllpp-dev

Lintian Result

Diff

diff --git a/.travis.yml b/.travis.yml
index 77be6e0..30ec874 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,5 +1,14 @@
+arch:
+  - amd64
+  - ppc64le
 language: go
 
 go:
   - "1.4"
   - tip
+jobs:
+ exclude:
+  - go: "1.4"
+    arch: amd64
+  - go: "1.4"
+    arch: ppc64le
diff --git a/debian/changelog b/debian/changelog
index e1ab351..1705d75 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,9 +1,10 @@
-golang-github-retailnext-hllpp (1.0.0+git20170901.6e8b6d3-4) UNRELEASED; urgency=medium
+golang-github-retailnext-hllpp (1.0.0+git20201105.fa21384-1) UNRELEASED; urgency=medium
 
   * Remove constraints unnecessary since stretch:
     + Build-Depends: Drop versioned constraint on dh-golang.
+  * New upstream snapshot.
 
- -- Debian Janitor <janitor@jelmer.uk>  Tue, 22 Jun 2021 14:20:03 -0000
+ -- Debian Janitor <janitor@jelmer.uk>  Tue, 25 Oct 2022 05:11:17 -0000
 
 golang-github-retailnext-hllpp (1.0.0+git20170901.6e8b6d3-3) unstable; urgency=medium
 
diff --git a/hllpp.go b/hllpp.go
index 2608552..e1334dd 100644
--- a/hllpp.go
+++ b/hllpp.go
@@ -1,4 +1,4 @@
-// Copyright (c) 2015, RetailNext, Inc.
+// Copyright (c) 2018, RetailNext, Inc.
 // All rights reserved.
 
 // hllpp implements the HyperLogLog++ cardinality estimator as specified
@@ -21,7 +21,7 @@ type HLLPP struct {
 	data []byte
 
 	// accumulates unsorted values in sparse mode
-	tmpSet uint32Slice
+	tmpSet []uint32
 
 	sparse       bool
 	sparseLength uint32
diff --git a/sparse.go b/sparse.go
index 31e9f5a..9b21adf 100644
--- a/sparse.go
+++ b/sparse.go
@@ -1,4 +1,4 @@
-// Copyright (c) 2015, RetailNext, Inc.
+// Copyright (c) 2018, RetailNext, Inc.
 // All rights reserved.
 
 package hllpp
@@ -8,20 +8,6 @@ import (
 	"sort"
 )
 
-type uint32Slice []uint32
-
-func (s uint32Slice) Len() int {
-	return len(s)
-}
-
-func (s uint32Slice) Less(i, j int) bool {
-	return s[i] < s[j]
-}
-
-func (s uint32Slice) Swap(i, j int) {
-	s[i], s[j] = s[j], s[i]
-}
-
 type sparseReader struct {
 	data    []byte
 	idx     int
@@ -74,7 +60,7 @@ type sparseWriter struct {
 	currIdx    uint32
 	currRho    uint8
 
-	varIntBuf []byte
+	varIntBuf [binary.MaxVarintLen32]byte
 	length    uint32
 }
 
@@ -101,7 +87,7 @@ func (writer *sparseWriter) Append(k, idx uint32, rho uint8) {
 }
 
 func (writer *sparseWriter) commit() {
-	n := binary.PutUvarint(writer.varIntBuf, uint64(writer.currVal-writer.lastVal))
+	n := binary.PutUvarint(writer.varIntBuf[:], uint64(writer.currVal-writer.lastVal))
 	writer.data = append(writer.data, writer.varIntBuf[:n]...)
 	writer.lastVal = writer.currVal
 	writer.length++
@@ -123,9 +109,7 @@ func (writer *sparseWriter) Len() uint32 {
 }
 
 func newSparseWriter() *sparseWriter {
-	return &sparseWriter{
-		varIntBuf: make([]byte, binary.MaxVarintLen32),
-	}
+	return &sparseWriter{}
 }
 
 func (h *HLLPP) flushTmpSet() {
@@ -133,7 +117,11 @@ func (h *HLLPP) flushTmpSet() {
 		return
 	}
 
-	sort.Sort(h.tmpSet)
+	sort.Slice(h.tmpSet, func(i, j int) bool {
+		iIdx, _ := h.decodeHash(h.tmpSet[i], h.pp)
+		jIdx, _ := h.decodeHash(h.tmpSet[j], h.pp)
+		return iIdx < jIdx
+	})
 	h.mergeSparse(h.tmpSet)
 	h.tmpSet = nil
 }
diff --git a/sparse_test.go b/sparse_test.go
index 9f59d42..7958266 100644
--- a/sparse_test.go
+++ b/sparse_test.go
@@ -1,10 +1,12 @@
-// Copyright (c) 2015, RetailNext, Inc.
+// Copyright (c) 2018, RetailNext, Inc.
 // All rights reserved.
 
 package hllpp
 
 import (
+	"math/rand"
 	"testing"
+	"time"
 )
 
 func TestSparseReaderWriter(t *testing.T) {
@@ -69,3 +71,26 @@ func TestSparseReaderWriter(t *testing.T) {
 		t.Errorf("should be done")
 	}
 }
+
+func TestSparseMerge(t *testing.T) {
+	gen := rand.New(rand.NewSource(time.Now().UnixNano()))
+
+	for i := 0; i < 1000; i++ {
+		v1 := intToBytes(gen.Uint64())
+		v2 := intToBytes(gen.Uint64())
+
+		h := New()
+		h.Add(v1)
+		h.Add(v2)
+
+		other := New()
+		other.Add(v1)
+
+		h.flushTmpSet()
+		h.Merge(other)
+
+		if h.Count() != 2 {
+			t.Fatalf("iter %d got %d", i, h.Count())
+		}
+	}
+}

Debdiff

File lists identical (after any substitutions)

No differences were encountered in the control files

More details

Full run details