SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
s3tables: implement token-based pagination for namespace listing
Chris Lubabf1b06acbf
diff --git a/weed/s3api/s3tables/handler_namespace.go b/weed/s3api/s3tables/handler_namespace.goindex d45641195f..87d4ee3baf 100644--- a/weed/s3api/s3tables/handler_namespace.go+++ b/weed/s3api/s3tables/handler_namespace.go@@ -220,14 +220,14 @@ func (h *S3TablesHandler) handleListNamespaces(w http.ResponseWriter, r *http.RebucketPath := getTableBucketPath(bucketName)var namespaces []NamespaceSummary- var lastFileName string+ lastFileName := req.ContinuationTokenerr = filerClient.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {for len(namespaces) < maxNamespaces {resp, err := client.ListEntries(r.Context(), &filer_pb.ListEntriesRequest{Directory: bucketPath,Limit: uint32(maxNamespaces * 2),StartFromFileName: lastFileName,- InclusiveStartFrom: lastFileName == "",+ InclusiveStartFrom: lastFileName == "" || lastFileName == req.ContinuationToken,})if err != nil {return err@@ -245,6 +245,12 @@ func (h *S3TablesHandler) handleListNamespaces(w http.ResponseWriter, r *http.Reif entry.Entry == nil {continue}++ // Skip the start item if it was included in the previous page+ if len(namespaces) == 0 && req.ContinuationToken != "" && entry.Entry.Name == req.ContinuationToken {+ continue+ }+hasMore = truelastFileName = entry.Entry.Name@@ -300,8 +306,14 @@ func (h *S3TablesHandler) handleListNamespaces(w http.ResponseWriter, r *http.Re}}+ paginationToken := ""+ if len(namespaces) >= maxNamespaces {+ paginationToken = lastFileName+ }+resp := &ListNamespacesResponse{- Namespaces: namespaces,+ Namespaces: namespaces,+ ContinuationToken: paginationToken,}h.writeJSON(w, http.StatusOK, resp)