pond-ts API Reference (core)
    Preparing search index...

    Class LiveRollingAggregation<S, Out>

    Type Parameters

    Index

    Constructors

    • Type Parameters

      Parameters

      • source: LiveSource<S>
      • window: RollingWindow
      • mapping:
            | Readonly<
                Record<
                    string,
                    | AggregateReducer
                    | Readonly<
                        {
                            from: ValueColumnsForSchema<S>[number]["name"];
                            kind?: ScalarKind | undefined;
                            using: AggregateFunctionsForKind<
                                Extract<
                                    ValueColumnsForSchema<(...)>[number],
                                    ColumnDef<(...)[(...)], ScalarKind>,
                                >["kind"],
                            >;
                        },
                    >,
                >,
            >
            | Readonly<
                Record<
                    string,
                    | AggregateReducer
                    | Readonly<
                        {
                            from: ValueColumnsForSchema<S>[number]["name"];
                            kind?: ScalarKind | undefined;
                            using: AggregateFunctionsForKind<
                                Extract<
                                    ValueColumnsForSchema<(...)>[number],
                                    ColumnDef<(...)[(...)], ScalarKind>,
                                >["kind"],
                            >;
                        },
                    >,
                >,
            >
      • options: LiveRollingOptions = {}

      Returns LiveRollingAggregation<S, Out>

    Properties

    name: string
    schema: Out

    Accessors

    Methods

    • Type Parameters

      • const M extends
            | Readonly<
                Record<
                    string,
                    | AggregateReducer
                    | Readonly<
                        {
                            from: ValueColumnsForSchema<Out>[number]["name"];
                            kind?: ScalarKind | undefined;
                            using: AggregateFunctionsForKind<
                                Extract<
                                    ValueColumnsForSchema<(...)>[number],
                                    ColumnDef<(...)[(...)], ScalarKind>,
                                >["kind"],
                            >;
                        },
                    >,
                >,
            >
            | {
                readonly [K in string
                | number
                | symbol]: K extends ValueColumnsForSchema<Out>[number]["name"]
                    ?
                        | Readonly<
                            {
                                from: ValueColumnsForSchema<Out>[number]["name"];
                                kind?: ScalarKind;
                                using: AggregateFunctionsForKind<
                                    Extract<
                                        ValueColumnsForSchema<(...)>[number],
                                        ColumnDef<(...)[(...)], ScalarKind>,
                                    >["kind"],
                                >;
                            },
                        >
                        | AggregateFunctionsForKind<
                            ColumnKindByName<ValueColumnsForSchema<Out>, K & string>,
                        >
                    : string extends K
                        ? | AggregateReducer
                        | Readonly<
                            {
                                from: ValueColumnsForSchema<Out>[number]["name"];
                                kind?: ScalarKind | undefined;
                                using: AggregateFunctionsForKind<
                                    Extract<(...)[(...)], ColumnDef<(...), (...)>>["kind"],
                                >;
                            },
                        >
                        : Readonly<
                            {
                                from: ValueColumnsForSchema<Out>[number]["name"];
                                kind?: ScalarKind;
                                using: AggregateFunctionsForKind<
                                    Extract<
                                        ValueColumnsForSchema<(...)>[number],
                                        ColumnDef<(...)[(...)], ScalarKind>,
                                    >["kind"],
                                >;
                            },
                        >
            }

      Parameters

      Returns LiveAggregation<
          Out,
          readonly [
              ColumnDef<"interval", "interval">,
              AggregateColumns<ValueColumnsForSchema<Out>, M>,
          ],
      >

    • Type Parameters

      • const M extends Readonly<
            Record<
                string,
                | AggregateReducer
                | Readonly<
                    {
                        from: ValueColumnsForSchema<Out>[number]["name"];
                        kind?: ScalarKind | undefined;
                        using: AggregateFunctionsForKind<
                            Extract<
                                ValueColumnsForSchema<Out>[number],
                                ColumnDef<(...)[(...)]["name"], ScalarKind>,
                            >["kind"],
                        >;
                    },
                >,
            >,
        >

      Parameters

      Returns LiveAggregation<
          Out,
          readonly [
              ColumnDef<"interval", "interval">,
              AggregateColumns<ValueColumnsForSchema<Out>, M>,
          ],
      >

    • Type Parameters

      • const Targets extends string

      Parameters

      • spec: {
            [K in string]:
                | "sum"
                | "min"
                | "max"
                | "count"
                | ((acc: number, value: number) => number)
        }

      Returns LiveView<
          readonly [
              Out[0],
              ReplaceSmoothedColumn<ValueColumnsForSchema<Out>, Targets>,
          ],
      >

    • Pipeline stats snapshot — cumulative counters since construction plus current window state. Cheap O(1).

      • eventsObserved: total source events ingested. Includes events replayed at construction from a non-empty source. Never decreases.
      • evictions: total entries removed from the window by retention. Never decreases.
      • emissions: total output events fired. Never decreases. Always <= eventsObserved; for Trigger.event it equals eventsObserved, for Trigger.count(n) and Trigger.clock it can be smaller.
      • windowSize: current live window size (= this.windowSize).

      Use case: long-running pipelines that want headline counters without wiring rolling.on('event', ...) listeners by hand.

      Returns {
          emissions: number;
          eventsObserved: number;
          evictions: number;
          windowSize: number;
      }