|
@ -129,15 +129,15 @@ func (sc *SwapFileChunk) ReadDataAt(p []byte, off int64, tsNs int64) (maxStop in |
|
|
logicStart := max(off, chunkStartOffset+t.StartOffset) |
|
|
logicStart := max(off, chunkStartOffset+t.StartOffset) |
|
|
logicStop := min(off+int64(len(p)), chunkStartOffset+t.stopOffset) |
|
|
logicStop := min(off+int64(len(p)), chunkStartOffset+t.stopOffset) |
|
|
if logicStart < logicStop { |
|
|
if logicStart < logicStop { |
|
|
|
|
|
actualStart := logicStart - chunkStartOffset + int64(sc.actualChunkIndex)*sc.swapfile.chunkSize |
|
|
|
|
|
if _, err := sc.swapfile.file.ReadAt(p[logicStart-off:logicStop-off], actualStart); err != nil { |
|
|
|
|
|
glog.Errorf("failed to reading swap file %s: %v", sc.swapfile.file.Name(), err) |
|
|
|
|
|
break |
|
|
|
|
|
} |
|
|
|
|
|
maxStop = max(maxStop, logicStop) |
|
|
|
|
|
|
|
|
if t.TsNs >= tsNs { |
|
|
if t.TsNs >= tsNs { |
|
|
actualStart := logicStart - chunkStartOffset + int64(sc.actualChunkIndex)*sc.swapfile.chunkSize |
|
|
|
|
|
if _, err := sc.swapfile.file.ReadAt(p[logicStart-off:logicStop-off], actualStart); err != nil { |
|
|
|
|
|
glog.Errorf("failed to reading swap file %s: %v", sc.swapfile.file.Name(), err) |
|
|
|
|
|
break |
|
|
|
|
|
} |
|
|
|
|
|
maxStop = max(maxStop, logicStop) |
|
|
|
|
|
} else { |
|
|
|
|
|
println("read old data2", tsNs-t.TsNs, "ns") |
|
|
|
|
|
|
|
|
println("read new data2", t.TsNs - tsNs, "ns") |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|