Skip to content

Commit

Permalink
no direct access to allot lookup table
Browse files Browse the repository at this point in the history
  • Loading branch information
gaissmai committed Dec 20, 2024
1 parent d7b63ad commit 4ef69f1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 10 additions & 2 deletions allot_lookuptbl.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@

package bart

// IdxToAllotment returns the precalculated bitset for idx.
// Only used for fast bitset intersections instead of
// range loops in table overlaps methods.
//
// Please read the ART paper ./doc/artlookup.pdf
// to understand the allotment algorithm.
func idxToAllot(idx uint) [8]uint64 {
return allotLookupTbl[idx]
}

// allotLookupTbl, as precalculated bitsets,
// map the baseIndex to bitset with precomputed complete binary tree.
//
// Used for bitset intersections instead of range loops in overlaps tests.
//
// // 1 <= idx <= 511
// func allotRec(aTbl *bitset.BitSet, idx uint) {
// aTbl = aTbl.Set(idx)
Expand Down
6 changes: 3 additions & 3 deletions overlaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (n *node[V]) overlapsChildrenIn(o *node[V]) bool {

for _, idx := range allIndices {
// get pre alloted bitset for idx
a8 := allotLookupTbl[idx]
a8 := idxToAllot(idx)
prefixRoutes.InPlaceUnion(bitset.BitSet(a8[:]))
}

Expand Down Expand Up @@ -241,7 +241,7 @@ func (n *node[V]) overlapsOneRouteIn(o *node[V]) bool {
// use bitset intersection with alloted stride table instead of range loops

// copy pre alloted bitset for idx
a8 := allotLookupTbl[idx]
a8 := idxToAllot(idx)
allotedPrefixRoutes := bitset.BitSet(a8[:])

// use bitset intersection instead of range loops
Expand All @@ -260,7 +260,7 @@ func (n *node[V]) overlapsPrefix(octet byte, pfxLen int) bool {
// use bitset intersection with alloted stride table instead of range loops

// copy pre alloted bitset for idx
a8 := allotLookupTbl[idx]
a8 := idxToAllot(idx)
allotedPrefixRoutes := bitset.BitSet(a8[:])

// use bitset intersection instead of range loops
Expand Down

0 comments on commit 4ef69f1

Please sign in to comment.