• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kelindar / roaring / 15946630268

28 Jun 2025 05:41PM UTC coverage: 85.945% (-1.0%) from 86.978%
15946630268

push

github

web-flow
Add min/max methods and fixed run container math (#12)

* Add copyright notice and implement min/max functions for containers

- Added copyright notice to all relevant files.
- Implemented min and max functions for array, bitmap, and run containers to retrieve the smallest and largest values, respectively.
- Introduced minZero and maxZero functions to find the smallest and largest unset values in each container type.
- Enhanced tests to validate the new min, max, minZero, and maxZero functionalities across various scenarios.

* table tests

* Update min/max tests to reflect correct expected values

- Adjusted test cases in TestMinMax to return the correct expected values for boundary conditions in array, bitmap, and run containers.
- Ensured consistency in expected results across all test scenarios, improving the accuracy of the min/max functionality tests.

* Update boundary test case in TestMinMax to reflect correct expected value

* Update README and refine MaxZero function logic

- Adjusted logo dimensions in README for better display.
- Updated the MaxZero function in the Bitmap struct to improve logic for finding the last zero bit, ensuring accurate results across various scenarios.
- Enhanced test cases in TestMinMax to reflect correct expected values for boundary conditions in array, bitmap, and run containers.

* Refactor container functions and enhance test coverage

- Updated container methods to improve logic for finding unset values, including arrMinZero and runMinZero.
- Removed unused maxZero functions from container types to streamline code.
- Added arrToRun function to optimize array to run conversion.
- Enhanced test cases in TestMinMax to ensure accurate results for boundary conditions and removed commented-out tests for clarity.
- Updated .gitignore to include *.exe files.

* Enhance arrToRun function in assert_test.go

- Updated arrToRun function to set container type and handle empty data cases, improving robustness.
- Removed re... (continued)

210 of 256 new or added lines in 10 files covered. (82.03%)

8 existing lines in 2 files now uncovered.

1651 of 1921 relevant lines covered (85.94%)

13343.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.67
/buffer.go
1
package roaring
2

3
import (
4
        "sync"
5
        "unsafe"
6

7
        "github.com/kelindar/bitmap"
8
)
9

10
const bitmapSize = 4096
11

12
var pool = sync.Pool{
13
        New: func() any {
6✔
14
                return make([]uint16, 0, bitmapSize)
6✔
15
        },
6✔
16
}
17

18
func borrowArray() []uint16 {
17✔
19
        return pool.Get().([]uint16)
17✔
20
}
17✔
21

22
func borrowBitmap() bitmap.Bitmap {
17✔
23
        arr := borrowArray()
17✔
24
        if cap(arr) < bitmapSize {
27✔
25
                arr = make([]uint16, bitmapSize)
10✔
26
        }
10✔
27

28
        // Clear the memory to ensure clean bitmap
29
        out := asBitmap(arr[:bitmapSize])
17✔
30
        for i := range out {
17,425✔
31
                out[i] = 0
17,408✔
32
        }
17,408✔
33
        return out
17✔
34
}
35

36
func release(v any) {
17✔
37
        switch v := v.(type) {
17✔
38
        case []uint16:
17✔
39
                pool.Put(v[:0])
17✔
NEW
40
        case bitmap.Bitmap:
×
NEW
41
                pool.Put(asUint16s(v[:0]))
×
42
        }
43
}
44

45
func asBitmap(data []uint16) bitmap.Bitmap {
205,069✔
46
        if len(data) == 0 {
205,069✔
NEW
47
                return nil
×
NEW
48
        }
×
49

50
        return bitmap.Bitmap(unsafe.Slice((*uint64)(unsafe.Pointer(&data[0])), len(data)/4))
205,069✔
51
}
52

53
func asUint16s(data bitmap.Bitmap) []uint16 {
17✔
54
        return unsafe.Slice((*uint16)(unsafe.Pointer(&data[0])), len(data)*4)
17✔
55
}
17✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc