mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
code cleanup
This commit is contained in:
parent
3d4eaecac0
commit
228865cc35
2 changed files with 10 additions and 10 deletions
|
|
@ -176,7 +176,7 @@ func (c *Client) Import(db, frame string, slice uint64, bits []Bit) error {
|
|||
return ErrFrameRequired
|
||||
}
|
||||
|
||||
buf, err := ImportPayload(db, frame, slice, bits)
|
||||
buf, err := MarshalImportPayload(db, frame, slice, bits)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error Creating Payload: %s", err)
|
||||
}
|
||||
|
|
@ -198,7 +198,7 @@ func (c *Client) Import(db, frame string, slice uint64, bits []Bit) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func ImportPayload(db, frame string, slice uint64, bits []Bit) ([]byte, error) {
|
||||
func MarshalImportPayload(db, frame string, slice uint64, bits []Bit) ([]byte, error) {
|
||||
// Separate bitmap and profile IDs to reduce allocations.
|
||||
bitmapIDs := Bits(bits).BitmapIDs()
|
||||
profileIDs := Bits(bits).ProfileIDs()
|
||||
|
|
|
|||
16
fragment.go
16
fragment.go
|
|
@ -821,8 +821,8 @@ func (f *Fragment) Import(bitmapIDs, profileIDs []uint64) error {
|
|||
// Process every bit.
|
||||
// If an error occurs then reopen the storage.
|
||||
if err := func() error {
|
||||
last_id := uint64(0)
|
||||
bm_counter := uint64(0)
|
||||
lastID := uint64(0)
|
||||
bmCounter := uint64(0)
|
||||
var bitmap *Bitmap
|
||||
for i := range bitmapIDs {
|
||||
bitmapID, profileID := bitmapIDs[i], profileIDs[i]
|
||||
|
|
@ -840,19 +840,19 @@ func (f *Fragment) Import(bitmapIDs, profileIDs []uint64) error {
|
|||
// import optimization to avoid linear foreach calls
|
||||
// slight risk of concurrent cache counter being off but
|
||||
// no real danger
|
||||
if bitmapID != last_id {
|
||||
if i == 0 || bitmapID != lastID {
|
||||
bitmap = f.bitmap(bitmapID)
|
||||
if last_id != 0 {
|
||||
f.cache.Add(last_id, bm_counter)
|
||||
if i != 0 {
|
||||
f.cache.Add(lastID, bmCounter)
|
||||
}
|
||||
bm_counter = bitmap.Count()
|
||||
last_id = bitmapID
|
||||
bmCounter = bitmap.Count()
|
||||
lastID = bitmapID
|
||||
}
|
||||
|
||||
// Invalidate block checksum.
|
||||
delete(f.checksums, int(bitmapID/HashBlockSize))
|
||||
if bitmap.SetBit(profileID) {
|
||||
bm_counter += 1
|
||||
bmCounter += 1
|
||||
}
|
||||
// Update the cache.
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue