Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix for Collection-History #345

Open
wants to merge 1 commit into
base: v1.0.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions states/etcd/show/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@
case framework.FormatDefault, framework.FormatPlain:
sb := &strings.Builder{}
for _, coll := range rs.collections {
printCollection(sb, coll)
printCollection( coll)

Check failure on line 86 in states/etcd/show/collection.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/milvus-io) --custom-order (gci)
}
fmt.Fprintln(sb, "================================================================================")
fmt.Fprintf(sb, "--- Total collections: %d\t Matched collections: %d\n", rs.total, len(rs.collections))
fmt.Fprintf(sb, "--- Total channel: %d\t Healthy collections: %d\n", rs.channels, rs.healthy)
fmt.Printf( "================================================================================")

Check failure on line 88 in states/etcd/show/collection.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/milvus-io) --custom-order (gci)
fmt.Printf( "--- Total collections: %d\t Matched collections: %d\n", rs.total, len(rs.collections))
fmt.Printf( "--- Total channel: %d\t Healthy collections: %d\n", rs.channels, rs.healthy)
return sb.String()
}
return ""
Expand All @@ -97,48 +97,48 @@
return rs.collections
}

func printCollection(sb *strings.Builder, collection *models.Collection) {
fmt.Fprintln(sb, "================================================================================")
fmt.Fprintf(sb, "DBID: %d\n", collection.DBID)
fmt.Fprintf(sb, "Collection ID: %d\tCollection Name: %s\n", collection.ID, collection.Schema.Name)
func printCollection( collection *models.Collection) {

Check failure on line 100 in states/etcd/show/collection.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/milvus-io) --custom-order (gci)
fmt.Printf( "================================================================================")
fmt.Printf( "DBID: %d\n", collection.DBID)
fmt.Printf( "Collection ID: %d\tCollection Name: %s\n", collection.ID, collection.Schema.Name)
t, _ := utils.ParseTS(collection.CreateTime)
fmt.Fprintf(sb, "Collection State: %s\tCreate Time: %s\n", collection.State.String(), t.Format("2006-01-02 15:04:05"))
fmt.Fprintf(sb, "Fields:\n")
fmt.Printf( "Collection State: %s\tCreate Time: %s\n", collection.State.String(), t.Format("2006-01-02 15:04:05"))

Check failure on line 105 in states/etcd/show/collection.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/milvus-io) --custom-order (gci)
fmt.Printf( "Fields:\n")
fields := collection.Schema.Fields
sort.Slice(fields, func(i, j int) bool {
return fields[i].FieldID < fields[j].FieldID
})
for _, field := range fields {
fmt.Fprintf(sb, " - Field ID: %d \t Field Name: %s \t Field Type: %s\n", field.FieldID, field.Name, field.DataType.String())
fmt.Printf( " - Field ID: %d \t Field Name: %s \t Field Type: %s\n", field.FieldID, field.Name, field.DataType.String())

Check failure on line 112 in states/etcd/show/collection.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/milvus-io) --custom-order (gci)
if field.IsPrimaryKey {
fmt.Fprintf(sb, "\t - Primary Key: %t, AutoID: %t\n", field.IsPrimaryKey, field.AutoID)
fmt.Printf( "\t - Primary Key: %t, AutoID: %t\n", field.IsPrimaryKey, field.AutoID)

Check failure on line 114 in states/etcd/show/collection.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/milvus-io) --custom-order (gci)
}
if field.IsDynamic {
fmt.Fprintf(sb, "\t - Dynamic Field\n")
fmt.Printf( "\t - Dynamic Field\n")

Check failure on line 117 in states/etcd/show/collection.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/milvus-io) --custom-order (gci)
}
if field.IsPartitionKey {
fmt.Fprintf(sb, "\t - Partition Key\n")
fmt.Printf( "\t - Partition Key\n")

Check failure on line 120 in states/etcd/show/collection.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/milvus-io) --custom-order (gci)
}
if field.IsClusteringKey {
fmt.Fprintf(sb, "\t - Clustering Key\n")
fmt.Printf( "\t - Clustering Key\n")

Check failure on line 123 in states/etcd/show/collection.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/milvus-io) --custom-order (gci)
}
// print element type if field is array
if field.DataType == models.DataTypeArray {
fmt.Fprintf(sb, "\t - Element Type: %s\n", field.ElementType.String())
fmt.Printf( "\t - Element Type: %s\n", field.ElementType.String())

Check failure on line 127 in states/etcd/show/collection.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/milvus-io) --custom-order (gci)
}
// type params
for key, value := range field.Properties {
fmt.Fprintf(sb, "\t - Type Param %s: %s\n", key, value)
fmt.Printf( "\t - Type Param %s: %s\n", key, value)
}
}

fmt.Fprintf(sb, "Enable Dynamic Schema: %t\n", collection.Schema.EnableDynamicSchema)
fmt.Fprintf(sb, "Consistency Level: %s\n", collection.ConsistencyLevel.String())
fmt.Printf( "Enable Dynamic Schema: %t\n", collection.Schema.EnableDynamicSchema)
fmt.Printf( "Consistency Level: %s\n", collection.ConsistencyLevel.String())
for _, channel := range collection.Channels {
fmt.Fprintf(sb, "Start position for channel %s(%s): %v\n", channel.PhysicalName, channel.VirtualName, channel.StartPosition.MsgID)
fmt.Printf( "Start position for channel %s(%s): %v\n", channel.PhysicalName, channel.VirtualName, channel.StartPosition.MsgID)
}
fmt.Fprintf(sb, "Collection properties(%d):\n", len(collection.Properties))
fmt.Printf( "Collection properties(%d):\n", len(collection.Properties))
for k, v := range collection.Properties {
fmt.Fprintf(sb, "\tKey: %s: %v\n", k, v)
fmt.Printf( "\tKey: %s: %v\n", k, v)
}
}
10 changes: 4 additions & 6 deletions states/etcd/show/collection_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"errors"
"fmt"
"strings"

"github.com/milvus-io/birdwatcher/framework"
"github.com/milvus-io/birdwatcher/models"
Expand Down Expand Up @@ -60,16 +59,15 @@ type CollectionHistory struct {
func (rs *CollectionHistory) PrintAs(format framework.Format) string {
switch format {
case framework.FormatDefault, framework.FormatPlain:
sb := &strings.Builder{}
printCollection(sb, rs.Collection)
printCollection(rs.Collection)
for _, item := range rs.HistoryItems {
t, _ := utils.ParseTS(item.Ts)
fmt.Fprintln(sb, "Snapshot at", t.Format("2006-01-02 15:04:05"))
fmt.Printf( "Snapshot at", t.Format("2006-01-02 15:04:05"))
if item.Dropped {
fmt.Fprintln(sb, "Collection Dropped")
fmt.Printf( "Collection Dropped")
continue
}
printCollection(sb, &item.Collection)
printCollection(&item.Collection)
}
default:
}
Expand Down