mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-12 15:51:01 +00:00
added roaringsentinel build tag to check for user errors at build time
This commit is contained in:
parent
4f8b3f650e
commit
bc0f86755a
3 changed files with 41 additions and 3 deletions
|
|
@ -431,7 +431,7 @@ func (b *Bitmap) Size() int {
|
|||
|
||||
// CountRange returns the number of bits set between [start, end).
|
||||
func (b *Bitmap) CountRange(start, end uint64) (n uint64) {
|
||||
if roaringParanoia {
|
||||
if roaringSentinel {
|
||||
if start > end {
|
||||
panic(fmt.Sprintf("counting in range but %v > %v", start, end))
|
||||
}
|
||||
|
|
@ -494,7 +494,7 @@ func (b *Bitmap) Slice() []uint64 {
|
|||
|
||||
// SliceRange returns a slice of integers between [start, end).
|
||||
func (b *Bitmap) SliceRange(start, end uint64) []uint64 {
|
||||
if roaringParanoia {
|
||||
if roaringSentinel {
|
||||
if start > end {
|
||||
panic(fmt.Sprintf("getting slice in range but %v > %v", start, end))
|
||||
}
|
||||
|
|
@ -1271,7 +1271,7 @@ func (b *Bitmap) Check() error {
|
|||
|
||||
// Flip performs a logical negate of the bits in the range [start,end].
|
||||
func (b *Bitmap) Flip(start, end uint64) *Bitmap {
|
||||
if roaringParanoia {
|
||||
if roaringSentinel {
|
||||
if start > end {
|
||||
panic(fmt.Sprintf("flipping in range but %v > %v", start, end))
|
||||
}
|
||||
|
|
|
|||
19
roaring/roaring_nop_sentinel.go
Normal file
19
roaring/roaring_nop_sentinel.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright 2017 Pilosa Corp.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// +build !roaringsentinel
|
||||
|
||||
package roaring
|
||||
|
||||
const roaringSentinel = false
|
||||
19
roaring/roaring_sentinel.go
Normal file
19
roaring/roaring_sentinel.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright 2017 Pilosa Corp.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// +build roaringsentinel
|
||||
|
||||
package roaring
|
||||
|
||||
const roaringSentinel = true
|
||||
Loading…
Add table
Reference in a new issue