compact_map_cases_test.go 751 B

12345678910111213141516171819202122232425262728293031323334
  1. //go:build 5BytesOffset
  2. // +build 5BytesOffset
  3. package needle_map
  4. import (
  5. "fmt"
  6. "github.com/seaweedfs/seaweedfs/weed/storage/types"
  7. "github.com/stretchr/testify/assert"
  8. "log"
  9. "os"
  10. "testing"
  11. )
  12. func Test5bytesIndexLoading(t *testing.T) {
  13. indexFile, ie := os.OpenFile("../../../test/data/187.idx", os.O_RDWR|os.O_RDONLY, 0644)
  14. if ie != nil {
  15. log.Fatalln(ie)
  16. }
  17. defer indexFile.Close()
  18. m, rowCount := loadNewNeedleMap(indexFile)
  19. println("total entries:", rowCount)
  20. key := types.NeedleId(0x671b905) // 108116229
  21. needle, found := m.Get(types.NeedleId(0x671b905))
  22. fmt.Printf("%v key:%v offset:%v size:%v\n", found, key, needle.Offset, needle.Size)
  23. assert.Equal(t, int64(12884911892)*8, needle.Offset.ToActualOffset(), "offset")
  24. }