build out cli and add size and gather functionality
This commit is contained in:
@ -25,11 +25,11 @@ func CalculatePartitions(store db.DB, targetSize int64) (partitions [][]types.Fi
|
||||
partitions = make([][]types.FileMetadata, 0)
|
||||
partitionSize := int64(0)
|
||||
partitionFiles := make([]types.FileMetadata, 0)
|
||||
leftOverFiles := make([]types.FileMetadata, 0)
|
||||
leftOverSize := int64(0)
|
||||
overSizedFiles := make([]types.FileMetadata, 0)
|
||||
overSizedSize := int64(0)
|
||||
for _, file := range files {
|
||||
if partitionSize+file.Size > targetSize {
|
||||
fmt.Printf("Partition Size: %v\n", humanize.Bytes(uint64(partitionSize)))
|
||||
//fmt.Printf("Partition Size: %v\n", humanize.Bytes(uint64(partitionSize)))
|
||||
partitions = append(partitions, partitionFiles)
|
||||
partitionFiles = make([]types.FileMetadata, 0)
|
||||
partitionSize = 0
|
||||
@ -38,16 +38,25 @@ func CalculatePartitions(store db.DB, targetSize int64) (partitions [][]types.Fi
|
||||
partitionFiles = append(partitionFiles, file)
|
||||
partitionSize += file.Size
|
||||
} else {
|
||||
leftOverFiles = append(leftOverFiles, file)
|
||||
leftOverSize += file.Size
|
||||
overSizedFiles = append(overSizedFiles, file)
|
||||
overSizedSize += file.Size
|
||||
}
|
||||
}
|
||||
|
||||
for _, partition := range partitions {
|
||||
fmt.Printf("Partition File Count: %v\n", len(partition))
|
||||
if len(partitionFiles) > 0 {
|
||||
partitions = append(partitions, partitionFiles)
|
||||
}
|
||||
fmt.Printf("Left Over File Count: %v\n", len(leftOverFiles))
|
||||
fmt.Printf("Left Over Size: %v\n", humanize.Bytes(uint64(leftOverSize)))
|
||||
|
||||
//for _, partition := range partitions {
|
||||
// fmt.Printf("Partition File Count: %v\n", len(partition))
|
||||
//}
|
||||
fmt.Printf("Over Sized File Count: %v\n", len(overSizedFiles))
|
||||
fmt.Printf("Total Over Sized Size: %v\n", humanize.Bytes(uint64(overSizedSize)))
|
||||
|
||||
return partitions, nil
|
||||
}
|
||||
|
||||
// CalculatePartitionsLeftPack calculates the partitions efficiently by searching for files that fit the remaining space in each partition
|
||||
func CalculatePartitionsLeftPack(store db.DB, targetSize int64) (partitions [][]types.FileMetadata, err error) {
|
||||
// TODO: implement this function
|
||||
return nil, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user