func takeMostSharedWithoutOverlap(all map[string]repositoryWork, alreadyUploaded sets.String) []repositoryWork {
	keys := make([]keysWithCount, 0, len(all))
	for k, v := range all {
		keys = append(keys, keysWithCount{name: k, count: int(v.repository.stats.sharedCount)})
	}
	sort.Slice(keys, func(i, j int) bool { return keys[i].count > keys[j].count })

	// from the set of possible work, ordered from most shared to least shared, take:
	// 1. the first available unit of work
	// 2. any other unit of work that does not have overlapping shared blobs
	uploadingBlobs := sets.NewString()
	var work []repositoryWork
	for _, key := range keys {
		name := key.name
		next, ok := all[name]
		if !ok {
			continue
		}
		if repositoryPlanHasAnyBlobs(next.repository, uploadingBlobs) {
			continue
		}
		repositoryPlanAddAllExcept(next.repository, uploadingBlobs, alreadyUploaded)
		delete(all, name)
		work = append(work, next)
	}
	return work
}
// takeMostSharedWithoutOverlap is a greedy algorithm that finds the repositories with the
// most shared layers that do not overlap. It will always return at least one unit of work.
takeMostSharedWithoutOverlap is a greedy algorithm that finds the repositories with the
most shared layers that do not overlap. It will always return at least one unit of work.
// takeMostSharedWithoutOverlap is a greedy algorithm that finds the repositories with the // most shared layers that do not overlap . It will always return at least one unit of work .
func takeMostSharedWithoutOverlap(all map[string]repositoryWork, alreadyUploaded sets.String) []repositoryWork {
	keys := make([]keysWithCount, 0, len(all))
	for k, v := range all {
		keys = append(keys, keysWithCount{name: k, count: int(v.repository.stats.sharedCount)})
	}
	sort.Slice(keys, func(i, j int) bool { return keys[i].count > keys[j].count })
	uploadingBlobs := sets.NewString()
	var work []repositoryWork
	for _, key := range keys {
		name := key.name
		next, ok := all[name]
		if !ok {
			continue
		}
		if repositoryPlanHasAnyBlobs(next.repository, uploadingBlobs) {
			continue
		}
		repositoryPlanAddAllExcept(next.repository, uploadingBlobs, alreadyUploaded)
		delete(all, name)
		work = append(work, next)
	}
	return work
}
func takeMostSharedWithoutOverlap ( all map [ string ] repositoryWork , alreadyUploaded sets . String ) [ ] repositoryWork { keys := make ( [ ] keysWithCount , 0 , len ( all ) ) for k , v := range all { keys = append ( keys , keysWithCount { name : k , count : int ( v . repository . stats . sharedCount ) } ) } sort . Slice ( keys , func ( i , j int ) bool { return keys [ i ] . count > keys [ j ] . count } ) uploadingBlobs := sets . NewString ( ) var work [ ] repositoryWork for _ , key := range keys { name := key . name next , ok := all [ name ] if ! ok { continue } if repositoryPlanHasAnyBlobs ( next . repository , uploadingBlobs ) { continue } repositoryPlanAddAllExcept ( next . repository , uploadingBlobs , alreadyUploaded ) delete ( all , name ) work = append ( work , next ) } return work }
takeMostSharedWithoutOverlap is a greedy algorithm that finds the repositories with the
most shared layers that do not overlap.
takeMostSharedWithoutOverlap is a greedy algorithm that finds the repositories with the most shared layers that do not overlap .
// from the set of possible work, ordered from most shared to least shared, take: // 1. the first available unit of work // 2. any other unit of work that does not have overlapping shared blobs