Merge branch 'master' into advertise-addr

This commit is contained in:
Travis Turner 2019-01-24 17:55:51 -06:00 committed by GitHub
commit cd7d4ecc22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 9 deletions

View file

@ -401,7 +401,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
@ -414,7 +414,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
@ -427,7 +427,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
@ -445,7 +445,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]
@ -463,7 +463,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]
@ -481,7 +481,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]
@ -503,7 +503,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]
@ -521,7 +521,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]
@ -539,7 +539,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]

View file

@ -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() int {
numbytes := 0
citer, _ := b.Containers.Iterator(0)
for citer.Next() {
_, c := citer.Value()
numbytes += c.size()
}
return numbytes
}
// CountRange returns the number of bits set between [start, end).
func (b *Bitmap) CountRange(start, end uint64) (n uint64) {
if b.Containers.Size() == 0 {

View file

@ -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 <= 4096; i++ {
b.DirectAdd(i)
}
if b.Size() != 8192 {
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 {