mirror of
https://github.com/milvus-io/milvus.git
synced 2026-07-21 10:15:43 +00:00
fix: preserve segment insert log paths for text index (#50959)
issue: #50865 ## Summary Preserve existing insert log paths when building segment insert files for StorageV2 text index builds. Fall back to constructing paths from log IDs when the binlog path is absent. Signed-off-by: aoiasd <zhicheng.yue@zilliz.com>
This commit is contained in:
@@ -25,8 +25,7 @@ func GetSegmentInsertFiles(fieldBinlogs []*datapb.FieldBinlog, storageConfig *in
|
||||
filePaths := make([]string, 0)
|
||||
columnGroupID := insertLog.GetFieldID()
|
||||
for _, binlog := range insertLog.GetBinlogs() {
|
||||
filePath := metautil.BuildInsertLogPath(storageConfig.GetRootPath(), collectionID, partitionID, segmentID, columnGroupID, binlog.GetLogID())
|
||||
filePaths = append(filePaths, filePath)
|
||||
filePaths = append(filePaths, getInsertLogPath(binlog, storageConfig, collectionID, partitionID, segmentID, columnGroupID))
|
||||
}
|
||||
insertLogs = append(insertLogs, &indexcgopb.FieldInsertFiles{
|
||||
FilePaths: filePaths,
|
||||
@@ -36,3 +35,11 @@ func GetSegmentInsertFiles(fieldBinlogs []*datapb.FieldBinlog, storageConfig *in
|
||||
FieldInsertFiles: insertLogs,
|
||||
}
|
||||
}
|
||||
|
||||
func getInsertLogPath(binlog *datapb.Binlog, storageConfig *indexpb.StorageConfig, collectionID int64, partitionID int64, segmentID int64, columnGroupID int64) string {
|
||||
filePath := binlog.GetLogPath()
|
||||
if filePath != "" {
|
||||
return filePath
|
||||
}
|
||||
return metautil.BuildInsertLogPath(storageConfig.GetRootPath(), collectionID, partitionID, segmentID, columnGroupID, binlog.GetLogID())
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/milvus-io/milvus/pkg/v3/proto/datapb"
|
||||
"github.com/milvus-io/milvus/pkg/v3/proto/indexpb"
|
||||
)
|
||||
|
||||
func TestGetSegmentInsertFilesPreservesLogPath(t *testing.T) {
|
||||
storageConfig := &indexpb.StorageConfig{
|
||||
RootPath: "file",
|
||||
}
|
||||
insertBinlogs := []*datapb.FieldBinlog{{
|
||||
FieldID: 1,
|
||||
Binlogs: []*datapb.Binlog{{
|
||||
LogPath: "file/insert_log/10/20/30/1/40",
|
||||
EntriesNum: 100,
|
||||
}},
|
||||
}}
|
||||
|
||||
got := GetSegmentInsertFiles(insertBinlogs, storageConfig, 10, 20, 30)
|
||||
|
||||
assert.Equal(t, "file/insert_log/10/20/30/1/40", got.GetFieldInsertFiles()[0].GetFilePaths()[0])
|
||||
}
|
||||
|
||||
func TestGetSegmentInsertFilesFallsBackToLogID(t *testing.T) {
|
||||
storageConfig := &indexpb.StorageConfig{
|
||||
RootPath: "file",
|
||||
}
|
||||
insertBinlogs := []*datapb.FieldBinlog{{
|
||||
FieldID: 1,
|
||||
Binlogs: []*datapb.Binlog{{
|
||||
LogID: 40,
|
||||
EntriesNum: 100,
|
||||
}},
|
||||
}}
|
||||
|
||||
got := GetSegmentInsertFiles(insertBinlogs, storageConfig, 10, 20, 30)
|
||||
|
||||
assert.Equal(t, "file/insert_log/10/20/30/1/40", got.GetFieldInsertFiles()[0].GetFilePaths()[0])
|
||||
}
|
||||
Reference in New Issue
Block a user