From d9b0a817525a6f4b7907abb99046b5db04de47e6 Mon Sep 17 00:00:00 2001 From: wmillers <31211860+wmillers@users.noreply.github.com> Date: Wed, 5 Jul 2023 16:14:21 +0800 Subject: [PATCH 1/2] fix: compilation on 32bit --- worker/queue.go | 2 +- worker/restore_reduce.go | 3 ++- xidmap/trie.go | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/worker/queue.go b/worker/queue.go index 6f0a82c2465..d9d89cf65f8 100644 --- a/worker/queue.go +++ b/worker/queue.go @@ -302,7 +302,7 @@ func (t *tasks) cleanup() { func (t *tasks) newId() uint64 { myRaftId := State.WALstore.Uint(raftwal.RaftId) for { - id := myRaftId<<32 | uint64(t.rng.Intn(math.MaxUint32)) + id := myRaftId<<32 | uint64(t.rng.Intn(math.MaxInt32)) // z.Tree cannot store 0 or math.MaxUint64. Check that id is unique. if id != 0 && id != math.MaxUint64 && t.log.Get(id) == 0 { return id diff --git a/worker/restore_reduce.go b/worker/restore_reduce.go index b14eb2bd51c..a3cd03f29f1 100644 --- a/worker/restore_reduce.go +++ b/worker/restore_reduce.go @@ -18,6 +18,7 @@ import ( "encoding/binary" "io" "log" + "math" "os" "path/filepath" "sort" @@ -36,7 +37,7 @@ import ( ) const ( - mapFileSz int = 2 << 30 + mapFileSz int = math.MaxInt32 partitionBufSz int = 4 << 20 ) diff --git a/xidmap/trie.go b/xidmap/trie.go index 1e3cf845c51..bc1eb910405 100644 --- a/xidmap/trie.go +++ b/xidmap/trie.go @@ -35,7 +35,7 @@ type Trie struct { // NewTrie would return back a Trie backed by the provided Arena. Trie would assume ownership of the // Arena. Release must be called at the end to release Arena's resources. func NewTrie() *Trie { - buf := z.NewBuffer(32<<20, "Trie").WithMaxSize(math.MaxUint32) + buf := z.NewBuffer(32<<20, "Trie").WithMaxSize(math.MaxInt32) // 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) From 217485d914e5d3deda56d86578528a4d2b92d7c9 Mon Sep 17 00:00:00 2001 From: wmillers <31211860+wmillers@users.noreply.github.com> Date: Fri, 7 Jul 2023 09:23:41 +0800 Subject: [PATCH 2/2] Fix the compilation overflow problem in the code related to t.rng.Intn --- worker/queue.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worker/queue.go b/worker/queue.go index d9d89cf65f8..e469cd93732 100644 --- a/worker/queue.go +++ b/worker/queue.go @@ -302,7 +302,7 @@ func (t *tasks) cleanup() { func (t *tasks) newId() uint64 { myRaftId := State.WALstore.Uint(raftwal.RaftId) for { - id := myRaftId<<32 | uint64(t.rng.Intn(math.MaxInt32)) + id := myRaftId<<32 | uint64(t.rng.Uint32()) // z.Tree cannot store 0 or math.MaxUint64. Check that id is unique. if id != 0 && id != math.MaxUint64 && t.log.Get(id) == 0 { return id