mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
refactor
do not expose internal offset
This commit is contained in:
parent
02d0c12cdd
commit
1ee828b768
|
@ -30,8 +30,9 @@ func (mc *MemChunk) FreeResource() {
|
|||
}
|
||||
|
||||
func (mc *MemChunk) WriteDataAt(src []byte, offset int64) (n int) {
|
||||
n = copy(mc.buf[offset:], src)
|
||||
mc.usage.MarkWritten(offset, offset+int64(n))
|
||||
innerOffset := offset % mc.chunkSize
|
||||
n = copy(mc.buf[innerOffset:], src)
|
||||
mc.usage.MarkWritten(innerOffset, innerOffset+int64(n))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -57,14 +57,13 @@ func (cw *UploadPipeline) SaveDataAt(p []byte, off int64) (n int) {
|
|||
defer cw.writableChunksLock.Unlock()
|
||||
|
||||
logicChunkIndex := LogicChunkIndex(off / cw.ChunkSize)
|
||||
offsetRemainder := off % cw.ChunkSize
|
||||
|
||||
memChunk, found := cw.writableChunks[logicChunkIndex]
|
||||
if !found {
|
||||
memChunk = NewMemChunk(logicChunkIndex, cw.ChunkSize)
|
||||
cw.writableChunks[logicChunkIndex] = memChunk
|
||||
}
|
||||
n = memChunk.WriteDataAt(p, offsetRemainder)
|
||||
n = memChunk.WriteDataAt(p, off)
|
||||
cw.maybeMoveToSealed(memChunk, logicChunkIndex)
|
||||
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue