mirror of
https://github.com/minio/minio.git
synced 2025-11-20 09:56:07 -05:00
xl PutObject: Split object into parts (#3651)
For faster time-to-first-byte when we try to download a big object
This commit is contained in:
committed by
Harshavardhana
parent
46743c7918
commit
e9394dc22d
@@ -343,3 +343,30 @@ func getOrderedDisks(distribution []int, disks []StorageAPI) (orderedDisks []Sto
|
||||
}
|
||||
return orderedDisks
|
||||
}
|
||||
|
||||
// getPartSizeFromIdx predicts the part size according to its index. It also
|
||||
// returns -1 when totalSize is also -1.
|
||||
func getPartSizeFromIdx(totalSize int64, partSize int64, partIndex int) int64 {
|
||||
if partSize == 0 {
|
||||
panic("Part size cannot be nil.")
|
||||
}
|
||||
if partIndex < 1 {
|
||||
panic("Part index should be greater than 1.")
|
||||
}
|
||||
switch totalSize {
|
||||
case -1, 0:
|
||||
return totalSize
|
||||
}
|
||||
// Compute the total count of parts
|
||||
partsCount := totalSize/partSize + 1
|
||||
// Return the part's size
|
||||
switch {
|
||||
case int64(partIndex) < partsCount:
|
||||
return partSize
|
||||
case int64(partIndex) == partsCount:
|
||||
// Size of last part
|
||||
return totalSize % partSize
|
||||
default:
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user