mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 17:15:56 +00:00
sanity-check: check whether containers are flagged as mapped before mapping
In the old unmarshal code, the decision to mark a thing as mapped (always yes) happens separately from setting the mapping. What if this could ever somehow possibly go wrong? Let's sanity-check that to be extra careful.
This commit is contained in:
parent
7841a660a8
commit
ba7db3028b
1 changed files with 18 additions and 3 deletions
|
|
@ -88,7 +88,12 @@ func readOffsets(b *Bitmap, data []byte, pos int, keyN uint32) error {
|
|||
|
||||
// Map byte slice directly to the container data.
|
||||
citer.Next()
|
||||
_, c := citer.Value()
|
||||
k, c := citer.Value()
|
||||
if !c.Mapped() {
|
||||
fmt.Printf("inexplicable: container %d (%d/%d) doesn't think it's mapped. fixing that.\n",
|
||||
k, i, keyN)
|
||||
c.setMapped(true)
|
||||
}
|
||||
switch c.typ() {
|
||||
case containerArray:
|
||||
c.setArray((*[0xFFFFFFF]uint16)(unsafe.Pointer(&data[offset]))[:c.N():c.N()])
|
||||
|
|
@ -108,7 +113,12 @@ func readWithRuns(b *Bitmap, data []byte, pos int, keyN uint32) error {
|
|||
citer, _ := b.Containers.Iterator(0)
|
||||
for i := 0; i < int(keyN); i++ {
|
||||
citer.Next()
|
||||
_, c := citer.Value()
|
||||
k, c := citer.Value()
|
||||
if !c.Mapped() {
|
||||
fmt.Printf("inexplicable: container %d (%d/%d) doesn't think it's mapped. fixing that.\n",
|
||||
k, i, keyN)
|
||||
c.setMapped(true)
|
||||
}
|
||||
switch c.typ() {
|
||||
case containerRun:
|
||||
runCount := binary.LittleEndian.Uint16(data[pos : pos+runCountHeaderSize])
|
||||
|
|
@ -176,12 +186,17 @@ func (b *Bitmap) unmarshalPilosaRoaring(data []byte) error {
|
|||
|
||||
// Map byte slice directly to the container data.
|
||||
citer.Next()
|
||||
_, c := citer.Value()
|
||||
k, c := citer.Value()
|
||||
|
||||
// this shouldn't happen, since we don't normally store nils.
|
||||
if c == nil {
|
||||
continue
|
||||
}
|
||||
if !c.Mapped() {
|
||||
fmt.Printf("inexplicable: container %d (%d/%d) doesn't think it's mapped. fixing that.\n",
|
||||
k, i, keyN)
|
||||
c.setMapped(true)
|
||||
}
|
||||
switch c.typ() {
|
||||
case containerRun:
|
||||
runCount := binary.LittleEndian.Uint16(data[offset : offset+runCountHeaderSize])
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue