Skip to content

Commit 2cd2e93

Browse files
author
Jeri-Jose1
committed
bug fix for show collection-history --id <id> not printing value
Signed-off-by: Jeri-Jose1 <[email protected]>
1 parent 43d4e81 commit 2cd2e93

File tree

2 files changed

+26
-28
lines changed

2 files changed

+26
-28
lines changed

states/etcd/show/collection.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ func (rs *Collections) PrintAs(format framework.Format) string {
8383
case framework.FormatDefault, framework.FormatPlain:
8484
sb := &strings.Builder{}
8585
for _, coll := range rs.collections {
86-
printCollection(sb, coll)
86+
printCollection( coll)
8787
}
88-
fmt.Fprintln(sb, "================================================================================")
89-
fmt.Fprintf(sb, "--- Total collections: %d\t Matched collections: %d\n", rs.total, len(rs.collections))
90-
fmt.Fprintf(sb, "--- Total channel: %d\t Healthy collections: %d\n", rs.channels, rs.healthy)
88+
fmt.Printf( "================================================================================")
89+
fmt.Printf( "--- Total collections: %d\t Matched collections: %d\n", rs.total, len(rs.collections))
90+
fmt.Printf( "--- Total channel: %d\t Healthy collections: %d\n", rs.channels, rs.healthy)
9191
return sb.String()
9292
}
9393
return ""
@@ -97,48 +97,48 @@ func (rs *Collections) Entities() any {
9797
return rs.collections
9898
}
9999

100-
func printCollection(sb *strings.Builder, collection *models.Collection) {
101-
fmt.Fprintln(sb, "================================================================================")
102-
fmt.Fprintf(sb, "DBID: %d\n", collection.DBID)
103-
fmt.Fprintf(sb, "Collection ID: %d\tCollection Name: %s\n", collection.ID, collection.Schema.Name)
100+
func printCollection( collection *models.Collection) {
101+
fmt.Printf( "================================================================================")
102+
fmt.Printf( "DBID: %d\n", collection.DBID)
103+
fmt.Printf( "Collection ID: %d\tCollection Name: %s\n", collection.ID, collection.Schema.Name)
104104
t, _ := utils.ParseTS(collection.CreateTime)
105-
fmt.Fprintf(sb, "Collection State: %s\tCreate Time: %s\n", collection.State.String(), t.Format("2006-01-02 15:04:05"))
106-
fmt.Fprintf(sb, "Fields:\n")
105+
fmt.Printf( "Collection State: %s\tCreate Time: %s\n", collection.State.String(), t.Format("2006-01-02 15:04:05"))
106+
fmt.Printf( "Fields:\n")
107107
fields := collection.Schema.Fields
108108
sort.Slice(fields, func(i, j int) bool {
109109
return fields[i].FieldID < fields[j].FieldID
110110
})
111111
for _, field := range fields {
112-
fmt.Fprintf(sb, " - Field ID: %d \t Field Name: %s \t Field Type: %s\n", field.FieldID, field.Name, field.DataType.String())
112+
fmt.Printf( " - Field ID: %d \t Field Name: %s \t Field Type: %s\n", field.FieldID, field.Name, field.DataType.String())
113113
if field.IsPrimaryKey {
114-
fmt.Fprintf(sb, "\t - Primary Key: %t, AutoID: %t\n", field.IsPrimaryKey, field.AutoID)
114+
fmt.Printf( "\t - Primary Key: %t, AutoID: %t\n", field.IsPrimaryKey, field.AutoID)
115115
}
116116
if field.IsDynamic {
117-
fmt.Fprintf(sb, "\t - Dynamic Field\n")
117+
fmt.Printf( "\t - Dynamic Field\n")
118118
}
119119
if field.IsPartitionKey {
120-
fmt.Fprintf(sb, "\t - Partition Key\n")
120+
fmt.Printf( "\t - Partition Key\n")
121121
}
122122
if field.IsClusteringKey {
123-
fmt.Fprintf(sb, "\t - Clustering Key\n")
123+
fmt.Printf( "\t - Clustering Key\n")
124124
}
125125
// print element type if field is array
126126
if field.DataType == models.DataTypeArray {
127-
fmt.Fprintf(sb, "\t - Element Type: %s\n", field.ElementType.String())
127+
fmt.Printf( "\t - Element Type: %s\n", field.ElementType.String())
128128
}
129129
// type params
130130
for key, value := range field.Properties {
131-
fmt.Fprintf(sb, "\t - Type Param %s: %s\n", key, value)
131+
fmt.Printf( "\t - Type Param %s: %s\n", key, value)
132132
}
133133
}
134134

135-
fmt.Fprintf(sb, "Enable Dynamic Schema: %t\n", collection.Schema.EnableDynamicSchema)
136-
fmt.Fprintf(sb, "Consistency Level: %s\n", collection.ConsistencyLevel.String())
135+
fmt.Printf( "Enable Dynamic Schema: %t\n", collection.Schema.EnableDynamicSchema)
136+
fmt.Printf( "Consistency Level: %s\n", collection.ConsistencyLevel.String())
137137
for _, channel := range collection.Channels {
138-
fmt.Fprintf(sb, "Start position for channel %s(%s): %v\n", channel.PhysicalName, channel.VirtualName, channel.StartPosition.MsgID)
138+
fmt.Printf( "Start position for channel %s(%s): %v\n", channel.PhysicalName, channel.VirtualName, channel.StartPosition.MsgID)
139139
}
140-
fmt.Fprintf(sb, "Collection properties(%d):\n", len(collection.Properties))
140+
fmt.Printf( "Collection properties(%d):\n", len(collection.Properties))
141141
for k, v := range collection.Properties {
142-
fmt.Fprintf(sb, "\tKey: %s: %v\n", k, v)
142+
fmt.Printf( "\tKey: %s: %v\n", k, v)
143143
}
144144
}

states/etcd/show/collection_history.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"errors"
66
"fmt"
7-
"strings"
87

98
"github.com/milvus-io/birdwatcher/framework"
109
"github.com/milvus-io/birdwatcher/models"
@@ -60,16 +59,15 @@ type CollectionHistory struct {
6059
func (rs *CollectionHistory) PrintAs(format framework.Format) string {
6160
switch format {
6261
case framework.FormatDefault, framework.FormatPlain:
63-
sb := &strings.Builder{}
64-
printCollection(sb, rs.Collection)
62+
printCollection(rs.Collection)
6563
for _, item := range rs.HistoryItems {
6664
t, _ := utils.ParseTS(item.Ts)
67-
fmt.Fprintln(sb, "Snapshot at", t.Format("2006-01-02 15:04:05"))
65+
fmt.Printf( "Snapshot at", t.Format("2006-01-02 15:04:05"))
6866
if item.Dropped {
69-
fmt.Fprintln(sb, "Collection Dropped")
67+
fmt.Printf( "Collection Dropped")
7068
continue
7169
}
72-
printCollection(sb, &item.Collection)
70+
printCollection(&item.Collection)
7371
}
7472
default:
7573
}

0 commit comments

Comments
 (0)