mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
needle scanner read appendAtNs
This commit is contained in:
parent
8b26d15740
commit
44647a46c0
|
@ -4,6 +4,7 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
"github.com/chrislusf/seaweedfs/weed/storage"
|
"github.com/chrislusf/seaweedfs/weed/storage"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -22,11 +23,12 @@ func (scanner *VolumeFileScanner4SeeDat) VisitSuperBlock(superBlock storage.Supe
|
||||||
|
|
||||||
}
|
}
|
||||||
func (scanner *VolumeFileScanner4SeeDat) ReadNeedleBody() bool {
|
func (scanner *VolumeFileScanner4SeeDat) ReadNeedleBody() bool {
|
||||||
return false
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (scanner *VolumeFileScanner4SeeDat) VisitNeedle(n *storage.Needle, offset int64) error {
|
func (scanner *VolumeFileScanner4SeeDat) VisitNeedle(n *storage.Needle, offset int64) error {
|
||||||
glog.V(0).Infof("%d,%s%x offset %d size %d cookie %x", *volumeId, n.Id, n.Cookie, offset, n.Size, n.Cookie)
|
t := time.Unix(int64(n.AppendAtNs)/int64(time.Second), int64(n.AppendAtNs)%int64(time.Second))
|
||||||
|
glog.V(0).Infof("%d,%s%x offset %d size %d cookie %x appendedAt %v", *volumeId, n.Id, n.Cookie, offset, n.Size, n.Cookie, t)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -283,6 +283,7 @@ func NeedleBodyLength(needleSize uint32, version Version) int64 {
|
||||||
//n should be a needle already read the header
|
//n should be a needle already read the header
|
||||||
//the input stream will read until next file entry
|
//the input stream will read until next file entry
|
||||||
func (n *Needle) ReadNeedleBody(r *os.File, version Version, offset int64, bodyLength int64) (err error) {
|
func (n *Needle) ReadNeedleBody(r *os.File, version Version, offset int64, bodyLength int64) (err error) {
|
||||||
|
|
||||||
if bodyLength <= 0 {
|
if bodyLength <= 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -301,6 +302,11 @@ func (n *Needle) ReadNeedleBody(r *os.File, version Version, offset int64, bodyL
|
||||||
}
|
}
|
||||||
n.readNeedleDataVersion2(bytes[0:n.Size])
|
n.readNeedleDataVersion2(bytes[0:n.Size])
|
||||||
n.Checksum = NewCRC(n.Data)
|
n.Checksum = NewCRC(n.Data)
|
||||||
|
|
||||||
|
if version == Version3 {
|
||||||
|
tsOffset := n.Size+NeedleChecksumSize
|
||||||
|
n.AppendAtNs = util.BytesToUint64(bytes[tsOffset : tsOffset+TimestampSize])
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
err = fmt.Errorf("Unsupported Version! (%d)", version)
|
err = fmt.Errorf("Unsupported Version! (%d)", version)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue