mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
comments to make import mutex less confusing
This commit is contained in:
parent
8476fffaa7
commit
7af64e382c
1 changed files with 8 additions and 4 deletions
12
fragment.go
12
fragment.go
|
|
@ -1610,12 +1610,14 @@ func (f *fragment) bulkImportMutex(rowIDs, columnIDs []uint64) error {
|
|||
// we have to maintain which columns are getting bits set as a map so that
|
||||
// we don't end up setting multiple bits in the same column if a column is
|
||||
// repeated within the import.
|
||||
colSet := make(map[uint64]uint64) // row to column
|
||||
colSet := make(map[uint64]uint64)
|
||||
|
||||
// Since each imported bit will at most set one bit and clear one bit, we
|
||||
// can reuse the rowIDs and columnIDs slices as the set and clear slice
|
||||
// arguments to importPositions. We maintain indexes into them as we loop
|
||||
// through them since the indexes of set and cleared bits may lag behind the
|
||||
// current index.
|
||||
// arguments to importPositions. The set positions we'll get from the
|
||||
// colSet, but we maintain clearIdx as we loop through row and col ids so
|
||||
// that we know how many bits we need to clear and how far through columnIDs
|
||||
// we are.
|
||||
clearIdx := 0
|
||||
for i := range rowIDs {
|
||||
rowID, columnID := rowIDs[i], columnIDs[i]
|
||||
|
|
@ -1641,6 +1643,8 @@ func (f *fragment) bulkImportMutex(rowIDs, columnIDs []uint64) error {
|
|||
colSet[columnID] = pos
|
||||
rowSet[rowID] = struct{}{}
|
||||
}
|
||||
|
||||
// re-use rowIDs by populating positions to set from colSet.
|
||||
i := 0
|
||||
for _, pos := range colSet {
|
||||
rowIDs[i] = pos
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue