2021-09-01 09:45:42 +00:00
|
|
|
//go:build 5BytesOffset
|
2021-06-28 22:48:07 +00:00
|
|
|
// +build 5BytesOffset
|
|
|
|
|
|
|
|
package needle_map
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"github.com/chrislusf/seaweedfs/weed/storage/types"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Test5bytesIndexLoading(t *testing.T) {
|
|
|
|
|
|
|
|
indexFile, ie := os.OpenFile("../../../test/data/187.idx", os.O_RDWR|os.O_RDONLY, 0644)
|
|
|
|
if ie != nil {
|
|
|
|
log.Fatalln(ie)
|
|
|
|
}
|
|
|
|
defer indexFile.Close()
|
|
|
|
m, rowCount := loadNewNeedleMap(indexFile)
|
|
|
|
|
|
|
|
println("total entries:", rowCount)
|
|
|
|
|
2021-06-29 05:46:49 +00:00
|
|
|
key := types.NeedleId(0x671b905) // 108116229
|
2021-06-28 22:48:07 +00:00
|
|
|
|
|
|
|
needle, found := m.Get(types.NeedleId(0x671b905))
|
|
|
|
|
|
|
|
fmt.Printf("%v key:%v offset:%v size:%v\n", found, key, needle.Offset, needle.Size)
|
|
|
|
|
|
|
|
assert.Equal(t, int64(12884911892)*8, needle.Offset.ToActualOffset(), "offset")
|
|
|
|
|
|
|
|
}
|