Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

name: op-attr-set-popcount
description: Per-row popcount of a set field — number of selected labels.
kind: operator
category: ATTR
operator: ATTR_SET_POPCOUNT
type: reference
applies_to: process, compose, predict
examples_tags: [feature-engineering, cardinality-analysis, streaming-friendly]

Attributes emit row-level scalars; they do not produce Response.Components.

Use when

Adds to every row the number of options its multi-select field has selected.

Questions it answers:

  • How many reasons did each respondent tick?
  • Which customers selected three or more interests?

Use something else:

  • AGG_SET_CARDINALITY_AVG when you want the average number of selections per group.
  • ATTR_SET_HAS when you want whether one particular option was chosen.

Params

None.

Inputs

ParamAccepted field types
Fieldany set rung — set_u8, set_u16, set_u32, set_u64, set_u128, set_u256
Labelrequired — new column name

Output

One integer per record, 0..set width inclusive — 0..256 at set_u256, hence emits_type u16, not u8. Empty mask → 0 (valid, distinct from null). Null source → 0 (not null).

Gotchas

  • Row-local one-pass — streams cleanly.
  • Use as a downstream filterable signal (“respondents who selected ≥ 3 issues”) — pair with FILTER_GTE after this attribute, or precompute as FEAT if you need it before the filterers slot.
  • A fully-selected set_u256 gives 256, one past a u8’s 255 — size any destination column from emits_type, not from the rung’s byte width.

See