package maps
import (
)
const debugLog = false
func ( *table) ( *abi.MapType, *Map) {
if !debugLog {
return
}
var uint16
var uint16
var uint16
for := uint64(0); <= .groups.lengthMask; ++ {
:= .groups.group(, )
for := uintptr(0); < abi.MapGroupSlots; ++ {
:= .ctrls().get()
switch {
case == ctrlDeleted:
++
case == ctrlEmpty:
++
default:
++
:= .key(, )
if .IndirectKey() {
= *((*unsafe.Pointer)())
}
if !.Key.Equal(, ) {
continue
}
if , := .Get(, , ); ! {
:= .Hasher(, .seed)
print("invariant failed: slot(", , "/", , "): key ")
dump(, .Key.Size_)
print(" not found [hash=", , ", h2=", h2(), " h1=", h1(), "]\n")
.Print(, )
panic("invariant failed: slot: key not found")
}
}
}
}
if != .used {
print("invariant failed: found ", , " used slots, but used count is ", .used, "\n")
.Print(, )
panic("invariant failed: found mismatched used slot count")
}
:= (.capacity*maxAvgGroupLoad)/abi.MapGroupSlots - .used -
if != .growthLeft {
print("invariant failed: found ", .growthLeft, " growthLeft, but expected ", , "\n")
.Print(, )
panic("invariant failed: found mismatched growthLeft")
}
if != .tombstones() {
print("invariant failed: found ", , " tombstones, but expected ", .tombstones(), "\n")
.Print(, )
panic("invariant failed: found mismatched tombstones")
}
if == 0 {
print("invariant failed: found no empty slots (violates probe invariant)\n")
.Print(, )
panic("invariant failed: found no empty slots (violates probe invariant)")
}
}
func ( *table) ( *abi.MapType, *Map) {
print(`table{
index: `, .index, `
localDepth: `, .localDepth, `
capacity: `, .capacity, `
used: `, .used, `
growthLeft: `, .growthLeft, `
groups:
`)
for := uint64(0); <= .groups.lengthMask; ++ {
print("\t\tgroup ", , "\n")
:= .groups.group(, )
:= .ctrls()
for := uintptr(0); < abi.MapGroupSlots; ++ {
print("\t\t\tslot ", , "\n")
:= .get()
print("\t\t\t\tctrl ", )
switch {
case ctrlEmpty:
print(" (empty)\n")
case ctrlDeleted:
print(" (deleted)\n")
default:
print("\n")
}
print("\t\t\t\tkey ")
dump(.key(, ), .Key.Size_)
println("")
print("\t\t\t\telem ")
dump(.elem(, ), .Elem.Size_)
println("")
}
}
}
func ( unsafe.Pointer, uintptr) {
for > 0 {
print(*(*byte)(), " ")
= unsafe.Pointer(uintptr() + 1)
--
}
}