package engine import ( "context" "errors" "github.com/seaweedfs/seaweedfs/weed/mq/logstore" "github.com/seaweedfs/seaweedfs/weed/mq/topic" "github.com/seaweedfs/seaweedfs/weed/mq/topictable" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/pb/mq_pb" icebergcatalog "github.com/seaweedfs/seaweedfs/weed/s3api/iceberg" ) // topicTable is the Iceberg table the scanned topic's topic.conf names, nil // when it names none, read once per scanner. func (hms *HybridMessageScanner) topicTable(ctx context.Context) (*mq_pb.TopicTable, error) { hms.tableOnce.Do(func() { if hms.filerClient == nil { return } hms.tableErr = hms.filerClient.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error { conf, _, err := hms.topic.ReadConfFileWithMetadata(ctx, client) if errors.Is(err, filer_pb.ErrNotFound) { return nil } if err != nil { return err } hms.table = conf.Table return nil }) if hms.tableErr == nil && hms.table != nil { hms.tableViews = topictable.NewTables(icebergcatalog.NewServer(hms.filerClient, nil), hms.filerClient) } }) return hms.table, hms.tableErr } // partitionTable hands the scan of partition p below its table's high-water // mark to the topic's table, its data files pruned by _partition, _offset and // _ts_ns, looked up under the query's ctx. func (hms *HybridMessageScanner) partitionTable(ctx context.Context, p topic.Partition) logstore.PartitionTable { name := topictable.PartitionName(hms.topic, p) return func() (logstore.TableReader, error) { tt, err := hms.topicTable(ctx) if err != nil || tt == nil { return nil, err } view, err := hms.tableViews.View(ctx, hms.topic, tt, topictable.ViewRefresh) if err != nil { return nil, err } return view.Partition(name), nil } }