Skip to main content

GPU Dataframe indexes and joins

Join or look up unique right-side keys​

GPU Dataframe supports bounded, unique-right-key inner, left outer, semi, and anti joins, together with source-aligned lookups. Left and right tables may have different batch topologies, empty chunks, nullable keys, and explicit original source-row offsets. The right-side hash index is built directly from its original batches. Keys use packed uint32, sint32, or float32. Mixed integer formats match only on their shared range. Both sides use float32 for a floating-point join. Numeric keys are prepared per batch. Float32 compares signed zeros as equal and skips NaN keys. Int32 supports the full signed range.

const joined = customers
.filter(column('customerId').isValid())
.innerJoin(accounts, {
leftOn: 'customerId',
rightOn: 'accountId',
capacity: 1024,
indexCapacity: 4096,
maxProbeCount: 64
})
.compile(new GPUCommandGraph<GPUDataFrameQueryParameters>(device));

joined.rowIndices;
joined.rightRowIndices;
joined.rightValidity;
joined.joinType;
joined.requiredCounts;
joined.selectedCounts;
joined.overflows;
joined.indexStatistics;
joined.lookupStatistics;
joined.contractViolation;
joined.rightTable;

const leftOuter = customers
.leftJoin(accounts, {leftOn: 'customerId', rightOn: 'accountId'})
.compile(new GPUCommandGraph<GPUDataFrameQueryParameters>(device));

const matchedCustomers = customers
.semiJoin(accounts, {leftOn: 'customerId', rightOn: 'accountId'})
.compile(new GPUCommandGraph<GPUDataFrameQueryParameters>(device));

const unmatchedCustomers = customers
.antiJoin(accounts, {leftOn: 'customerId', rightOn: 'accountId'})
.compile(new GPUCommandGraph<GPUDataFrameQueryParameters>(device));

const lookups = customers
.lookup(accounts, {leftOn: 'customerId', rightOn: 'accountId'})
.compile(new GPUCommandGraph<GPUDataFrameQueryParameters>(device));

lookups.rowIndices;
lookups.rightRowIndices;
lookups.matchMask;
lookups.probeCounts;
lookups.indexStatistics;
lookups.contractViolation;

For every join, rowIndices and rightRowIndices contain paired stable source identifiers; selectedCounts gives the published prefix while requiredCounts reports all selected result rows before capacity truncation. overflows flags insufficient output capacity per original left batch. rightValidity is a compacted, GPU-resident uint32 sidecar: 1 means a right partner exists; 0 means the published left row is unmatched and its right identifier is the reserved 0xffffffff marker.

  • innerJoin publishes only matching left rows and their right partners.
  • leftJoin publishes every selected left row, including missing and nullable left keys, and explicitly marks unmatched right partners through rightValidity.
  • semiJoin publishes only selected left rows with an existing right partner.
  • antiJoin publishes only selected unmatched left rows, including nullable left keys; every published rightValidity entry is zero.
  • lookup preserves source-aligned right identifiers and exposes a match flag and probe count for every left row without compacting the original batches.

All four join modes support the same capacity, indexCapacity, and maxProbeCount options and compose with filtered, projected, or derived left plans. Publication remains stable within each original left batch; no implicit global row ordering or source-column materialization occurs.

To include right payloads in an inner or left join, call compileWithRightColumns:

const compiled = trips.leftJoin(accounts, {leftOn: 'accountId', rightOn: 'id'})
.compileWithRightColumns(graph, {
rightColumns: {accountPosition: 'position'},
maxJoinProjectionScratchBytes: 1_048_576
});

The alias follows the selected left fields and inherits the right column's packed numeric format. Read the joined rows using compiled.rowIndices and compiled.selectedCounts. The projected validity mask marks unmatched left rows and null right payloads. The optional budget caps staging for right values and validity across all projected fields. Zero selects direct gathers.

The six GPU-resident index statistic words are, in order, unique entries, duplicate keys, index overflow, invalid keys, total probe count, and maximum probe count. For UInt32-to-UInt32 joins, a valid key equal to 0xffffffff is reserved. Null right keys and Float32 NaNs are ignored. Int32 -1 uses a separate slot and contributes to the same unique-entry and duplicate counters. Duplicate right keys, reserved valid keys, or incomplete hash-index construction set contractViolation and suppress all published rows in every join mode instead of returning ambiguous results or treating an incomplete index as missing matches. Dictionary-encoded keys must have identical labels and ordering on both sides.

Bounded joins with repeated or composite keys​

Use joinPairs when either side can repeat a key or matching requires multiple fields. Specify a global capacity for the GPU-resident output. The graph emits pairs in left batch and row order, then in right batch and row order within each left row.

const result = customers.joinPairs(
activity,
{
keys: [
{left: 'regionId', right: 'regionId'},
{left: 'customerId', right: 'customerId'}
],
type: 'left',
capacity: 65536
},
new GPUCommandGraph(device)
);

const encoder = device.createCommandEncoder();
result.encode(encoder);
device.submit(encoder.finish());

Use the compiled CompiledGPUDataFrameJoinPairs result to consume the prefix of leftRowIndices and rightRowIndices identified by the published count. counts contains the required count, the published count, and an overflow flag. A capacity of zero counts pairs without publishing rows. rightValidity distinguishes unmatched left rows and existence-join results from valid right IDs. Inner and left joins emit every matching pair. Semi and anti joins emit at most one row per left row.

Keys support one to four packed 32-bit scalar comparisons. Float32 treats signed zero as equal. Null and NaN key components never match. Mixed signed and unsigned integers compare within their common numeric range. Dictionary keys require identical labels and ordering.

The GPU counts candidates in bounded right-side tiles and scans counts before writing pairs. Working storage grows with source rows and the explicit output capacity, without a materialized Cartesian product. Comparison work can still grow as the product of input row counts. The worst-case pair count must fit Uint32. The compiled result keeps source buffers alive until destroy() and publishes source IDs for downstream gathers.

GPU SQL uses the unique-right join path. Right and full outer joins and raw string-key hashing remain outside the current native join surface.

Expand Arrow lists and maps on the GPU​

Use compileGPUUnnestFromArrow with an Arrow List, FixedSizeList, or Map column. Child fields use packed Int32, Uint32, or Float32 storage. The adapter uploads offsets, validity, and original flattened values. WebGPU computes the expansion counts and writes the result.

import {compileGPUUnnestFromArrow} from '@luma.gl/graph/arrow';

const expanded = compileGPUUnnestFromArrow(
new GPUCommandGraph(device),
records.getChild('items')!,
{type: 'left', capacity: 65536}
);

const encoder = device.createCommandEncoder();
expanded.encode(encoder);
device.submit(encoder.finish());

The CompiledGPUDataFrameUnnest result exposes a capacity-backed GPU table with zero-based parentIndex, one-based ordinality, and a value field. Maps also emit a key field. Null child values retain their positions. A left expansion emits one row with null ordinality and child fields for an empty or null collection. A cross expansion skips those parents.

Pass the result to makeArrowTableFromGPUAnalyticsTable for explicit CPU readback. On the GPU, consume the prefix indicated by selectedCounts. The two counts words report the required row count and whether capacity truncated the output. A capacity of zero counts results without publishing rows. Call destroy() after downstream GPU consumers finish using the compiled result.

Share GPU outputs with rendering and GPUCrossfilter​

Visualization shaders can consume compiled.selectionMask, compiled.rowIndices, aggregated GPU columns, and joined source-row identifiers directly as storage or vertex buffers. Import the same existing table vectors into a separate GPUCrossfilter graph when an application needs linked ranges, brushes, histograms, or visibility views:

const interactionGraph = new GPUCommandGraph(device);
const fare = interactionGraph.importGPUVector('fare', dataframe.table.gpuVectors.fare);
const category = interactionGraph.importGPUVector('category', dataframe.table.gpuVectors.category);

const fareValidity = dataframe.validity.fare
? interactionGraph.importGPUVector('fare-validity', dataframe.validity.fare)
: undefined;

GPUCrossfilter and other lower-level consumers do not automatically interpret GPU Dataframe's nullable sidecars; combine the explicit validity mask into their selection before treating nullable values as valid. Sharing vectors does not transfer ownership, merge source batches, or require CPU row readback.