made Bitmap SetBit method public

This commit is contained in:
Todd Gruben 2016-04-19 09:22:42 -05:00
parent 847f5a5eb0
commit cc048f5f3f
3 changed files with 7 additions and 7 deletions

View file

@ -34,7 +34,7 @@ type Bitmap struct {
func NewBitmap(bits ...uint64) *Bitmap {
bm := &Bitmap{tree: rbtree.NewTree(rbtreeItemCompare)}
for _, i := range bits {
bm.setBit(i)
bm.SetBit(i)
}
return bm
}
@ -364,7 +364,7 @@ func (b *Bitmap) Bits() []uint64 {
}
// setBit sets the i-th bit of the bitmap.
func (b *Bitmap) setBit(i uint64) (changed bool) {
func (b *Bitmap) SetBit(i uint64) (changed bool) {
address := deref(i)
chunk := b.Chunk(&Chunk{address.ChunkKey, make(Blocks, 32)})
@ -382,7 +382,7 @@ func (b *Bitmap) setBit(i uint64) (changed bool) {
}
// clearBit clears the i-th bit of the bitmap.
func (b *Bitmap) clearBit(i uint64) (changed bool) {
func (b *Bitmap) ClearBit(i uint64) (changed bool) {
address := deref(i)
chunk := b.Chunk(&Chunk{address.ChunkKey, make(Blocks, 32)})

View file

@ -332,7 +332,7 @@ func (f *Fragment) bitmap(bitmapID uint64) *Bitmap {
bm := NewBitmap()
f.storage.ForEachRange(bitmapID*SliceWidth, (bitmapID+1)*SliceWidth, func(i uint64) {
profileID := (f.slice * SliceWidth) + (i % SliceWidth)
bm.setBit(profileID)
bm.SetBit(profileID)
})
// Add to the cache.
@ -377,7 +377,7 @@ func (f *Fragment) setBit(bitmapID, profileID uint64) (changed bool, bool error)
}
// Update the cache.
if f.bitmap(bitmapID).setBit(profileID) {
if f.bitmap(bitmapID).SetBit(profileID) {
changed = true
}
@ -422,7 +422,7 @@ func (f *Fragment) ClearBit(bitmapID, profileID uint64) (bool, error) {
}
// Update the cache.
if f.bitmap(bitmapID).clearBit(profileID) {
if f.bitmap(bitmapID).ClearBit(profileID) {
return true, nil
}

View file

@ -408,7 +408,7 @@ func (h *Handler) handlePostImport(w http.ResponseWriter, r *http.Request) {
// Import into fragment.
err = f.Import(req.GetBitmapIDs(), req.GetProfileIDs())
if err != nil {
h.logger().Printf("import error: db=%s, frame=%s, slice=%s, bits=%d, err=%s", db, frame, slice, len(req.GetProfileIDs()), err)
h.logger().Printf("import error: db=%s, frame=%s, slice=%d, bits=%d, err=%s", db, frame, slice, len(req.GetProfileIDs()), err)
}
// Marshal response object.