diff options
Diffstat (limited to 'go/storage/needle_map.go')
| -rw-r--r-- | go/storage/needle_map.go | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/go/storage/needle_map.go b/go/storage/needle_map.go index 814789616..41f53b90b 100644 --- a/go/storage/needle_map.go +++ b/go/storage/needle_map.go @@ -1,12 +1,11 @@ package storage import ( + "encoding/binary" "fmt" "io/ioutil" "os" "sync" - - "github.com/chrislusf/seaweedfs/go/util" ) type NeedleMapType int @@ -53,16 +52,16 @@ func (nm baseNeedleMapper) IndexFileName() string { } func idxFileEntry(bytes []byte) (key uint64, offset uint32, size uint32) { - key = util.BytesToUint64(bytes[:8]) - offset = util.BytesToUint32(bytes[8:12]) - size = util.BytesToUint32(bytes[12:16]) + key = binary.BigEndian.Uint64(bytes[:8]) + offset = binary.BigEndian.Uint32(bytes[8:12]) + size = binary.BigEndian.Uint32(bytes[12:16]) return } func (nm baseNeedleMapper) appendToIndexFile(key uint64, offset uint32, size uint32) error { bytes := make([]byte, 16) - util.Uint64toBytes(bytes[0:8], key) - util.Uint32toBytes(bytes[8:12], offset) - util.Uint32toBytes(bytes[12:16], size) + binary.BigEndian.PutUint64(bytes[0:8], key) + binary.BigEndian.PutUint32(bytes[8:12], offset) + binary.BigEndian.PutUint32(bytes[12:16], size) nm.indexFileAccessLock.Lock() defer nm.indexFileAccessLock.Unlock() |
