Files
seaweedfs/weed/parquet_pushdown/stats.go
T
Chris Lu e610dad2a1 parquet_pushdown(M0-C2): add service skeleton and request validation
Implement the gRPC service surface of the pushdown daemon:

- Service struct embeds the generated UnimplementedSeaweed
  ParquetPushdownServer, exposes Ping (returns version + trust mode)
  and Pushdown (returns Unimplemented after request-shape validation).
- request_validation.go enforces hard caps (max data files, columns,
  predicate bytes, row-id cap, vector dim, top_k) and content-type
  rules (Puffin DV requires blob_length + referenced_data_file;
  equality delete requires equality_field_ids; predicate_kind and
  predicate must be set together).
- stats.go is a small accumulator that produces a PushdownStats
  message stamped with trust_mode and elapsed micros; M0 wires it
  into the Unimplemented status's details so the stats wire format
  is exercised end to end.
- TrustMode constants encode the design's catalog-validated
  (default) and connector-trusted (dev-only) modes.

Unit tests cover the validation matrix (rejects empty/oversize
requests, accepts well-formed vector queries, accepts well-formed
deletion-vector descriptors, rejects DVs missing blob_length /
referenced_data_file).
2026-04-25 13:39:28 -07:00

40 lines
1.1 KiB
Go

package parquet_pushdown
import (
"time"
pb "github.com/seaweedfs/seaweedfs/weed/pb/parquet_pushdown_pb"
)
// statsRecorder accumulates per-request stats and converts to the
// wire form when the handler returns. M0 only records trust mode and
// elapsed server time; later milestones extend it with cache hits,
// pruning counts, and indexes-used / indexes-missing labels.
type statsRecorder struct {
start time.Time
trustMode TrustMode
indexesUsed []string
indexesMissing []string
}
func newStats(trustMode TrustMode) *statsRecorder {
return &statsRecorder{start: time.Now(), trustMode: trustMode}
}
func (r *statsRecorder) markIndexUsed(kind string) {
r.indexesUsed = append(r.indexesUsed, kind)
}
func (r *statsRecorder) markIndexMissing(kind string) {
r.indexesMissing = append(r.indexesMissing, kind)
}
func (r *statsRecorder) toProto() *pb.PushdownStats {
return &pb.PushdownStats{
TrustMode: string(r.trustMode),
ServerTimeMicros: time.Since(r.start).Microseconds(),
IndexesUsed: r.indexesUsed,
IndexesMissing: r.indexesMissing,
}
}