From 82df627a24cb65df922ea6f88edf2c042c6c604c Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Thu, 19 Nov 2026 22:20:56 -0800 Subject: [PATCH] admin: indexed metadata keys panel on the S3 Vectors bucket page Each index of a vector bucket gets a card: dimension, metric, vectors and vector index type; its indexed metadata keys with state, coverage of the table's rows, filtered queries per hour and index size, with Remove for a ready key and Cancel for a requested or building one; and the keys its queries filtered on most in the last hour that are not indexed, with their average latency. A key filtered only with numbers is marked "(numeric: phase 2)" and has no Index button. "+ Index a key" and a listed key's Index button open a dialog for the key, which refuses the index's non-filterable keys. Adding or removing goes through the engine; the admin then dispatches the lance_metadata_index job for that key when a worker can run it, and detection finds it otherwise. Filter stats are read from every registered engine and summed per hour over each engine's window. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK --- weed/admin/dash/s3vectors_management.go | 12 + weed/admin/dash/s3vectors_metadata_keys.go | 260 +++++++++ .../dash/s3vectors_metadata_keys_test.go | 33 ++ weed/admin/handlers/admin_handlers.go | 1 + .../view/app/s3vectors_bucket_details.templ | 222 +++++++ .../app/s3vectors_bucket_details_templ.go | 548 +++++++++++++++++- .../view/app/s3vectors_bucket_details_test.go | 11 + 7 files changed, 1063 insertions(+), 24 deletions(-) create mode 100644 weed/admin/dash/s3vectors_metadata_keys.go create mode 100644 weed/admin/dash/s3vectors_metadata_keys_test.go create mode 100644 weed/admin/view/app/s3vectors_bucket_details_test.go diff --git a/weed/admin/dash/s3vectors_management.go b/weed/admin/dash/s3vectors_management.go index d3055d3e52..500b7dbe70 100644 --- a/weed/admin/dash/s3vectors_management.go +++ b/weed/admin/dash/s3vectors_management.go @@ -12,6 +12,7 @@ import ( "github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants" "github.com/seaweedfs/seaweedfs/weed/s3api/s3tables" "github.com/seaweedfs/seaweedfs/weed/s3api/s3vectors" + "golang.org/x/sync/errgroup" ) type S3VectorsBucketsData struct { @@ -36,6 +37,7 @@ type S3VectorsBucketData struct { Bucket S3VectorsBucketSummary `json:"bucket"` Policy string `json:"policy,omitempty"` Indexes []*s3vectors.Index `json:"indexes"` + Panels []S3VectorsIndexPanel `json:"panels"` Operations VectorOperationsData `json:"operations"` TotalIndexes int `json:"total_indexes"` Truncated bool `json:"truncated,omitempty"` @@ -159,6 +161,16 @@ func (s *AdminServer) GetS3VectorsBucketData(ctx context.Context, bucket string) } data.Operations = s.GetVectorOperationsData(ctx) data.TotalIndexes = len(data.Indexes) + data.Panels = make([]S3VectorsIndexPanel, len(data.Indexes)) + var panels errgroup.Group + panels.SetLimit(8) + for i, index := range data.Indexes { + panels.Go(func() error { + data.Panels[i] = s.s3VectorsIndexPanel(ctx, bucket, index, data.Operations.Engines) + return nil + }) + } + _ = panels.Wait() return data, nil } diff --git a/weed/admin/dash/s3vectors_metadata_keys.go b/weed/admin/dash/s3vectors_metadata_keys.go new file mode 100644 index 0000000000..0357f09b0e --- /dev/null +++ b/weed/admin/dash/s3vectors_metadata_keys.go @@ -0,0 +1,260 @@ +package dash + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + "sort" + "time" + + "github.com/google/uuid" + "github.com/seaweedfs/seaweedfs/weed/glog" + "github.com/seaweedfs/seaweedfs/weed/pb" + "github.com/seaweedfs/seaweedfs/weed/pb/plugin_pb" + "github.com/seaweedfs/seaweedfs/weed/pb/vector_pb" + "github.com/seaweedfs/seaweedfs/weed/s3api/s3vectors" + "golang.org/x/sync/errgroup" +) + +// metadataIndexJobType is the worker job that adds, maintains and removes +// indexed metadata keys. +const metadataIndexJobType = "lance_metadata_index" + +// frequentFilterKeys caps the "frequently filtered, not indexed" list. +const frequentFilterKeys = 10 + +// S3VectorsIndexPanel is one index's card on the bucket page: its vector +// count and vector index, its indexed metadata keys, and the keys its +// queries filter on most that are not indexed. +type S3VectorsIndexPanel struct { + Index *s3vectors.Index `json:"index"` + Vectors uint64 `json:"vectors"` + VectorIndex string `json:"vector_index"` + Keys []S3VectorsMetadataKeyRow `json:"keys"` + Frequent []S3VectorsFilterKeyRow `json:"frequent"` + Error string `json:"error,omitempty"` + StatsError string `json:"stats_error,omitempty"` + stats map[string]*filterKeyTotal `json:"-"` +} + +type S3VectorsMetadataKeyRow struct { + Key string `json:"key"` + State string `json:"state"` + Coverage float64 `json:"coverage"` + QueriesPerHour float64 `json:"queries_per_hour"` + IndexBytes uint64 `json:"index_bytes"` +} + +type S3VectorsFilterKeyRow struct { + Key string `json:"key"` + QueriesPerHour float64 `json:"queries_per_hour"` + AvgMs float64 `json:"avg_ms"` + // Numeric marks a key filtered only with numbers, which phase 1 does + // not index. + Numeric bool `json:"numeric"` +} + +type filterKeyTotal struct { + perHour float64 + seconds float64 + queries uint64 + strings bool + numbers bool +} + +// s3VectorsIndexPanel reads one index's keys from its table through an +// engine, and its filter stats from every registered engine. +func (s *AdminServer) s3VectorsIndexPanel(ctx context.Context, bucket string, index *s3vectors.Index, engines []VectorNode) S3VectorsIndexPanel { + panel := S3VectorsIndexPanel{Index: index, Keys: []S3VectorsMetadataKeyRow{}, Frequent: []S3VectorsFilterKeyRow{}} + keys, err := s.s3VectorsServer.MetadataKeys(ctx, bucket, index.IndexName) + if err != nil { + panel.Error = err.Error() + } + stats, err := s.s3VectorsFilterStats(ctx, bucket, index.IndexName, engines) + if err != nil { + panel.StatsError = err.Error() + } + panel.stats = stats + indexed := map[string]bool{} + if keys != nil { + panel.Vectors = keys.Rows + panel.VectorIndex = keys.VectorIndex + for _, k := range keys.Keys { + indexed[k.Key] = true + row := S3VectorsMetadataKeyRow{Key: k.Key, State: k.State, IndexBytes: k.IndexBytes} + if k.Rows > 0 { + row.Coverage = float64(k.IndexedRows) * 100 / float64(k.Rows) + } + if total := stats[k.Key]; total != nil { + row.QueriesPerHour = total.perHour + } + panel.Keys = append(panel.Keys, row) + } + } + nonFilterable := map[string]bool{} + if index.MetadataConfiguration != nil { + for _, k := range index.MetadataConfiguration.NonFilterableMetadataKeys { + nonFilterable[k] = true + } + } + for key, total := range stats { + if indexed[key] || nonFilterable[key] || (!total.strings && !total.numbers) { + continue + } + row := S3VectorsFilterKeyRow{Key: key, QueriesPerHour: total.perHour, Numeric: !total.strings} + if total.queries > 0 { + row.AvgMs = total.seconds * 1000 / float64(total.queries) + } + panel.Frequent = append(panel.Frequent, row) + } + sort.Slice(panel.Frequent, func(i, j int) bool { + if panel.Frequent[i].QueriesPerHour != panel.Frequent[j].QueriesPerHour { + return panel.Frequent[i].QueriesPerHour > panel.Frequent[j].QueriesPerHour + } + return panel.Frequent[i].Key < panel.Frequent[j].Key + }) + if len(panel.Frequent) > frequentFilterKeys { + panel.Frequent = panel.Frequent[:frequentFilterKeys] + } + return panel +} + +// s3VectorsFilterStats sums an index's filter stats over the engines, each +// counted per hour over its own window. +func (s *AdminServer) s3VectorsFilterStats(ctx context.Context, bucket, index string, engines []VectorNode) (map[string]*filterKeyTotal, error) { + responses := make([]*vector_pb.FilterStatsResponse, len(engines)) + errs := make([]error, len(engines)) + var calls errgroup.Group + calls.SetLimit(8) + for i, engine := range engines { + calls.Go(func() error { + ctx, cancel := context.WithTimeout(ctx, 3*time.Second) + defer cancel() + conn, err := pb.GrpcDial(ctx, engine.Address, false, s.grpcDialOption) + if err != nil { + errs[i] = err + return nil + } + defer conn.Close() + responses[i], errs[i] = vector_pb.NewVectorServiceClient(conn).FilterStats(ctx, &vector_pb.FilterStatsRequest{ + Table: &vector_pb.Table{Id: []string{bucket, "vector", index}}, + }) + return nil + }) + } + _ = calls.Wait() + return sumFilterStats(responses), firstError(engines, errs) +} + +func sumFilterStats(responses []*vector_pb.FilterStatsResponse) map[string]*filterKeyTotal { + out := map[string]*filterKeyTotal{} + for _, resp := range responses { + if resp == nil || resp.WindowSeconds == 0 { + continue + } + for _, k := range resp.Keys { + total := out[k.Key] + if total == nil { + total = &filterKeyTotal{} + out[k.Key] = total + } + total.perHour += float64(k.Queries) * 3600 / float64(resp.WindowSeconds) + total.queries += k.Queries + total.seconds += k.Seconds + total.strings = total.strings || k.StringOperand + total.numbers = total.numbers || k.NumberOperand + } + } + return out +} + +func firstError(engines []VectorNode, errs []error) error { + for i, err := range errs { + if err != nil { + return fmt.Errorf("filter stats from %s: %w", engines[i].Address, err) + } + } + return nil +} + +// UpdateS3VectorsMetadataKeyAPI asks to index a metadata key (POST) or to +// stop (DELETE), then dispatches the worker job that carries it out. +func (s *AdminServer) UpdateS3VectorsMetadataKeyAPI(w http.ResponseWriter, r *http.Request) { + if !requireSessionCSRFToken(w, r) { + return + } + var req struct { + Bucket string `json:"bucket"` + Index string `json:"index"` + Key string `json:"key"` + } + if r.Method == http.MethodDelete { + q := r.URL.Query() + req.Bucket, req.Index, req.Key = q.Get("bucket"), q.Get("index"), q.Get("key") + } else if err := json.NewDecoder(http.MaxBytesReader(w, r.Body, 1<<16)).Decode(&req); err != nil { + writeJSONError(w, http.StatusBadRequest, "invalid request body: "+err.Error()) + return + } + if req.Bucket == "" || req.Index == "" || req.Key == "" { + writeJSONError(w, http.StatusBadRequest, "bucket, index and key are required") + return + } + remove := r.Method == http.MethodDelete + keys, err := s.s3VectorsServer.UpdateMetadataKey(r.Context(), req.Bucket, req.Index, req.Key, remove) + if err != nil { + writeJSONError(w, http.StatusBadRequest, err.Error()) + return + } + // A withdrawn request leaves nothing for a worker to do. + action := "add" + if remove { + action = "" + for _, k := range keys.GetKeys() { + if k.Key == req.Key && k.State == "off" { + action = "remove" + } + } + } + dispatched := false + if action != "" { + dispatched = s.dispatchMetadataIndexJob(req.Bucket, req.Index, req.Key, action) + } + writeJSON(w, http.StatusOK, map[string]interface{}{"keys": keys.GetKeys(), "job_dispatched": dispatched}) +} + +// dispatchMetadataIndexJob runs the job for one key in the background when +// a worker can; otherwise the job's detection finds the work. +func (s *AdminServer) dispatchMetadataIndexJob(bucket, index, key, action string) bool { + if s.plugin == nil || !s.hasCapableWorker(metadataIndexJobType) { + return false + } + job := &plugin_pb.JobSpec{ + JobId: uuid.NewString(), + JobType: metadataIndexJobType, + DedupeKey: fmt.Sprintf("%s:%s$vector$%s:%s:%s", metadataIndexJobType, bucket, index, key, action), + Summary: fmt.Sprintf("%s metadata key %s of %s/%s", action, key, bucket, index), + Parameters: map[string]*plugin_pb.ConfigValue{ + "table_id": {Kind: &plugin_pb.ConfigValue_StringList{StringList: &plugin_pb.StringList{Values: []string{bucket, "vector", index}}}}, + "key": {Kind: &plugin_pb.ConfigValue_StringValue{StringValue: key}}, + "action": {Kind: &plugin_pb.ConfigValue_StringValue{StringValue: action}}, + }, + } + go func() { + ctx, cancel := context.WithTimeout(context.Background(), time.Hour) + defer cancel() + if _, err := s.ExecutePluginJob(ctx, job, s.buildDefaultPluginClusterContext(), 1); err != nil { + glog.Warningf("%s for %s/%s key %s: %v", metadataIndexJobType, bucket, index, key, err) + } + }() + return true +} + +func (s *AdminServer) hasCapableWorker(jobType string) bool { + for _, worker := range s.GetPluginWorkers() { + if capability := worker.Capabilities[jobType]; capability != nil && capability.CanExecute { + return true + } + } + return false +} diff --git a/weed/admin/dash/s3vectors_metadata_keys_test.go b/weed/admin/dash/s3vectors_metadata_keys_test.go new file mode 100644 index 0000000000..69ce57aa78 --- /dev/null +++ b/weed/admin/dash/s3vectors_metadata_keys_test.go @@ -0,0 +1,33 @@ +package dash + +import ( + "math" + "testing" + + "github.com/seaweedfs/seaweedfs/weed/pb/vector_pb" +) + +func TestSumFilterStatsPerHourAcrossEngines(t *testing.T) { + got := sumFilterStats([]*vector_pb.FilterStatsResponse{ + {WindowSeconds: 3600, Keys: []*vector_pb.FilterKeyStats{ + {Key: "author", Queries: 100, Seconds: 2, StringOperand: true}, + {Key: "year", Queries: 10, Seconds: 0.5, NumberOperand: true}, + }}, + // An engine up for half an hour counts double per hour. + {WindowSeconds: 1800, Keys: []*vector_pb.FilterKeyStats{ + {Key: "author", Queries: 50, Seconds: 1, StringOperand: true}, + }}, + nil, + {WindowSeconds: 0, Keys: []*vector_pb.FilterKeyStats{{Key: "ignored", Queries: 5}}}, + }) + author := got["author"] + if author == nil || math.Abs(author.perHour-200) > 1e-9 || author.queries != 150 || math.Abs(author.seconds-3) > 1e-9 || !author.strings { + t.Fatalf("author: %+v", author) + } + if year := got["year"]; year == nil || year.strings || !year.numbers || year.perHour != 10 { + t.Fatalf("year: %+v", year) + } + if _, ok := got["ignored"]; ok { + t.Fatal("an engine with no window must not count") + } +} diff --git a/weed/admin/handlers/admin_handlers.go b/weed/admin/handlers/admin_handlers.go index b3a33cd638..41d4c2bd32 100644 --- a/weed/admin/handlers/admin_handlers.go +++ b/weed/admin/handlers/admin_handlers.go @@ -264,6 +264,7 @@ func (h *AdminHandlers) registerAPIRoutes(api *mux.Router, enforceWrite bool) { s3VectorsApi.Handle("/buckets", wrapWrite(h.adminServer.DeleteS3VectorsBucket)).Methods(http.MethodDelete) s3VectorsApi.HandleFunc("/indexes", h.adminServer.GetS3VectorsBucketAPI).Methods(http.MethodGet) s3VectorsApi.Handle("/indexes", wrapWrite(h.adminServer.DeleteS3VectorsIndex)).Methods(http.MethodDelete) + s3VectorsApi.Handle("/metadata-keys", wrapWrite(h.adminServer.UpdateS3VectorsMetadataKeyAPI)).Methods(http.MethodPost, http.MethodDelete) filesApi := api.PathPrefix("/files").Subrouter() filesApi.Handle("/delete", wrapWrite(h.fileBrowserHandlers.DeleteFile)).Methods(http.MethodDelete) diff --git a/weed/admin/view/app/s3vectors_bucket_details.templ b/weed/admin/view/app/s3vectors_bucket_details.templ index 7d14103739..85e5e11f1d 100644 --- a/weed/admin/view/app/s3vectors_bucket_details.templ +++ b/weed/admin/view/app/s3vectors_bucket_details.templ @@ -7,6 +7,7 @@ import ( "strings" "github.com/seaweedfs/seaweedfs/weed/admin/dash" + "github.com/seaweedfs/seaweedfs/weed/s3api/s3vectors" ) templ S3VectorsBucketDetails(data dash.S3VectorsBucketData) { @@ -103,6 +104,9 @@ templ S3VectorsBucketDetails(data dash.S3VectorsBucketData) { + for _, panel := range data.Panels { + @S3VectorsIndexPanel(panel) + }
@@ -138,6 +142,30 @@ templ S3VectorsBucketDetails(data dash.S3VectorsBucketData) {
+
} +templ S3VectorsIndexPanel(panel dash.S3VectorsIndexPanel) { +
+
+
+ Index: { panel.Index.IndexName } +
+
+ { fmt.Sprintf("Dimension %d", panel.Index.Dimension) } · { panel.Index.DistanceMetric } · { groupDigits(float64(panel.Vectors)) } vectors · Vector index: + if panel.VectorIndex != "" { + { panel.VectorIndex } + } else { + none (exact scan) + } +
+
+
+ if panel.Error != "" { +
{ panel.Error }
+ } +
+ Metadata indexes + +
+
+ + + + + + + + + + + + + for _, key := range panel.Keys { + + + + + + + + + } + if len(panel.Keys) == 0 { + + + + } + +
KeyStateCoverageFiltered queries/hSize
{ key.Key }{ keyState(key.State) } + if key.State == "requested" { + — + } else { + { fmt.Sprintf("%.0f%%", key.Coverage) } + } + { groupDigits(key.QueriesPerHour) } + if key.IndexBytes > 0 { + { fmt.Sprintf("%.1f MiB", float64(key.IndexBytes)/(1<<20)) } + } else { + — + } + + if key.State == "ready" { + + } else if key.State == "requested" || key.State == "building" { + + } +
No indexed metadata keys.
+
+ Frequently filtered, not indexed + if panel.StatsError != "" { +
{ panel.StatsError }
+ } + if len(panel.Frequent) == 0 { +
No filtered queries in the last hour on keys without an index.
+ } +
    + for _, key := range panel.Frequent { +
  • + { key.Key } + { groupDigits(key.QueriesPerHour) } queries/h + { fmt.Sprintf("avg %.0f ms", key.AvgMs) } + if key.Numeric { + (numeric: phase 2) + } else { + + } +
  • + } +
+
+
+} + +func keyState(state string) string { + switch state { + case "requested": + return "Requested" + case "building": + return "Building" + case "ready": + return "Ready" + case "off": + return "Removing" + } + return state +} + +// groupDigits renders n rounded, with thousands separators. +func groupDigits(n float64) string { + digits := fmt.Sprintf("%.0f", n) + var out []byte + for i := range digits { + if i > 0 && (len(digits)-i)%3 == 0 { + out = append(out, ',') + } + out = append(out, digits[i]) + } + return string(out) +} + +func nonFilterableJSON(index *s3vectors.Index) string { + keys := []string{} + if index.MetadataConfiguration != nil { + keys = index.MetadataConfiguration.NonFilterableMetadataKeys + } + b, _ := json.Marshal(keys) + return string(b) +} + const maxIndentedJSONDepth = 32 func indentJSON(s string) string { diff --git a/weed/admin/view/app/s3vectors_bucket_details_templ.go b/weed/admin/view/app/s3vectors_bucket_details_templ.go index c5b9fd0990..15fbc44560 100644 --- a/weed/admin/view/app/s3vectors_bucket_details_templ.go +++ b/weed/admin/view/app/s3vectors_bucket_details_templ.go @@ -16,6 +16,7 @@ import ( "strings" "github.com/seaweedfs/seaweedfs/weed/admin/dash" + "github.com/seaweedfs/seaweedfs/weed/s3api/s3vectors" ) func S3VectorsBucketDetails(data dash.S3VectorsBucketData) templ.Component { @@ -42,7 +43,7 @@ func S3VectorsBucketDetails(data dash.S3VectorsBucketData) templ.Component { var templ_7745c5c3_Var2 string templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(data.Bucket.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 16, Col: 63} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 17, Col: 63} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) if templ_7745c5c3_Err != nil { @@ -55,7 +56,7 @@ func S3VectorsBucketDetails(data dash.S3VectorsBucketData) templ.Component { var templ_7745c5c3_Var3 string templ_7745c5c3_Var3, templ_7745c5c3_Err = templruntime.NewAttributeExpression(dash.PUrl(ctx, "/object-store/vector-buckets")).ResolveURL(ctx) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 20, Col: 89} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 21, Col: 89} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var3) if templ_7745c5c3_Err != nil { @@ -68,7 +69,7 @@ func S3VectorsBucketDetails(data dash.S3VectorsBucketData) templ.Component { var templ_7745c5c3_Var4 string templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(data.Bucket.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 21, Col: 78} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 22, Col: 78} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { @@ -93,7 +94,7 @@ func S3VectorsBucketDetails(data dash.S3VectorsBucketData) templ.Component { var templ_7745c5c3_Var5 string templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(data.Bucket.ARN) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 32, Col: 49} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 33, Col: 49} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) if templ_7745c5c3_Err != nil { @@ -106,7 +107,7 @@ func S3VectorsBucketDetails(data dash.S3VectorsBucketData) templ.Component { var templ_7745c5c3_Var6 string templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(data.Bucket.CreatedAt.Format("2006-01-02 15:04:05")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 34, Col: 79} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 35, Col: 79} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) if templ_7745c5c3_Err != nil { @@ -124,7 +125,7 @@ func S3VectorsBucketDetails(data dash.S3VectorsBucketData) templ.Component { var templ_7745c5c3_Var7 string templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(data.Bucket.Encryption) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 38, Col: 61} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 39, Col: 61} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) if templ_7745c5c3_Err != nil { @@ -147,7 +148,7 @@ func S3VectorsBucketDetails(data dash.S3VectorsBucketData) templ.Component { var templ_7745c5c3_Var8 string templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d indexes", data.TotalIndexes)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 49, Col: 84} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 50, Col: 84} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) if templ_7745c5c3_Err != nil { @@ -165,7 +166,7 @@ func S3VectorsBucketDetails(data dash.S3VectorsBucketData) templ.Component { var templ_7745c5c3_Var9 string templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("showing the first %d; list the rest with an S3 Vectors client", data.TotalIndexes)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 51, Col: 138} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 52, Col: 138} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) if templ_7745c5c3_Err != nil { @@ -188,7 +189,7 @@ func S3VectorsBucketDetails(data dash.S3VectorsBucketData) templ.Component { var templ_7745c5c3_Var10 string templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(index.IndexName) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 73, Col: 26} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 74, Col: 26} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) if templ_7745c5c3_Err != nil { @@ -201,7 +202,7 @@ func S3VectorsBucketDetails(data dash.S3VectorsBucketData) templ.Component { var templ_7745c5c3_Var11 string templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(index.IndexArn) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 74, Col: 55} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 75, Col: 55} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) if templ_7745c5c3_Err != nil { @@ -214,7 +215,7 @@ func S3VectorsBucketDetails(data dash.S3VectorsBucketData) templ.Component { var templ_7745c5c3_Var12 string templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(index.DataType) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 76, Col: 28} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 77, Col: 28} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12)) if templ_7745c5c3_Err != nil { @@ -227,7 +228,7 @@ func S3VectorsBucketDetails(data dash.S3VectorsBucketData) templ.Component { var templ_7745c5c3_Var13 string templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", index.Dimension)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 77, Col: 48} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 78, Col: 48} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13)) if templ_7745c5c3_Err != nil { @@ -240,7 +241,7 @@ func S3VectorsBucketDetails(data dash.S3VectorsBucketData) templ.Component { var templ_7745c5c3_Var14 string templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(index.DistanceMetric) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 78, Col: 34} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 79, Col: 34} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) if templ_7745c5c3_Err != nil { @@ -258,7 +259,7 @@ func S3VectorsBucketDetails(data dash.S3VectorsBucketData) templ.Component { var templ_7745c5c3_Var15 string templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(strings.Join(index.MetadataConfiguration.NonFilterableMetadataKeys, ", ")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 81, Col: 91} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 82, Col: 91} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15)) if templ_7745c5c3_Err != nil { @@ -281,7 +282,7 @@ func S3VectorsBucketDetails(data dash.S3VectorsBucketData) templ.Component { var templ_7745c5c3_Var16 string templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(index.CreationTime.Format("2006-01-02 15:04")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 86, Col: 59} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 87, Col: 59} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16)) if templ_7745c5c3_Err != nil { @@ -294,7 +295,7 @@ func S3VectorsBucketDetails(data dash.S3VectorsBucketData) templ.Component { var templ_7745c5c3_Var17 string templ_7745c5c3_Var17, templ_7745c5c3_Err = templruntime.NewAttributeExpression(index.IndexName).Resolve(ctx) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 88, Col: 129} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 89, Col: 129} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var17) if templ_7745c5c3_Err != nil { @@ -311,48 +312,58 @@ func S3VectorsBucketDetails(data dash.S3VectorsBucketData) templ.Component { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "
Bucket Policy
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + for _, panel := range data.Panels { + templ_7745c5c3_Err = S3VectorsIndexPanel(panel).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "
Bucket Policy
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if data.Policy != "" { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "
")
+			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "
")
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
 			var templ_7745c5c3_Var18 string
 			templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(indentJSON(data.Policy))
 			if templ_7745c5c3_Err != nil {
-				return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 114, Col: 102}
+				return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 118, Col: 102}
 			}
 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18))
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
-			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } else { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "No policy. Set one with PutVectorBucketPolicy.") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "No policy. Set one with PutVectorBucketPolicy.") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "
Delete Index

Delete the index and all its vectors?

Delete Index

Delete the index and all its vectors?

Index a metadata key of
Filters comparing this key with strings ($eq, $in) read its index instead of every row's metadata. Results do not change.
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -360,6 +371,495 @@ func S3VectorsBucketDetails(data dash.S3VectorsBucketData) templ.Component { }) } +func S3VectorsIndexPanel(panel dash.S3VectorsIndexPanel) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "
Index: ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var22 string + templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(panel.Index.IndexName) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 264, Col: 70} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var23 string + templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("Dimension %d", panel.Index.Dimension)) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 267, Col: 56} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, " · ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var24 string + templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(panel.Index.DistanceMetric) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 267, Col: 90} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, " · ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var25 string + templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(groupDigits(float64(panel.Vectors))) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 267, Col: 133} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, " vectors · Vector index: ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if panel.VectorIndex != "" { + var templ_7745c5c3_Var26 string + templ_7745c5c3_Var26, templ_7745c5c3_Err = templ.JoinStringErrs(panel.VectorIndex) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 269, Col: 24} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var26)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 42, "none (exact scan)") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 43, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if panel.Error != "" { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 44, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var27 string + templ_7745c5c3_Var27, templ_7745c5c3_Err = templ.JoinStringErrs(panel.Error) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 277, Col: 61} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var27)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 45, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 46, "
Metadata indexes
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + for _, key := range panel.Keys { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 49, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + if len(panel.Keys) == 0 { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 64, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 65, "
KeyStateCoverageFiltered queries/hSize
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var30 string + templ_7745c5c3_Var30, templ_7745c5c3_Err = templ.JoinStringErrs(key.Key) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 300, Col: 27} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var30)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 50, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var31 string + templ_7745c5c3_Var31, templ_7745c5c3_Err = templ.JoinStringErrs(keyState(key.State)) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 301, Col: 33} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var31)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 51, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if key.State == "requested" { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 52, "—") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + var templ_7745c5c3_Var32 string + templ_7745c5c3_Var32, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%.0f%%", key.Coverage)) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 306, Col: 47} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var32)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 53, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var33 string + templ_7745c5c3_Var33, templ_7745c5c3_Err = templ.JoinStringErrs(groupDigits(key.QueriesPerHour)) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 309, Col: 45} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var33)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 54, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if key.IndexBytes > 0 { + var templ_7745c5c3_Var34 string + templ_7745c5c3_Var34, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%.1f MiB", float64(key.IndexBytes)/(1<<20))) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 312, Col: 68} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var34)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 55, "—") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 56, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if key.State == "ready" { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 57, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else if key.State == "requested" || key.State == "building" { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 60, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 63, "
No indexed metadata keys.
Frequently filtered, not indexed ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if panel.StatsError != "" { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 66, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var39 string + templ_7745c5c3_Var39, templ_7745c5c3_Err = templ.JoinStringErrs(panel.StatsError) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 336, Col: 52} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var39)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 67, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + if len(panel.Frequent) == 0 { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 68, "
No filtered queries in the last hour on keys without an index.
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 69, "
    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + for _, key := range panel.Frequent { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 70, "
  • ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var40 string + templ_7745c5c3_Var40, templ_7745c5c3_Err = templ.JoinStringErrs(key.Key) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 344, Col: 34} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var40)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 71, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var41 string + templ_7745c5c3_Var41, templ_7745c5c3_Err = templ.JoinStringErrs(groupDigits(key.QueriesPerHour)) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 345, Col: 58} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var41)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 72, " queries/h ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var42 string + templ_7745c5c3_Var42, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("avg %.0f ms", key.AvgMs)) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/app/s3vectors_bucket_details.templ`, Line: 346, Col: 75} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var42)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 73, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if key.Numeric { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 74, "(numeric: phase 2)") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 75, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 79, "
  • ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 80, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +func keyState(state string) string { + switch state { + case "requested": + return "Requested" + case "building": + return "Building" + case "ready": + return "Ready" + case "off": + return "Removing" + } + return state +} + +// groupDigits renders n rounded, with thousands separators. +func groupDigits(n float64) string { + digits := fmt.Sprintf("%.0f", n) + var out []byte + for i := range digits { + if i > 0 && (len(digits)-i)%3 == 0 { + out = append(out, ',') + } + out = append(out, digits[i]) + } + return string(out) +} + +func nonFilterableJSON(index *s3vectors.Index) string { + keys := []string{} + if index.MetadataConfiguration != nil { + keys = index.MetadataConfiguration.NonFilterableMetadataKeys + } + b, _ := json.Marshal(keys) + return string(b) +} + const maxIndentedJSONDepth = 32 func indentJSON(s string) string { diff --git a/weed/admin/view/app/s3vectors_bucket_details_test.go b/weed/admin/view/app/s3vectors_bucket_details_test.go new file mode 100644 index 0000000000..7e6aa918e0 --- /dev/null +++ b/weed/admin/view/app/s3vectors_bucket_details_test.go @@ -0,0 +1,11 @@ +package app + +import "testing" + +func TestGroupDigits(t *testing.T) { + for n, want := range map[float64]string{0: "0", 999: "999", 1000: "1,000", 12400: "12,400", 2140312: "2,140,312", 8899.6: "8,900"} { + if got := groupDigits(n); got != want { + t.Errorf("groupDigits(%v) = %q, want %q", n, got, want) + } + } +}