From 374fc9deff04c12654059d71bf2c9d3a993a10d8 Mon Sep 17 00:00:00 2001 From: Todd Gruben Date: Wed, 23 Jan 2019 07:18:39 -0600 Subject: [PATCH 1/7] added convience function to calculate size of bitmap in bytes completed test converage --- roaring/roaring.go | 12 ++++++++++++ roaring/roaring_test.go | 23 +++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/roaring/roaring.go b/roaring/roaring.go index 9c45c044b..035f17ac7 100644 --- a/roaring/roaring.go +++ b/roaring/roaring.go @@ -232,6 +232,18 @@ func (b *Bitmap) Count() (n uint64) { return b.Containers.Count() } +// Size returns the number of bytes required for the bitmap. +func (b *Bitmap) Size() (numbytes int) { + + citer, _ := b.Containers.Iterator(0) + for citer.Next() { + _, c := citer.Value() + numbytes += c.size() + + } + return +} + // CountRange returns the number of bits set between [start, end). func (b *Bitmap) CountRange(start, end uint64) (n uint64) { if b.Containers.Size() == 0 { diff --git a/roaring/roaring_test.go b/roaring/roaring_test.go index 5da9fc38c..e258dadbd 100644 --- a/roaring/roaring_test.go +++ b/roaring/roaring_test.go @@ -37,6 +37,29 @@ func TestContainerCount(t *testing.T) { t.Fatalf("Count != CountRange\n") } } +func TestSize(t *testing.T) { + //array + a := roaring.NewFileBitmap(0, 65535, 131072) + if a.Size() != 6 { + t.Fatalf("Size in bytes incorrect \n") + } + + //bitmap + b := roaring.NewFileBitmap() + for i:=uint64(0);i<2048;i++{ + b.DirectAdd(i) + } + + if b.Size() != 4096 { + t.Fatalf("Size in bytes incorrect \n") + } + //convert to rle + b.Optimize() + //rle + if b.Size() != 6 { + t.Fatalf("Size in bytes incorrect \n") + } +} func TestCountRange(t *testing.T) { tests := []struct { From 15494becac52400bde520eeeb29210b26eba6439 Mon Sep 17 00:00:00 2001 From: Todd Gruben Date: Wed, 23 Jan 2019 13:35:27 -0600 Subject: [PATCH 2/7] formatting --- roaring/roaring_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roaring/roaring_test.go b/roaring/roaring_test.go index e258dadbd..52353c692 100644 --- a/roaring/roaring_test.go +++ b/roaring/roaring_test.go @@ -46,14 +46,14 @@ func TestSize(t *testing.T) { //bitmap b := roaring.NewFileBitmap() - for i:=uint64(0);i<2048;i++{ + for i := uint64(0); i < 2048; i++ { b.DirectAdd(i) } if b.Size() != 4096 { t.Fatalf("Size in bytes incorrect \n") } - //convert to rle + //convert to rle b.Optimize() //rle if b.Size() != 6 { From 790123410f2f49ef8710589ca704926d83201153 Mon Sep 17 00:00:00 2001 From: Todd Gruben Date: Wed, 23 Jan 2019 13:50:01 -0600 Subject: [PATCH 3/7] metalinter fix --- roaring/roaring.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/roaring/roaring.go b/roaring/roaring.go index 035f17ac7..2fe76e8ef 100644 --- a/roaring/roaring.go +++ b/roaring/roaring.go @@ -233,15 +233,15 @@ func (b *Bitmap) Count() (n uint64) { } // Size returns the number of bytes required for the bitmap. -func (b *Bitmap) Size() (numbytes int) { - +func (b *Bitmap) Size() int { + numbytes := 0 citer, _ := b.Containers.Iterator(0) for citer.Next() { _, c := citer.Value() numbytes += c.size() } - return + return numbytes } // CountRange returns the number of bits set between [start, end). From cb087499676c16b74e1acdf5b2f9bf5b27e49811 Mon Sep 17 00:00:00 2001 From: Todd Gruben Date: Wed, 23 Jan 2019 16:47:59 -0600 Subject: [PATCH 4/7] correct bitmap test --- roaring/roaring_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roaring/roaring_test.go b/roaring/roaring_test.go index 52353c692..c6f7b9693 100644 --- a/roaring/roaring_test.go +++ b/roaring/roaring_test.go @@ -46,11 +46,11 @@ func TestSize(t *testing.T) { //bitmap b := roaring.NewFileBitmap() - for i := uint64(0); i < 2048; i++ { + for i := uint64(0); i < 4096; i++ { b.DirectAdd(i) } - if b.Size() != 4096 { + if b.Size() != 8192 { t.Fatalf("Size in bytes incorrect \n") } //convert to rle From c2ca00ebe865d8d66ec414e81a7d5462d975e7e7 Mon Sep 17 00:00:00 2001 From: Todd Gruben Date: Wed, 23 Jan 2019 17:05:40 -0600 Subject: [PATCH 5/7] force bitmap creation on test; for real this time --- roaring/roaring_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roaring/roaring_test.go b/roaring/roaring_test.go index c6f7b9693..b165042a9 100644 --- a/roaring/roaring_test.go +++ b/roaring/roaring_test.go @@ -46,7 +46,7 @@ func TestSize(t *testing.T) { //bitmap b := roaring.NewFileBitmap() - for i := uint64(0); i < 4096; i++ { + for i := uint64(0); i <= 4096; i++ { b.DirectAdd(i) } From 8062fc6ea7aff59e9fd5475a28de8e8889264b5f Mon Sep 17 00:00:00 2001 From: WaaX Date: Tue, 18 Dec 2018 17:07:25 -0500 Subject: [PATCH 6/7] Replaced seed with seeds Cluster config referred to seed but the server now expects seeds --- docs/configuration.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 140258437..dc09aa401 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -366,7 +366,7 @@ A three node cluster running on different hosts could be minimally configured as [gossip] port = 12000 - seed = "node0.pilosa.com:12000" + seeds = "node0.pilosa.com:12000" [cluster] replicas = 1 @@ -379,7 +379,7 @@ A three node cluster running on different hosts could be minimally configured as [gossip] port = 12000 - seed = "node0.pilosa.com:12000" + seeds = "node0.pilosa.com:12000" [cluster] replicas = 1 @@ -392,7 +392,7 @@ A three node cluster running on different hosts could be minimally configured as [gossip] port = 12000 - seed = "node0.pilosa.com:12000" + seeds = "node0.pilosa.com:12000" [cluster] replicas = 1 @@ -410,7 +410,7 @@ The same cluster which uses HTTPS instead of HTTP can be configured as follows. [gossip] port = 12000 - seed = "node0.pilosa.com:12000" + seeds = "node0.pilosa.com:12000" key = "/home/pilosa/private/gossip.key32" [cluster] @@ -428,7 +428,7 @@ The same cluster which uses HTTPS instead of HTTP can be configured as follows. [gossip] port = 12000 - seed = "node0.pilosa.com:12000" + seeds = "node0.pilosa.com:12000" key = "/home/pilosa/private/gossip.key32" [cluster] @@ -446,7 +446,7 @@ The same cluster which uses HTTPS instead of HTTP can be configured as follows. [gossip] port = 12000 - seed = "node0.pilosa.com:12000" + seeds = "node0.pilosa.com:12000" key = "/home/pilosa/private/gossip.key32" [cluster] @@ -468,7 +468,7 @@ You can run a cluster on the same host using the configuration above with a few [gossip] port = 12000 - seed = "localhost:12000" + seeds = "localhost:12000" key = "/home/pilosa/private/gossip.key32" [cluster] @@ -486,7 +486,7 @@ You can run a cluster on the same host using the configuration above with a few [gossip] port = 12001 - seed = "localhost:12000" + seeds = "localhost:12000" key = "/home/pilosa/private/gossip.key32" [cluster] @@ -504,7 +504,7 @@ You can run a cluster on the same host using the configuration above with a few [gossip] port = 12002 - seed = "localhost:12000" + seeds = "localhost:12000" key = "/home/pilosa/private/gossip.key32" [cluster] From fa975411b73080d1b4216430533bd0520bea7257 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Thu, 24 Jan 2019 09:20:01 -0600 Subject: [PATCH 7/7] change seeds examples from string to list --- docs/configuration.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index dc09aa401..a8dafa91d 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -366,7 +366,7 @@ A three node cluster running on different hosts could be minimally configured as [gossip] port = 12000 - seeds = "node0.pilosa.com:12000" + seeds = ["node0.pilosa.com:12000"] [cluster] replicas = 1 @@ -379,7 +379,7 @@ A three node cluster running on different hosts could be minimally configured as [gossip] port = 12000 - seeds = "node0.pilosa.com:12000" + seeds = ["node0.pilosa.com:12000"] [cluster] replicas = 1 @@ -392,7 +392,7 @@ A three node cluster running on different hosts could be minimally configured as [gossip] port = 12000 - seeds = "node0.pilosa.com:12000" + seeds = ["node0.pilosa.com:12000"] [cluster] replicas = 1 @@ -410,7 +410,7 @@ The same cluster which uses HTTPS instead of HTTP can be configured as follows. [gossip] port = 12000 - seeds = "node0.pilosa.com:12000" + seeds = ["node0.pilosa.com:12000"] key = "/home/pilosa/private/gossip.key32" [cluster] @@ -428,7 +428,7 @@ The same cluster which uses HTTPS instead of HTTP can be configured as follows. [gossip] port = 12000 - seeds = "node0.pilosa.com:12000" + seeds = ["node0.pilosa.com:12000"] key = "/home/pilosa/private/gossip.key32" [cluster] @@ -446,7 +446,7 @@ The same cluster which uses HTTPS instead of HTTP can be configured as follows. [gossip] port = 12000 - seeds = "node0.pilosa.com:12000" + seeds = ["node0.pilosa.com:12000"] key = "/home/pilosa/private/gossip.key32" [cluster] @@ -468,7 +468,7 @@ You can run a cluster on the same host using the configuration above with a few [gossip] port = 12000 - seeds = "localhost:12000" + seeds = ["localhost:12000"] key = "/home/pilosa/private/gossip.key32" [cluster] @@ -486,7 +486,7 @@ You can run a cluster on the same host using the configuration above with a few [gossip] port = 12001 - seeds = "localhost:12000" + seeds = ["localhost:12000"] key = "/home/pilosa/private/gossip.key32" [cluster] @@ -504,7 +504,7 @@ You can run a cluster on the same host using the configuration above with a few [gossip] port = 12002 - seeds = "localhost:12000" + seeds = ["localhost:12000"] key = "/home/pilosa/private/gossip.key32" [cluster]