test compact map with snowflake sequencer

This commit is contained in:
chrislu 2022-06-23 21:45:51 -07:00
parent 217d7dc377
commit 509a9047db

View file

@ -2,10 +2,25 @@ package needle_map
import ( import (
"fmt" "fmt"
"github.com/chrislusf/seaweedfs/weed/sequence"
. "github.com/chrislusf/seaweedfs/weed/storage/types" . "github.com/chrislusf/seaweedfs/weed/storage/types"
"testing" "testing"
) )
func TestSnowflakeSequencer(t *testing.T) {
m := NewCompactMap()
seq, _ := sequence.NewSnowflakeSequencer("for_test", 1)
for i := 0; i < 200000; i++ {
id := seq.NextFileId(1)
oldOffset, oldSize := m.Set(NeedleId(id), ToOffset(8), 3000073)
if oldSize != 0 {
t.Errorf("id %d oldOffset %v oldSize %d", id, oldOffset, oldSize)
}
}
}
func TestOverflow2(t *testing.T) { func TestOverflow2(t *testing.T) {
m := NewCompactMap() m := NewCompactMap()
_, oldSize := m.Set(NeedleId(150088), ToOffset(8), 3000073) _, oldSize := m.Set(NeedleId(150088), ToOffset(8), 3000073)