Skip to content

Let the bin grid travel with the aggregation result #37

Open

Description

@jvdd

Problem

Histogram, Histogram2D and GeoHistogram2D keep per-request state on the trace instance. get_aggregation_spec stores the grid it binned on (Histogram._bin_edges, Histogram2D._grid, GeoHistogram2D._grid, plus the _*_temporal_dtype fields), and _to_update reads it back. The engine builds one trace per request, so this works. But the order "spec before update" is a hidden part of the interface: nothing in the signatures shows it, and _to_update cannot be called on a frame alone.

The result already carries most of the grid. The 2-D kernel echoes x_lo, x_hi, y_lo, y_hi but not the bin counts, so a zoomed grid (snapped to the lattice, bins or bins + 1 per axis) cannot be unpacked from the struct. The 1-D kernel echoes one breakpoint per bin; the 1-D plans emit counts only.

Proposal

Let the grid travel with the result, so _to_update is a pure function of the frame:

  1. fixed_hist returns {lo, step, n, count: List} instead of one breakpoint per bin. The 1-D fold and the grouped streaming plan emit the same struct.
  2. fixed_hist2d and fixed_hist2d_reduce add nb_x and nb_y to the echoed struct. The 2-D fold emits the same.
  3. _to_update reads the grid from the struct. Delete _bin_edges and _grid.
  4. The temporal dtype is not derivable from the frame. Pass it in, for example as one source-info value that get_aggregation_spec and _to_update both take.
  5. Mirror the 1-D shape in histDeltaFromCounts (runtime/cube.js) and check the cube target dim path.

Scope

Rust kernels (flexviz_polars/src/expressions.rs), the two folds and the grouped plan, three traces, the cube mirror, and their tests. Output on the wire does not change: the delta already sends [lo, step, n] triples.

Done when

  • No trace sets state in get_aggregation_spec that _to_update reads.
  • Resident and scan output stay identical on the existing resident-vs-scan tests.
  • The 1-D result frame is smaller than today (three scalars instead of one breakpoint per bin).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions