Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/armtests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.22.x]
go-version: [1.24.x]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/basictests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.22.x]
go-version: [1.24.x]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
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.22.x]
go-version: [1.24.x]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/legacytests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.22.x]
go-version: [1.24.x]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macostests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.22.x]
go-version: [1.24.x]
platform: [macos-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windowstests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.22.x]
go-version: [1.24.x]
platform: [windows-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand Down
8 changes: 5 additions & 3 deletions iter.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package roaring

import "iter"

// Values returns an iterator that yields the elements of the bitmap in
// increasing order. Starting with Go 1.23, users can use a for loop to iterate
// over it.
func Values(b *Bitmap) func(func(uint32) bool) {
func Values(b *Bitmap) iter.Seq[uint32] {
return func(yield func(uint32) bool) {
it := b.Iterator()
for it.HasNext() {
Expand All @@ -17,7 +19,7 @@ func Values(b *Bitmap) func(func(uint32) bool) {
// Backward returns an iterator that yields the elements of the bitmap in
// decreasing order. Starting with Go 1.23, users can use a for loop to iterate
// over it.
func Backward(b *Bitmap) func(func(uint32) bool) {
func Backward(b *Bitmap) iter.Seq[uint32] {
return func(yield func(uint32) bool) {
it := b.ReverseIterator()
for it.HasNext() {
Expand All @@ -30,7 +32,7 @@ func Backward(b *Bitmap) func(func(uint32) bool) {

// Unset creates an iterator that yields values in the range [min, max] that are NOT contained in the bitmap.
// The iterator becomes invalid if the bitmap is modified (e.g., with Add or Remove).
func Unset(b *Bitmap, min, max uint32) func(func(uint32) bool) {
func Unset(b *Bitmap, min, max uint32) iter.Seq[uint32] {
return func(yield func(uint32) bool) {
it := b.UnsetIterator(uint64(min), uint64(max)+1)
for it.HasNext() {
Expand Down
4 changes: 1 addition & 3 deletions roaring64/bsi64_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/binary"
"fmt"
"io"
"io/ioutil"
"math/big"
"math/rand"
"os"
Expand Down Expand Up @@ -645,11 +644,10 @@ func TestMinMaxWithNilFoundSet(t *testing.T) {
}

func TestBSIWriteToReadFrom(t *testing.T) {
file, err := ioutil.TempFile("./testdata", "bsi-test")
file, err := os.CreateTemp(t.TempDir(), "bsi-test")
if err != nil {
t.Fatal(err)
}
defer t.Cleanup(func() { os.Remove(file.Name()) })
defer file.Close()
bsi, min, max := setupRandom()
_, err = bsi.WriteTo(file)
Expand Down
6 changes: 4 additions & 2 deletions roaring64/iter.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package roaring64

import "iter"

// Values returns an iterator that yields the elements of the bitmap in
// increasing order. Starting with Go 1.23, users can use a for loop to iterate
// over it.
func Values(b *Bitmap) func(func(uint64) bool) {
func Values(b *Bitmap) iter.Seq[uint64] {
return func(yield func(uint64) bool) {
it := b.Iterator()
for it.HasNext() {
Expand All @@ -17,7 +19,7 @@ func Values(b *Bitmap) func(func(uint64) bool) {
// Backward returns an iterator that yields the elements of the bitmap in
// decreasing order. Starting with Go 1.23, users can use a for loop to iterate
// over it.
func Backward(b *Bitmap) func(func(uint64) bool) {
func Backward(b *Bitmap) iter.Seq[uint64] {
return func(yield func(uint64) bool) {
it := b.ReverseIterator()
for it.HasNext() {
Expand Down
12 changes: 4 additions & 8 deletions roaring64/serialization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"math"
"os"
"path/filepath"
Expand Down Expand Up @@ -87,7 +86,7 @@ func TestSerializationBasic037(t *testing.T) {

func TestSerializationToFile038(t *testing.T) {
rb := BitmapOf(1, 2, 3, 4, 5, 100, 1000)
fname := "myfile.bin"
fname := filepath.Join(t.TempDir(), "myfile.bin")
fout, err := os.OpenFile(fname, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o660)
if err != nil {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
Expand All @@ -114,10 +113,7 @@ func TestSerializationToFile038(t *testing.T) {
buf := bytes.NewBuffer(nil)
teer := io.TeeReader(fin, buf)

defer func() {
fin.Close()
_ = os.Remove(fname)
}()
defer fin.Close()

_, _ = newrb.ReadFrom(teer)
assert.True(t, rb.Equals(newrb))
Expand Down Expand Up @@ -276,7 +272,7 @@ func Test_tryReadFromRoaring32WithRoaring64(t *testing.T) {
}

func Test_tryReadFromRoaring32WithRoaring64_File(t *testing.T) {
tempDir, err := ioutil.TempDir("./", "testdata")
tempDir, err := os.MkdirTemp("./", "testdata")
if err != nil {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
Expand All @@ -290,7 +286,7 @@ func Test_tryReadFromRoaring32WithRoaring64_File(t *testing.T) {
}

name := filepath.Join(tempDir, "r32")
if err := ioutil.WriteFile(name, bs, 0o600); err != nil {
if err := os.WriteFile(name, bs, 0o600); err != nil {
t.Fatal(err)
}
file, err := os.Open(name)
Expand Down
13 changes: 6 additions & 7 deletions serialization_frozen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package roaring
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"reflect"
"testing"
Expand Down Expand Up @@ -49,12 +48,12 @@ func TestFrozenFormat(t *testing.T) {
t.Run("view "+name, func(t *testing.T) {
t.Parallel()

frozenBuf, err := ioutil.ReadFile(fpath)
frozenBuf, err := os.ReadFile(fpath)
if err != nil {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
}
portableBuf, err := ioutil.ReadFile(ppath)
portableBuf, err := os.ReadFile(ppath)
if err != nil {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
Expand All @@ -75,12 +74,12 @@ func TestFrozenFormat(t *testing.T) {
t.Run("freeze "+name, func(t *testing.T) {
t.Parallel()

frozenBuf, err := ioutil.ReadFile(fpath)
frozenBuf, err := os.ReadFile(fpath)
if err != nil {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
}
portableBuf, err := ioutil.ReadFile(ppath)
portableBuf, err := os.ReadFile(ppath)
if err != nil {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
Expand All @@ -106,12 +105,12 @@ func TestFrozenFormat(t *testing.T) {
t.Run("freeze with writer"+name, func(t *testing.T) {
t.Parallel()

frozenBuf, err := ioutil.ReadFile(fpath)
frozenBuf, err := os.ReadFile(fpath)
if err != nil {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
}
portableBuf, err := ioutil.ReadFile(ppath)
portableBuf, err := os.ReadFile(ppath)
if err != nil {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
Expand Down
22 changes: 9 additions & 13 deletions serialization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"encoding/binary"
"encoding/gob"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"runtime"
Expand Down Expand Up @@ -65,7 +64,7 @@ func TestSerializationBasic037(t *testing.T) {

func TestSerializationToFile038(t *testing.T) {
rb := BitmapOf(1, 2, 3, 4, 5, 100, 1000)
fname := "myfile.bin"
fname := filepath.Join(t.TempDir(), "myfile.bin")
fout, err := os.OpenFile(fname, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0660)
if err != nil {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
Expand All @@ -90,10 +89,7 @@ func TestSerializationToFile038(t *testing.T) {
return
}

defer func() {
fin.Close()
_ = os.Remove(fname)
}()
defer fin.Close()

_, _ = newrb.ReadFrom(fin)
assert.True(t, rb.Equals(newrb))
Expand All @@ -102,7 +98,7 @@ func TestSerializationToFile038(t *testing.T) {
func TestSerializationReadRunsFromFile039(t *testing.T) {
fn := "testdata/bitmapwithruns.bin"

by, err := ioutil.ReadFile(fn)
by, err := os.ReadFile(fn)
if err != nil {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
Expand Down Expand Up @@ -464,7 +460,7 @@ func TestBitmap_FromBuffer(t *testing.T) {
t.Run("bitmap with runs", func(t *testing.T) {
file := "testdata/bitmapwithruns.bin"

buf, err := ioutil.ReadFile(file)
buf, err := os.ReadFile(file)
if err != nil {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
Expand All @@ -480,7 +476,7 @@ func TestBitmap_FromBuffer(t *testing.T) {

t.Run("bitmap without runs", func(t *testing.T) {
fn := "testdata/bitmapwithruns.bin"
buf, err := ioutil.ReadFile(fn)
buf, err := os.ReadFile(fn)

if err != nil {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
Expand All @@ -496,7 +492,7 @@ func TestBitmap_FromBuffer(t *testing.T) {
// all3.classic somehow created by other tests.
t.Run("all3.classic bitmap", func(t *testing.T) {
file := "testdata/all3.classic"
buf, err := ioutil.ReadFile(file)
buf, err := os.ReadFile(file)

if err != nil {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
Expand All @@ -511,7 +507,7 @@ func TestBitmap_FromBuffer(t *testing.T) {

t.Run("testdata/bitmapwithruns.bin bitmap Ops", func(t *testing.T) {
file := "testdata/bitmapwithruns.bin"
buf, err := ioutil.ReadFile(file)
buf, err := os.ReadFile(file)

if err != nil {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
Expand Down Expand Up @@ -545,7 +541,7 @@ func TestBitmap_FromBuffer(t *testing.T) {

t.Run("marking all containers as requiring COW", func(t *testing.T) {
file := "testdata/bitmapwithruns.bin"
buf, err := ioutil.ReadFile(file)
buf, err := os.ReadFile(file)

if err != nil {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
Expand All @@ -572,7 +568,7 @@ func TestSerializationCrashers(t *testing.T) {
}

for _, crasher := range crashers {
data, err := ioutil.ReadFile(crasher)
data, err := os.ReadFile(crasher)
if err != nil {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
Expand Down
3 changes: 1 addition & 2 deletions smat_generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package roaring

import (
"fmt"
"io/ioutil"
"os"
"testing"

Expand All @@ -21,7 +20,7 @@ func TestGenerateSmatCorpus(t *testing.T) {
err, i, actionSeq)
}
os.MkdirAll("workdir/corpus", 0700)
ioutil.WriteFile(fmt.Sprintf("workdir/corpus/%d", i), byteSequence, 0600)
os.WriteFile(fmt.Sprintf("workdir/corpus/%d", i), byteSequence, 0600)
}
}

Expand Down
Loading