Browse Source

replace util/bytes.go with binary.BigEndian

pull/283/head
tnextday 10 years ago
parent
commit
356751f001
  1. 1
      go/storage/needle.go
  2. 5
      go/storage/needle_read_write.go
  3. 8
      go/storage/volume_replicate.go

1
go/storage/needle.go

@ -16,7 +16,6 @@ import (
"github.com/chrislusf/seaweedfs/go/glog" "github.com/chrislusf/seaweedfs/go/glog"
"github.com/chrislusf/seaweedfs/go/images" "github.com/chrislusf/seaweedfs/go/images"
"github.com/chrislusf/seaweedfs/go/operation" "github.com/chrislusf/seaweedfs/go/operation"
"github.com/chrislusf/seaweedfs/go/util"
) )
const ( const (

5
go/storage/needle_read_write.go

@ -238,7 +238,8 @@ func (n *Needle) ReadNeedleBody(r *os.File, version Version, offset int64, bodyL
} }
n.Data = bytes[:n.Size] n.Data = bytes[:n.Size]
n.Checksum = NewCRC(n.Data) n.Checksum = NewCRC(n.Data)
checksum := util.BytesToUint32(bytes[n.Size : n.Size+NeedleChecksumSize])
checksum := binary.BigEndian.Uint32(bytes[n.Size : n.Size+NeedleChecksumSize])
if n.Checksum.Value() != checksum { if n.Checksum.Value() != checksum {
glog.V(0).Infof("CRC error! Data On Disk Corrupted, needle id = %x", n.Id) glog.V(0).Infof("CRC error! Data On Disk Corrupted, needle id = %x", n.Id)
} }
@ -252,7 +253,7 @@ func (n *Needle) ReadNeedleBody(r *os.File, version Version, offset int64, bodyL
return return
} }
n.Checksum = NewCRC(n.Data) n.Checksum = NewCRC(n.Data)
checksum := util.BytesToUint32(bytes[n.Size : n.Size+NeedleChecksumSize])
checksum := binary.BigEndian.Uint32(bytes[n.Size : n.Size+NeedleChecksumSize])
if n.Checksum.Value() != checksum { if n.Checksum.Value() != checksum {
glog.V(0).Infof("CRC error! Data On Disk Corrupted, needle id = %x", n.Id) glog.V(0).Infof("CRC error! Data On Disk Corrupted, needle id = %x", n.Id)
} }

8
go/storage/volume_replicate.go

@ -6,7 +6,7 @@ import (
"sort" "sort"
"sync" "sync"
"github.com/chrislusf/seaweedfs/go/util"
"encoding/binary"
) )
type DirtyData struct { type DirtyData struct {
@ -39,9 +39,9 @@ func ScanDirtyData(indexFileContent []byte) (dirtys DirtyDatas) {
m := NewCompactMap() m := NewCompactMap()
for i := 0; i+16 <= len(indexFileContent); i += 16 { for i := 0; i+16 <= len(indexFileContent); i += 16 {
bytes := indexFileContent[i : i+16] bytes := indexFileContent[i : i+16]
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])
k := Key(key) k := Key(key)
if offset != 0 && size != 0 { if offset != 0 && size != 0 {
m.Set(k, offset, size) m.Set(k, offset, size)

Loading…
Cancel
Save