mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
sort bits on import
This commit sorts bits from import files before performing the input.
This commit is contained in:
parent
32697531fd
commit
64decdaf81
2 changed files with 21 additions and 3 deletions
17
client.go
17
client.go
|
|
@ -12,6 +12,7 @@ import (
|
|||
"math/rand"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"sort"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
|
|
@ -567,6 +568,16 @@ type Bit struct {
|
|||
// Bits represents a slice of bits.
|
||||
type Bits []Bit
|
||||
|
||||
func (p Bits) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
|
||||
func (p Bits) Len() int { return len(p) }
|
||||
|
||||
func (p Bits) Less(i, j int) bool {
|
||||
if p[i].BitmapID == p[j].BitmapID {
|
||||
return p[i].ProfileID < p[j].ProfileID
|
||||
}
|
||||
return p[i].BitmapID < p[j].BitmapID
|
||||
}
|
||||
|
||||
// BitmapIDs returns a slice of all the bitmap IDs.
|
||||
func (a Bits) BitmapIDs() []uint64 {
|
||||
other := make([]uint64, len(a))
|
||||
|
|
@ -592,5 +603,11 @@ func (a Bits) GroupBySlice() map[uint64][]Bit {
|
|||
slice := bit.ProfileID / SliceWidth
|
||||
m[slice] = append(m[slice], bit)
|
||||
}
|
||||
|
||||
for slice, bits := range m {
|
||||
sort.Sort(Bits(bits))
|
||||
m[slice] = bits
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
|
|
|||
|
|
@ -848,13 +848,14 @@ func (f *Fragment) Import(bitmapIDs, profileIDs []uint64) error {
|
|||
bmCounter = bitmap.Count()
|
||||
lastID = bitmapID
|
||||
}
|
||||
|
||||
// Invalidate block checksum.
|
||||
delete(f.checksums, int(bitmapID/HashBlockSize))
|
||||
if bitmap.SetBit(profileID) {
|
||||
bmCounter += 1
|
||||
}
|
||||
|
||||
// Invalidate block checksum.
|
||||
delete(f.checksums, int(bitmapID/HashBlockSize))
|
||||
}
|
||||
|
||||
f.cache.Invalidate()
|
||||
return nil
|
||||
}(); err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue