From 692e2d79fa7b1ed92122da1495869c9a58c574e8 Mon Sep 17 00:00:00 2001 From: Ahsan Barkati <ahsanbarkati@gmail.com> Date: Sat, 7 Nov 2020 10:49:55 +0530 Subject: [PATCH] Fix Trie tests --- xidmap/trie.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xidmap/trie.go b/xidmap/trie.go index 16519b32300..dff69a6dc78 100644 --- a/xidmap/trie.go +++ b/xidmap/trie.go @@ -36,9 +36,11 @@ type Trie struct { func NewTrie() *Trie { buf, err := z.NewBufferWith(32<<20, math.MaxUint32, z.UseMmap) x.Check(err) - ro := buf.AllocateOffset(nodeSz) + // Add additional 8 bytes at the start, because offset=0 is used for checking non-existing node. + // Therefore we can't keep root at 0 offset. + ro := buf.AllocateOffset(nodeSz + 8) return &Trie{ - root: uint32(ro), + root: uint32(ro + 8), buf: buf, } }