-
Notifications
You must be signed in to change notification settings - Fork 2
/
partsize.go
56 lines (50 loc) · 1.04 KB
/
partsize.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package lib
const (
BasePart = int64(1024 * 1024 * 5)
)
// PartSizes return 10k parts that add up to 4.9 TB
var PartSizes = partSizes()
func partSizes() []int64 {
maxSize := int64(1024 * 1024 * 1024 * 1024 * 5)
totalParts := 10_000
totalSize := int64(0)
var parts []int64
partSize := BasePart
var iter []int
iter = append(iter, 0)
iter = append(iter, 100)
f := fibonacci()
f() // 0 - skip first two rounds of fib
f() // 100
for len(parts) < totalParts {
perIt := f() * 100
for i := 0; i < perIt; i++ {
if len(parts) == totalParts {
break
}
remaining := maxSize - totalSize
if remaining >= partSize {
parts = append(parts, partSize)
totalSize += partSize
} else if remaining > 0 {
parts = append(parts, remaining)
totalSize += remaining
} else {
break
}
}
if maxSize-totalSize == 0 {
break
}
partSize = partSize + partSize
}
return parts
}
func fibonacci() func() int {
first, second := 0, 1
return func() int {
ret := first
first, second = second, first+second
return ret
}
}