Skip to content

Commit

Permalink
enhance: Support filter show segment-index result with field ID (#296)
Browse files Browse the repository at this point in the history
Related to #294

Signed-off-by: Congqi Xia <[email protected]>
  • Loading branch information
congqixia authored Aug 16, 2024
1 parent 3369b50 commit 2aad825
Showing 1 changed file with 28 additions and 17 deletions.
45 changes: 28 additions & 17 deletions states/etcd/show/segment_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import (

type SegmentIndexParam struct {
framework.ParamBase `use:"show segment-index" desc:"display segment index information" alias:"segments-index,segment-indexes,segments-indexes"`
CollectionID int64 `name:"collection" default:"0"`
SegmentID int64 `name:"segment" default:"0"`
CollectionID int64 `name:"collection" default:"0" desc:"collection id to filter with"`
SegmentID int64 `name:"segment" default:"0" desc:"segment id to filter with"`
FieldID int64 `name:"field" default:"0" desc:"field id to filter with"`
}

// SegmentIndexCommand returns show segment-index command.
Expand Down Expand Up @@ -96,27 +97,37 @@ func (c *ComponentShow) SegmentIndexCommand(ctx context.Context, p *SegmentIndex
continue
}
for _, segIdx := range segIdxv2 {
fmt.Printf("\n\tIndexV2 build ID: %d, states %s", segIdx.GetBuildID(), segIdx.GetState().String())
count[segIdx.GetState().String()]++
idx, ok := idIdx[segIdx.GetIndexID()]
if ok {
fmt.Printf("\t Index Type:%v on Field ID: %d", common.GetKVPair(idx.GetIndexInfo().GetIndexParams(), "index_type"), idx.GetIndexInfo().GetFieldID())
if !ok {
continue
}
// filter with field id
if p.FieldID != 0 && idx.GetIndexInfo().GetFieldID() != p.FieldID {
continue
}
fmt.Printf("\n\tIndexV2 build ID: %d, states %s", segIdx.GetBuildID(), segIdx.GetState().String())
count[segIdx.GetState().String()]++

fmt.Printf("\t Index Type:%v on Field ID: %d", common.GetKVPair(idx.GetIndexInfo().GetIndexParams(), "index_type"), idx.GetIndexInfo().GetFieldID())
fmt.Printf("\tSerialized Size: %d\n", segIdx.GetSerializeSize())
fmt.Printf("\tCurrent Index Version: %d\n", segIdx.GetCurrentIndexVersion())
}
fmt.Println()
}

for _, segIdx := range segIdxs {
info, ok := buildID2Info[segIdx.BuildID]
if !ok {
fmt.Printf("\tno build info found for id: %d\n", segIdx.BuildID)
fmt.Println(segIdx.String())
} else {
// use v1 info
for _, segIdx := range segIdxs {
info, ok := buildID2Info[segIdx.BuildID]
if !ok {
fmt.Printf("\tno build info found for id: %d\n", segIdx.BuildID)
fmt.Println(segIdx.String())
continue
}
if p.FieldID != 0 && p.FieldID != info.GetReq().GetFieldSchema().GetFieldID() {
continue
}
fmt.Printf("\n\tIndex build ID: %d, state: %s", info.IndexBuildID, info.State.String())
fmt.Printf("\t Index Type:%v on Field ID: %d", common.GetKVPair(info.GetReq().GetIndexParams(), "index_type"), segIdx.GetFieldID())
fmt.Printf("\t info.SerializeSize: %d\n", info.GetSerializeSize())
}
fmt.Printf("\n\tIndex build ID: %d, state: %s", info.IndexBuildID, info.State.String())
fmt.Printf("\t Index Type:%v on Field ID: %d", common.GetKVPair(info.GetReq().GetIndexParams(), "index_type"), segIdx.GetFieldID())
fmt.Printf("\t info.SerializeSize: %d\n", info.GetSerializeSize())
}
fmt.Println()
}
Expand Down

0 comments on commit 2aad825

Please sign in to comment.