Skip to content

Commit

Permalink
Code cleaning:
Browse files Browse the repository at this point in the history
rlei.go and rle16.go should be merged into runcontainer.go
#187

rle.go should be removed
#186

This will make the code base easier to understand.
  • Loading branch information
lemire committed May 28, 2018
1 parent 1a28a7f commit 0caa902
Show file tree
Hide file tree
Showing 21 changed files with 1,538 additions and 6,212 deletions.
14 changes: 2 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: help all test format fmtcheck vet lint qa deps clean nuke rle backrle ser fetch-real-roaring-datasets
.PHONY: help all test format fmtcheck vet lint qa deps clean nuke ser fetch-real-roaring-datasets



Expand Down Expand Up @@ -97,18 +97,8 @@ nuke:
rm -rf ./target
GOPATH=$(GOPATH) go clean -i ./...

rle:
cp rle.go rle16.go
perl -pi -e 's/32/16/g' rle16.go
cp rle_test.go rle16_test.go
perl -pi -e 's/32/16/g' rle16_test.go

backrle:
cp rle16.go rle.go
perl -pi -e 's/16/32/g' rle.go
perl -pi -e 's/2032/2016/g' rle.go

ser: rle
ser:
go generate

cover:
Expand Down
6 changes: 0 additions & 6 deletions arraycontainer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ func TestArrayContainerNumberOfRuns025(t *testing.T) {
Convey("arrayContainer's numberOfRuns() function should be correct against the runContainer equivalent",
t, func() {
seed := int64(42)
p("seed is %v", seed)
rand.Seed(seed)

trials := []trial{
Expand All @@ -173,7 +172,6 @@ func TestArrayContainerNumberOfRuns025(t *testing.T) {

tester := func(tr trial) {
for j := 0; j < tr.ntrial; j++ {
p("TestArrayContainerNumberOfRuns023 on check# j=%v", j)
ma := make(map[int]bool)

n := tr.n
Expand All @@ -192,7 +190,6 @@ func TestArrayContainerNumberOfRuns025(t *testing.T) {
rc := newRunContainer16FromVals(false, a...)
rcNr := rc.numberOfRuns()

p("rcNr from run container is %v", rcNr)

// vs arrayContainer
ac := newArrayContainer()
Expand Down Expand Up @@ -247,7 +244,6 @@ func TestArrayContainerNumberOfRuns025(t *testing.T) {

//fmt.Printf("\nnum runs was: %v\n", rcNr)
}
p("done with randomized arrayContianer.numberOrRuns() checks for trial %#v", tr)
}

for i := range trials {
Expand Down Expand Up @@ -301,8 +297,6 @@ func TestArrayContainerEtc070(t *testing.T) {
ac.inot(0, MaxUint16+1)
rc = newRunContainer16Range(0, MaxUint16)

p("ac.card = %v", ac.getCardinality())
p("rc.card = %v", rc.getCardinality())
So(rc.equals(ac), ShouldBeTrue)

// comparing two array containers with different card
Expand Down
7 changes: 0 additions & 7 deletions bitmapcontainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,6 @@ func (bc *bitmapContainer) iremoveReturnMinimized(i uint16) container {

// iremove returns true if i was found.
func (bc *bitmapContainer) iremove(i uint16) bool {
/* branchless code
w := bc.bitmap[i>>6]
mask := uint64(1) << (i % 64)
neww := w &^ mask
bc.cardinality -= int((w ^ neww) >> (i % 64))
bc.bitmap[i>>6] = neww */
if bc.contains(i) {
bc.cardinality--
bc.bitmap[i/64] &^= (uint64(1) << (i % 64))
Expand Down Expand Up @@ -306,7 +300,6 @@ func (bc *bitmapContainer) iremoveRange(firstOfRange, lastOfRange int) container

// flip all values in range [firstOfRange,endx)
func (bc *bitmapContainer) inot(firstOfRange, endx int) container {
p("bc.inot() called with [%v, %v)", firstOfRange, endx)
if endx-firstOfRange == maxCapacity {
//p("endx-firstOfRange == maxCapacity")
flipBitmapRange(bc.bitmap, firstOfRange, endx)
Expand Down
9 changes: 0 additions & 9 deletions bitmapcontainer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,14 @@ func TestBitmapContainerNumberOfRuns024(t *testing.T) {
Convey("bitmapContainer's numberOfRuns() function should be correct against the runContainer equivalent",
t, func() {
seed := int64(42)
p("seed is %v", seed)
rand.Seed(seed)

trials := []trial{
{n: 1000, percentFill: .1, ntrial: 10},
/*
trial{n: 100, percentFill: .5, ntrial: 10},
trial{n: 100, percentFill: .01, ntrial: 10},
trial{n: 100, percentFill: .99, ntrial: 10},
*/
}

tester := func(tr trial) {
for j := 0; j < tr.ntrial; j++ {
p("TestBitmapContainerNumberOfRuns023 on check# j=%v", j)
ma := make(map[int]bool)

n := tr.n
Expand All @@ -44,7 +37,6 @@ func TestBitmapContainerNumberOfRuns024(t *testing.T) {
rc := newRunContainer16FromVals(false, a...)
rcNr := rc.numberOfRuns()

p("rcNr from run container is %v", rcNr)

// vs bitmapContainer
bc := newBitmapContainer()
Expand All @@ -56,7 +48,6 @@ func TestBitmapContainerNumberOfRuns024(t *testing.T) {
So(bcNr, ShouldEqual, rcNr)
//fmt.Printf("\nnum runs was: %v\n", rcNr)
}
p("done with randomized bitmapContianer.numberOrRuns() checks for trial %#v", tr)
}

for i := range trials {
Expand Down
1 change: 0 additions & 1 deletion ctz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func TestCountTrailingZeros072(t *testing.T) {

func getRandomUint64Set(n int) []uint64 {
seed := int64(42)
p("seed is %v", seed)
rand.Seed(seed)

var buf [8]byte
Expand Down
2 changes: 0 additions & 2 deletions example_roaring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ func TestExample2_roaring061(t *testing.T) {
for i := uint32(0); i < 10000; i += 3 {
rb1.Add(i)
}
p("rb1card before doing AndNot(rb3): %v, rb3card=%v",
rb1.GetCardinality(), rb3.GetCardinality())
rb1.AndNot(rb3)
rb1card := rb1.GetCardinality()
if rb1card != 1 {
Expand Down
Loading

0 comments on commit 0caa902

Please sign in to comment.