Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes, changes to FrozenBitmap API (renaming) #406

Merged
merged 4 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ steps:
commands:
- go get -t
- go test
- go test -race -run TestConcurrent*
- go build -tags appengine
- go test -tags appengine
- GOARCH=386 go build
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/basictests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
uses: actions/checkout@v3
- name: Test
run: |
go test -race -run TestConcurrent*
go build -tags appengine
go test -tags appengine
go test -v
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/bigendiantests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.13.x, 1.14.x]
go-version: [1.14.x]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/macostests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
uses: actions/checkout@v3
- name: Test
run: |
go test -race -run TestConcurrent*
go build -tags appengine
go test -tags appengine
go test -v
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/windowstests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
uses: actions/checkout@v3
- name: Test
run: |
go test -race -run TestConcurrent*
go build -tags appengine
go test -tags appengine
go test -v
Expand Down
107 changes: 0 additions & 107 deletions Makefile

This file was deleted.

7 changes: 4 additions & 3 deletions aggregation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ package roaring

import (
"fmt"
"github.com/stretchr/testify/assert"
"sort"
"testing"

"github.com/stretchr/testify/assert"
)

func testAggregations(t *testing.T,
Expand Down Expand Up @@ -288,9 +289,9 @@ func TestIssue330(t *testing.T) {
bitmap := BitmapOf(v...)
bitmap.RunOptimize()
bitmaps = append(bitmaps, bitmap)
array_result := bitmap.ToArray()
arrayResult := bitmap.ToArray()
sort.Sort(uints(v))
assert.Equal(t, array_result, v)
assert.Equal(t, arrayResult, v)
}
assert.Equal(t, FastAnd(bitmaps[0], bitmaps[1]).GetCardinality(), uint64(0))
assert.Equal(t, FastAnd(bitmaps[0], bitmaps[2]).GetCardinality(), uint64(0))
Expand Down
29 changes: 15 additions & 14 deletions benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package roaring
import (
"bytes"
"fmt"
"github.com/stretchr/testify/require"
"math/rand"
"testing"

"github.com/stretchr/testify/require"

"github.com/bits-and-blooms/bitset"
)

Expand All @@ -22,7 +23,7 @@ func BenchmarkIteratorAlloc(b *testing.B) {
bm.Add(v)
}
i := IntIterator{}
expected_cardinality := bm.GetCardinality()
expectedCardinality := bm.GetCardinality()
counter := uint64(0)
b.Run("simple iteration with alloc", func(b *testing.B) {
for n := 0; n < b.N; n++ {
Expand All @@ -35,8 +36,8 @@ func BenchmarkIteratorAlloc(b *testing.B) {
}
b.StopTimer()
})
if counter != expected_cardinality {
b.Fatalf("Cardinalities don't match: %d, %d", counter, expected_cardinality)
if counter != expectedCardinality {
b.Fatalf("Cardinalities don't match: %d, %d", counter, expectedCardinality)
}
b.Run("simple iteration", func(b *testing.B) {
for n := 0; n < b.N; n++ {
Expand All @@ -49,8 +50,8 @@ func BenchmarkIteratorAlloc(b *testing.B) {
}
b.StopTimer()
})
if counter != expected_cardinality {
b.Fatalf("Cardinalities don't match: %d, %d", counter, expected_cardinality)
if counter != expectedCardinality {
b.Fatalf("Cardinalities don't match: %d, %d", counter, expectedCardinality)
}
b.Run("reverse iteration with alloc", func(b *testing.B) {
for n := 0; n < b.N; n++ {
Expand All @@ -63,8 +64,8 @@ func BenchmarkIteratorAlloc(b *testing.B) {
}
b.StopTimer()
})
if counter != expected_cardinality {
b.Fatalf("Cardinalities don't match: %d, %d", counter, expected_cardinality)
if counter != expectedCardinality {
b.Fatalf("Cardinalities don't match: %d, %d", counter, expectedCardinality)
}
ir := IntReverseIterator{}

Expand All @@ -79,8 +80,8 @@ func BenchmarkIteratorAlloc(b *testing.B) {
}
b.StopTimer()
})
if counter != expected_cardinality {
b.Fatalf("Cardinalities don't match: %d, %d", counter, expected_cardinality)
if counter != expectedCardinality {
b.Fatalf("Cardinalities don't match: %d, %d", counter, expectedCardinality)
}

b.Run("many iteration with alloc", func(b *testing.B) {
Expand All @@ -94,8 +95,8 @@ func BenchmarkIteratorAlloc(b *testing.B) {
}
b.StopTimer()
})
if counter != expected_cardinality {
b.Fatalf("Cardinalities don't match: %d, %d", counter, expected_cardinality)
if counter != expectedCardinality {
b.Fatalf("Cardinalities don't match: %d, %d", counter, expectedCardinality)
}
im := ManyIntIterator{}
buf := make([]uint32, 1024)
Expand All @@ -110,8 +111,8 @@ func BenchmarkIteratorAlloc(b *testing.B) {
}
b.StopTimer()
})
if counter != expected_cardinality {
b.Fatalf("Cardinalities don't match: %d, %d", counter, expected_cardinality)
if counter != expectedCardinality {
b.Fatalf("Cardinalities don't match: %d, %d", counter, expectedCardinality)
}
}

Expand Down
24 changes: 12 additions & 12 deletions roaring.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,10 @@ type IntIterator = intIterator
// Initialize configures the existing iterator so that it can iterate through the values of
// the provided bitmap.
// The iteration results are undefined if the bitmap is modified (e.g., with Add or Remove).
func (p *intIterator) Initialize(a *Bitmap) {
p.pos = 0
p.highlowcontainer = &a.highlowcontainer
p.init()
func (ii *intIterator) Initialize(a *Bitmap) {
ii.pos = 0
ii.highlowcontainer = &a.highlowcontainer
ii.init()
}

type intReverseIterator struct {
Expand Down Expand Up @@ -438,10 +438,10 @@ type IntReverseIterator = intReverseIterator
// Initialize configures the existing iterator so that it can iterate through the values of
// the provided bitmap.
// The iteration results are undefined if the bitmap is modified (e.g., with Add or Remove).
func (p *intReverseIterator) Initialize(a *Bitmap) {
p.highlowcontainer = &a.highlowcontainer
p.pos = a.highlowcontainer.size() - 1
p.init()
func (ii *intReverseIterator) Initialize(a *Bitmap) {
ii.highlowcontainer = &a.highlowcontainer
ii.pos = a.highlowcontainer.size() - 1
ii.init()
}

// ManyIntIterable allows you to iterate over the values in a Bitmap
Expand Down Expand Up @@ -525,10 +525,10 @@ type ManyIntIterator = manyIntIterator
// Initialize configures the existing iterator so that it can iterate through the values of
// the provided bitmap.
// The iteration results are undefined if the bitmap is modified (e.g., with Add or Remove).
func (p *manyIntIterator) Initialize(a *Bitmap) {
p.pos = 0
p.highlowcontainer = &a.highlowcontainer
p.init()
func (ii *manyIntIterator) Initialize(a *Bitmap) {
ii.pos = 0
ii.highlowcontainer = &a.highlowcontainer
ii.init()
}

// String creates a string representation of the Bitmap
Expand Down
1 change: 0 additions & 1 deletion roaring64/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ help:
all: help
test:
go test
go test -race -run TestConcurrent*
# Format the source code
format:
@find ./ -type f -name "*.go" -exec gofmt -w {} \;
Expand Down
2 changes: 2 additions & 0 deletions roaring64/bsi64.go
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,7 @@ func (b *BSI) IncrementAll() {
b.Increment(b.GetExistenceBitmap())
}

// Equals - Check for semantic equality of two BSIs.
func (b *BSI) Equals(other *BSI) bool {
if !b.eBM.Equals(&other.eBM) {
return false
Expand All @@ -902,6 +903,7 @@ func (b *BSI) Equals(other *BSI) bool {
return true
}

// GetSizeInBytes - the size in bytes of the data structure
func (b *BSI) GetSizeInBytes() int {
size := b.eBM.GetSizeInBytes()
for _, bm := range b.bA {
Expand Down
13 changes: 7 additions & 6 deletions roaring64/fastaggregation64_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ package roaring64

import (
"github.com/stretchr/testify/assert"
"testing"
"sort"
"testing"
)

func TestFastAggregationsAdvanced_run(t *testing.T) {
Expand Down Expand Up @@ -38,6 +38,7 @@ func TestFastAggregationsAdvanced_run(t *testing.T) {
assert.True(t, FastOr(rb1, rb2, rb3).Equals(rb1))
assert.True(t, FastAnd(rb1, rb2, rb3).Equals(bigand))
}

type uints []uint64

func (u uints) Len() int { return len(u) }
Expand All @@ -53,16 +54,16 @@ func TestIssue330_64bits(t *testing.T) {
{1332290, 1447737, 1549291, 1187244, 1598129, 1579851, 1424171, 1538999, 1445358, 1586739, 1575050, 1437657, 1366343, 1062799, 1421550, 1460317, 1474875, 1060737, 1330773, 1447797, 1348633, 1559437, 1556214, 1187305, 1187234, 1187240, 1464660, 1567794, 1187260, 1260646, 1311938, 1573195, 1318525, 1484524, 1456152, 1087954, 1556007, 1187265, 1460920, 1485316, 1447849, 1447744, 1474001, 1537891, 1478211, 1313292, 1488405, 1187239, 1378814, 1343620, 1500498, 1567809, 1435838, 1506575, 1368282, 1447441, 1598101, 1067076, 1572997, 1598102, 1332697, 1324653, 1561437, 1187290, 1059945, 1187278, 1457187, 1430003, 1450643, 1447436, 1260650, 1473393, 1187247, 1087323, 1324967, 1187291, 1480771, 1472729, 1555881, 1187253, 1456481, 1452672, 1447435, 1378603, 1574771, 1187235, 1417857, 1568706, 1576739, 1534662, 1410189, 1587745, 1473791, 1187308, 1447730, 1328158, 1409164, 1506591, 1500147, 1433961, 1483709, 1187227, 1456479, 1562595, 1314333, 1187281, 1598012, 1415200, 1447791, 1371379, 1598019, 1435836, 1457188, 1457351, 1187248, 1417111, 1187289, 1187252, 1187257, 1316665, 1473464, 1187263, 1447732, 1520371, 1525651, 1598177, 1406947, 1465787, 1524659, 1324213, 1418439, 1575816, 1522696, 1187286, 1497821, 1333179, 1187282, 1335988, 1548952, 1556066, 1314993, 1187276, 1420503, 1187301, 1456468, 1423939, 1598089, 1504357, 1343247, 1437659, 1525768, 1539279, 1307385, 1187275, 1524305, 1332938, 1516498, 1303247, 1304237, 1187238, 1385283, 1595495, 1187300, 1187241, 1061740, 1316383, 1187307, 1062037, 1538693, 1454292, 1447731, 1187272, 1561442, 1187268, 1567150, 1597966, 1447745, 1598178, 1187262, 1464067, 1325394, 1537893, 1332693, 1479200, 1522335, 1589378, 1450573, 1399161, 1421274, 1561501, 1187232, 1187302, 1258469, 1331600, 1447740, 1187242, 1328147, 1264069, 1187294, 1299943, 1598013, 1526975, 1260604, 1487518, 1187229, 1487617, 1354087, 1456595, 1462047, 1561438, 1598363, 1332691, 1424655, 1567105, 1574774, 1598035, 1526981, 1384038, 1475987, 1343587, 1447437, 1454912, 1382215, 1447739, 1456512, 1447779, 1187283, 1440988, 1187293, 1187298, 1574754, 1354772, 1598018, 1447429, 1598181, 1447738, 1598273, 1312197, 1574752, 1572995, 1526127, 1473908, 1437660, 1447743, 1362262, 1456513, 1539280, 1348625, 1415878, 1332694, 1471020, 1432462, 1058088, 1526710, 1371788, 1187288, 1537984, 1316874, 1187270, 1333565, 1187292, 1447796, 1187311, 1187237, 1187231, 1574755, 1553822, 1522019, 1447418, 1187269, 1332692, 1447735, 1529638, 1468154, 1328031, 1447733, 1447402, 1593884, 1332696, 1560622, 1564819, 1538967, 1315756, 1328338, 1598113, 1324212, 1449895, 1567793, 1260629, 1430010, 1187266, 1187256, 1312754, 1449417, 1595494, 1529054, 1187261, 1187306, 1526976, 1425490, 1366922, 1527390, 1187299, 1561510, 1319222, 1187250, 1057262, 1457999, 1332937, 1187243, 1556213, 1278602, 1546839, 1187296, 1548950, 1580141, 1187303, 1187255, 1525650, 1572998, 1576740, 1187267, 1464664, 1440427, 1456467, 1187271, 1187258, 1585428, 1548760, 1342254, 1447793, 1406348, 1500177, 1260644, 1416954, 1323722, 1412713, 1187280, 1187310, 1538015, 1537285, 1187285, 1456482, 1260611, 1490508, 1187274, 1585641, 1416648, 1484655, 1421520, 1347485, 1525652, 1568987, 1526974, 1314375, 1187246, 1455623, 1488117, 1445025, 1447401, 1478237, 1561440, 1187287, 1561434, 1509337, 1451859, 1599630, 1348639, 1449436, 1361844, 1464661, 1263064, 1526973, 1187279, 1562080, 1354770, 1454521, 1520719, 1478236, 1526972, 1423948, 1334866, 1325026, 1438275, 1422582, 1437646, 1315530, 1458323, 1447795, 1528218, 1187254, 1598056, 1417853, 1423514, 1187297, 1187245, 1187264, 1524662, 1187251, 1524660, 1328113, 1187304, 1374767, 1474057, 1187284, 1331601, 1598180, 1062814, 1488818, 1187309, 1087494, 1063499, 1458325, 1187295, 1432336, 1260001, 1597982, 1537147, 1445355, 1595491, 1396111, 1546848, 1474048, 1495251, 1447734, 1464071, 1526978, 1187236, 1526977, 1566267, 1187277, 1421549, 1430015, 1316024, 1332695, 1561433, 1435837, 1087250, 1574753, 1476183, 1325395, 1561432, 1447736, 1500181, 1424164, 1456483, 1187228, 1573384, 1273769, 1598085, 1437661, 1306415, 1407257, 1187249, 1338215, 1458047, 1520791, 1447741, 1537263, 1472490, 1524661, 1061729, 1187273, 1417861, 1470196, 1485881, 1260595, 1538846, 1568762, 1315170, 1500469, 1372455, 1558140, 1425202, 1432702, 1472734, 1187230, 1187312, 1598191, 1569680, 1187233, 1263091, 1447417, 1504429, 1430016, 1435839, 1458324, 1546845, 1575027, 1187259, 1464610},
{1578810, 1166701, 1335901, 1063397, 1578812, 1526471, 1166702, 1067008, 1412862, 1059750, 1060729, 1166812, 1493768, 1335772, 1336194, 1166772, 1465775, 1166704, 1355314, 1314138, 1060727, 1388260, 1465786, 1565378, 1522096, 1312490, 1319284, 1418573, 1319169, 1060730, 1307995, 1465780, 1060728, 1404061, 1407842, 1326256, 1578754, 1410577, 1060732, 1461338, 1264209, 1166705, 1581273, 1414196, 1565398, 1355106, 1060731, 1412641, 1306618, 1060726, 1356302, 1310896, 1457885, 1497721, 1166709, 1067009, 1310812, 1578800, 1422203, 1484409, 1485278, 1322057, 1369956, 1311089, 1576614, 1355711, 1355798, 1564832, 1304166, 1166773, 1319071, 1578805, 1575869, 1403066},
}

bitmaps := []*Bitmap{}

for _, v := range values {
bitmap := BitmapOf(v...)
bitmap.RunOptimize()
bitmaps = append(bitmaps, bitmap)
sort.Sort(uints(v))
array_result := bitmap.ToArray()
assert.Equal(t, array_result, v)
arrayResult := bitmap.ToArray()
assert.Equal(t, arrayResult, v)
}
assert.Equal(t, FastAnd(bitmaps[0], bitmaps[1]).GetCardinality(), uint64(0))
assert.Equal(t, FastAnd(bitmaps[0], bitmaps[2]).GetCardinality(), uint64(0))
Expand All @@ -76,4 +77,4 @@ func TestIssue330_64bits(t *testing.T) {
assert.True(t, FastOr(bitmaps[2], bitmaps[1], bitmaps[0]).Equals(FastOr(bitmaps[0], bitmaps[1], bitmaps[2])))
assert.Equal(t, FastOr(bitmaps[2], bitmaps[1], bitmaps[0]).GetCardinality(), uint64(1040))
assert.Equal(t, FastOr(bitmaps[0], bitmaps[1], bitmaps[2]).GetCardinality(), uint64(1040))
}
}
Loading
Loading