Browse Source

parallel logic for read and write

pull/2/head
Chris Lu 12 years ago
parent
commit
37afb31d05
  1. 8
      weed-fs/src/pkg/storage/needle_read_write.go

8
weed-fs/src/pkg/storage/needle_read_write.go

@ -90,20 +90,22 @@ func (n *Needle) readNeedleHeader(bytes []byte) {
n.Size = util.BytesToUint32(bytes[12:NeedleHeaderSize]) n.Size = util.BytesToUint32(bytes[12:NeedleHeaderSize])
} }
func (n *Needle) readNeedleDataVersion2(bytes []byte) { func (n *Needle) readNeedleDataVersion2(bytes []byte) {
index := 0
index, lenBytes := 0, len(bytes)
if index < lenBytes {
n.DataSize = util.BytesToUint32(bytes[index : index+4]) n.DataSize = util.BytesToUint32(bytes[index : index+4])
index = index + 4 index = index + 4
n.Data = bytes[index : index+int(n.DataSize)] n.Data = bytes[index : index+int(n.DataSize)]
index = index + int(n.DataSize) index = index + int(n.DataSize)
n.Flags = bytes[index] n.Flags = bytes[index]
index = index + 1 index = index + 1
if index < len(bytes) {
}
if index < lenBytes {
n.NameSize = uint8(bytes[index]) n.NameSize = uint8(bytes[index])
index = index + 1 index = index + 1
n.Name = bytes[index : index+int(n.NameSize)] n.Name = bytes[index : index+int(n.NameSize)]
index = index + int(n.NameSize) index = index + int(n.NameSize)
} }
if index < len(bytes) {
if index < lenBytes {
n.MimeSize = uint8(bytes[index]) n.MimeSize = uint8(bytes[index])
index = index + 1 index = index + 1
n.Mime = bytes[index : index+int(n.MimeSize)] n.Mime = bytes[index : index+int(n.MimeSize)]

Loading…
Cancel
Save