Skip to content

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 ​

ts
new CrossIndex(options?): CrossIndex;

Defined in: packages/core/src/engine/crossindex.ts:282

Parameters ​

ParameterType
options?CrossIndexOptions

Returns ​

CrossIndex

Accessors ​

pending ​

Get Signature ​

ts
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 ​

ts
get rowCount(): number;

Defined in: packages/core/src/engine/crossindex.ts:300

Returns ​

number

Methods ​

addDimension() ​

ts
addDimension(id, spec): DimensionInfo;

Defined in: packages/core/src/engine/crossindex.ts:304

Parameters ​

ParameterType
idstring
specDimensionSpec

Returns ​

DimensionInfo


addGroup() ​

ts
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 ​

ParameterType
idstring
dimensionIdstring
aggregateAggregateSpec

Returns ​

Float64Array


load() ​

ts
load(table): void;

Defined in: packages/core/src/engine/crossindex.ts:286

Parameters ​

ParameterType
tableColumnTable

Returns ​

void


removeDimension() ​

ts
removeDimension(id): void;

Defined in: packages/core/src/engine/crossindex.ts:337

Parameters ​

ParameterType
idstring

Returns ​

void


removeGroup() ​

ts
removeGroup(id): void;

Defined in: packages/core/src/engine/crossindex.ts:391

Parameters ​

ParameterType
idstring

Returns ​

void


result() ​

ts
result(version): UpdateResult;

Defined in: packages/core/src/engine/crossindex.ts:1330

Parameters ​

ParameterType
versionnumber

Returns ​

UpdateResult


rows() ​

ts
rows(query?): RowsResult;

Defined in: packages/core/src/engine/crossindex.ts:1340

Rows passing every filter, optionally sorted ("-field" for descending) and paged.

Parameters ​

ParameterType
query?RowsQuery

Returns ​

RowsResult


setFilter() ​

ts
setFilter(id, filter): void;

Defined in: packages/core/src/engine/crossindex.ts:423

Parameters ​

ParameterType
idstring
filterFilter | null

Returns ​

void


update() ​

ts
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 ​

ParameterType
filtersFilterState
versionnumber

Returns ​

UpdateResult


work() ​

ts
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 ​

ParameterType
msnumber

Returns ​

boolean

Released under the MIT License.