2022-08-25 15:48:54 +08:00
|
|
|
package model
|
|
|
|
|
|
|
|
import (
|
2023-06-09 01:28:37 +08:00
|
|
|
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
|
2023-01-11 14:35:40 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/proto/indexpb"
|
2023-04-06 19:14:32 +08:00
|
|
|
"github.com/milvus-io/milvus/pkg/common"
|
2022-08-25 15:48:54 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
type SegmentIndex struct {
|
2022-10-19 16:55:27 +08:00
|
|
|
SegmentID int64
|
|
|
|
CollectionID int64
|
|
|
|
PartitionID int64
|
|
|
|
NumRows int64
|
|
|
|
IndexID int64
|
|
|
|
BuildID int64
|
|
|
|
NodeID int64
|
|
|
|
IndexVersion int64
|
|
|
|
IndexState commonpb.IndexState
|
|
|
|
FailReason string
|
|
|
|
IsDeleted bool
|
|
|
|
CreateTime uint64
|
|
|
|
IndexFileKeys []string
|
|
|
|
IndexSize uint64
|
2023-01-04 19:37:36 +08:00
|
|
|
// deprecated
|
2023-09-25 21:39:27 +08:00
|
|
|
WriteHandoff bool
|
|
|
|
CurrentIndexVersion int32
|
2022-08-25 15:48:54 +08:00
|
|
|
}
|
|
|
|
|
2023-01-11 14:35:40 +08:00
|
|
|
func UnmarshalSegmentIndexModel(segIndex *indexpb.SegmentIndex) *SegmentIndex {
|
2022-08-25 15:48:54 +08:00
|
|
|
if segIndex == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return &SegmentIndex{
|
2023-09-25 21:39:27 +08:00
|
|
|
SegmentID: segIndex.SegmentID,
|
|
|
|
CollectionID: segIndex.CollectionID,
|
|
|
|
PartitionID: segIndex.PartitionID,
|
|
|
|
NumRows: segIndex.NumRows,
|
|
|
|
IndexID: segIndex.IndexID,
|
|
|
|
BuildID: segIndex.BuildID,
|
|
|
|
NodeID: segIndex.NodeID,
|
|
|
|
IndexState: segIndex.State,
|
|
|
|
FailReason: segIndex.FailReason,
|
|
|
|
IndexVersion: segIndex.IndexVersion,
|
|
|
|
IsDeleted: segIndex.Deleted,
|
|
|
|
CreateTime: segIndex.CreateTime,
|
|
|
|
IndexFileKeys: common.CloneStringList(segIndex.IndexFileKeys),
|
|
|
|
IndexSize: segIndex.SerializeSize,
|
|
|
|
WriteHandoff: segIndex.WriteHandoff,
|
|
|
|
CurrentIndexVersion: segIndex.GetCurrentIndexVersion(),
|
2022-08-25 15:48:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-11 14:35:40 +08:00
|
|
|
func MarshalSegmentIndexModel(segIdx *SegmentIndex) *indexpb.SegmentIndex {
|
2022-08-25 15:48:54 +08:00
|
|
|
if segIdx == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-01-11 14:35:40 +08:00
|
|
|
return &indexpb.SegmentIndex{
|
2023-09-25 21:39:27 +08:00
|
|
|
CollectionID: segIdx.CollectionID,
|
|
|
|
PartitionID: segIdx.PartitionID,
|
|
|
|
SegmentID: segIdx.SegmentID,
|
|
|
|
NumRows: segIdx.NumRows,
|
|
|
|
IndexID: segIdx.IndexID,
|
|
|
|
BuildID: segIdx.BuildID,
|
|
|
|
NodeID: segIdx.NodeID,
|
|
|
|
State: segIdx.IndexState,
|
|
|
|
FailReason: segIdx.FailReason,
|
|
|
|
IndexVersion: segIdx.IndexVersion,
|
|
|
|
IndexFileKeys: common.CloneStringList(segIdx.IndexFileKeys),
|
|
|
|
Deleted: segIdx.IsDeleted,
|
|
|
|
CreateTime: segIdx.CreateTime,
|
|
|
|
SerializeSize: segIdx.IndexSize,
|
|
|
|
WriteHandoff: segIdx.WriteHandoff,
|
|
|
|
CurrentIndexVersion: segIdx.CurrentIndexVersion,
|
2022-08-25 15:48:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func CloneSegmentIndex(segIndex *SegmentIndex) *SegmentIndex {
|
|
|
|
return &SegmentIndex{
|
2023-09-25 21:39:27 +08:00
|
|
|
SegmentID: segIndex.SegmentID,
|
|
|
|
CollectionID: segIndex.CollectionID,
|
|
|
|
PartitionID: segIndex.PartitionID,
|
|
|
|
NumRows: segIndex.NumRows,
|
|
|
|
IndexID: segIndex.IndexID,
|
|
|
|
BuildID: segIndex.BuildID,
|
|
|
|
NodeID: segIndex.NodeID,
|
|
|
|
IndexState: segIndex.IndexState,
|
|
|
|
FailReason: segIndex.FailReason,
|
|
|
|
IndexVersion: segIndex.IndexVersion,
|
|
|
|
IsDeleted: segIndex.IsDeleted,
|
|
|
|
CreateTime: segIndex.CreateTime,
|
|
|
|
IndexFileKeys: common.CloneStringList(segIndex.IndexFileKeys),
|
|
|
|
IndexSize: segIndex.IndexSize,
|
|
|
|
WriteHandoff: segIndex.WriteHandoff,
|
|
|
|
CurrentIndexVersion: segIndex.CurrentIndexVersion,
|
2022-08-25 15:48:54 +08:00
|
|
|
}
|
|
|
|
}
|