mirror of
https://github.com/minio/minio.git
synced 2024-12-29 00:23:21 -05:00
eec66f195a
Earlier the listing would wait for all the objects to be processed this is essentially very time consuming considering even for 100,000 files.
76 lines
1.5 KiB
Go
76 lines
1.5 KiB
Go
package donut
|
|
|
|
import (
|
|
"sort"
|
|
"strings"
|
|
)
|
|
|
|
func appendUniq(slice []string, i string) []string {
|
|
for _, ele := range slice {
|
|
if ele == i {
|
|
return slice
|
|
}
|
|
}
|
|
return append(slice, i)
|
|
}
|
|
|
|
func filterPrefix(objects []string, prefix string) []string {
|
|
var results []string
|
|
for _, object := range objects {
|
|
if strings.HasPrefix(object, prefix) {
|
|
results = append(results, object)
|
|
}
|
|
}
|
|
return results
|
|
}
|
|
|
|
func removePrefix(objects []string, prefix string) []string {
|
|
var results []string
|
|
for _, object := range objects {
|
|
results = append(results, strings.TrimPrefix(object, prefix))
|
|
}
|
|
return results
|
|
}
|
|
|
|
func filterDelimited(objects []string, delim string) []string {
|
|
var results []string
|
|
for _, object := range objects {
|
|
if !strings.Contains(object, delim) {
|
|
results = append(results, object)
|
|
}
|
|
}
|
|
return results
|
|
}
|
|
|
|
func filterNotDelimited(objects []string, delim string) []string {
|
|
var results []string
|
|
for _, object := range objects {
|
|
if strings.Contains(object, delim) {
|
|
results = append(results, object)
|
|
}
|
|
}
|
|
return results
|
|
}
|
|
|
|
func extractDelimited(objects []string, delim string) []string {
|
|
var results []string
|
|
for _, object := range objects {
|
|
parts := strings.Split(object, delim)
|
|
results = append(results, parts[0]+delim)
|
|
}
|
|
return results
|
|
}
|
|
|
|
func uniqueObjects(objects []string) []string {
|
|
objectMap := make(map[string]string)
|
|
for _, v := range objects {
|
|
objectMap[v] = v
|
|
}
|
|
var results []string
|
|
for k := range objectMap {
|
|
results = append(results, k)
|
|
}
|
|
sort.Strings(results)
|
|
return results
|
|
}
|