Class: CrossIndex
Defined in: packages/core/src/engine/crossindex.ts:260
The cross-filter index. Synchronous, single-threaded, no DOM: the worker and local engines both wrap one of these.
Every row has a Uint32 mask with bit d set when the row fails dimension d's filter. A group on dimension d aggregates rows whose mask is zero once bit d is ignored ("exclude self"). Changing one filter only visits rows in bins whose state changed, and only rows whose bit flips touch the aggregates. Rows inside a bin are sorted by value, so a range that cuts through a bin only visits the rows between the old and new cut.
On large tables, a drag on one binned dimension switches to prefix-sum tiles: one pass builds them, and then every frame costs a few lookups per bin of the other charts, however far the brush moved. A box brush on a grid dimension (a heatmap or map), or two binned dimensions brushed in turn, use 2-D tiles (summed-area tables) the same way, once their frames are slow. Those take seconds to build on the largest tables, so they are built a slice at a time, in each update and in CrossIndex.work, while the drag goes on incrementally. The first change to any other dimension writes the mask back and drops the tiles (or the build).
Constructors
Constructor
new CrossIndex(options?): CrossIndex;Defined in: packages/core/src/engine/crossindex.ts:282
Parameters
| Parameter | Type |
|---|---|
options? | CrossIndexOptions |
Returns
CrossIndex
Accessors
pending
Get Signature
get pending(): boolean;Defined in: packages/core/src/engine/crossindex.ts:867
Whether background work is pending: a 2-D tile build for a box drag, or two range brushes moved in turn, on a large table. Call work in idle time to finish it sooner; updates also advance it.
Returns
boolean
rowCount
Get Signature
get rowCount(): number;Defined in: packages/core/src/engine/crossindex.ts:300
Returns
number
Methods
addDimension()
addDimension(id, spec): DimensionInfo;Defined in: packages/core/src/engine/crossindex.ts:304
Parameters
| Parameter | Type |
|---|---|
id | string |
spec | DimensionSpec |
Returns
addGroup()
addGroup(
id,
dimensionId,
aggregate
): Float64Array;Defined in: packages/core/src/engine/crossindex.ts:355
Add an aggregate over a dimension's bins. Returns the aggregate with no filters applied (one value per bin), which charts can draw as a baseline.
Parameters
| Parameter | Type |
|---|---|
id | string |
dimensionId | string |
aggregate | AggregateSpec |
Returns
Float64Array
load()
load(table): void;Defined in: packages/core/src/engine/crossindex.ts:286
Parameters
| Parameter | Type |
|---|---|
table | ColumnTable |
Returns
void
removeDimension()
removeDimension(id): void;Defined in: packages/core/src/engine/crossindex.ts:337
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
void
removeGroup()
removeGroup(id): void;Defined in: packages/core/src/engine/crossindex.ts:391
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
void
result()
result(version): UpdateResult;Defined in: packages/core/src/engine/crossindex.ts:1330
Parameters
| Parameter | Type |
|---|---|
version | number |
Returns
rows()
rows(query?): RowsResult;Defined in: packages/core/src/engine/crossindex.ts:1340
Rows passing every filter, optionally sorted ("-field" for descending) and paged.
Parameters
| Parameter | Type |
|---|---|
query? | RowsQuery |
Returns
setFilter()
setFilter(id, filter): void;Defined in: packages/core/src/engine/crossindex.ts:423
Parameters
| Parameter | Type |
|---|---|
id | string |
filter | Filter | null |
Returns
void
update()
update(filters, version): UpdateResult;Defined in: packages/core/src/engine/crossindex.ts:403
Apply a full filter state; dimensions absent from it are cleared.
Parameters
| Parameter | Type |
|---|---|
filters | FilterState |
version | number |
Returns
work()
work(ms): boolean;Defined in: packages/core/src/engine/crossindex.ts:876
Spend up to ms milliseconds on pending background work (see pending), at least one small step. Results don't change. Returns whether work remains. The worker engine calls this between messages.
Parameters
| Parameter | Type |
|---|---|
ms | number |
Returns
boolean