Add joinIDPath for reuse (#9650)

Signed-off-by: godchen <qingxiang.chen@zilliz.com>
This commit is contained in:
godchen 2021-10-12 17:20:33 +08:00 committed by GitHub
parent f85271cf3f
commit 13c1a1c746
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -68,7 +68,7 @@ func (alloc *allocator) allocID() (UniqueID, error) {
// genKey gives a valid key string for lists of UniqueIDs:
// if alloc is true, the returned keys will have a generated-unique ID at the end.
// if alloc is false, the returned keys will only consist of provided ids.
func (alloc *allocator) genKey(isalloc bool, ids ...UniqueID) (key string, err error) {
func (alloc *allocator) genKey(isalloc bool, ids ...UniqueID) (string, error) {
if isalloc {
idx, err := alloc.allocID()
if err != nil {
@ -76,12 +76,13 @@ func (alloc *allocator) genKey(isalloc bool, ids ...UniqueID) (key string, err e
}
ids = append(ids, idx)
}
return JoinIDPath(ids...), nil
}
func JoinIDPath(ids ...UniqueID) string {
idStr := make([]string, len(ids))
for _, id := range ids {
idStr = append(idStr, strconv.FormatInt(id, 10))
}
key = path.Join(idStr...)
return
return path.Join(idStr...)
}