• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

visgl / luma.gl / 28177788537

25 Jun 2026 02:33PM UTC coverage: 70.237% (-0.2%) from 70.408%
28177788537

Pull #2693

github

web-flow
Merge 7a40eab51 into b23218729
Pull Request #2693: [codex] clean up GPU table inputs and constructors

9607 of 15509 branches covered (61.94%)

Branch coverage included in aggregate %.

81 of 157 new or added lines in 9 files covered. (51.59%)

9 existing lines in 2 files now uncovered.

19235 of 25555 relevant lines covered (75.27%)

4233.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.51
/modules/arrow/src/arrow/renderers/path/source/arrow-path-source-mapping.ts
1
// luma.gl
2
// SPDX-License-Identifier: MIT
3
// Copyright (c) vis.gl contributors
4

5
import {RecordBatch, Table, Vector, type DataType} from 'apache-arrow';
6
import type {GPUInputDeclaration, GPUInputSchema} from '@luma.gl/tables';
7
import type {ArrowPathSourceVectors} from '../conversion/arrow-path-gpu-vectors';
8
import {getArrowPaths, getArrowVectorByPath} from '../../../arrow-utils/arrow-paths';
9

10
type ArrowVectorDataType<VectorT extends Vector> =
11
  VectorT extends Vector<infer TypeT> ? TypeT : DataType;
12
type ArrowPathSourceInputName = keyof ArrowPathMappedSourceVectors;
13

14
/** Raw Arrow table or record batch accepted by path source mapping helpers. */
15
export type ArrowPathSourceData = Table | RecordBatch;
16
/** Raw Arrow column selector accepted by path source mapping helpers. */
17
export type ArrowColumnSelector<TypeT extends DataType = DataType> = string | Vector<TypeT>;
18
/** Optional raw Arrow column selector accepted by path source mapping helpers. */
19
export type OptionalArrowColumnSelector<TypeT extends DataType = DataType> =
20
  | ArrowColumnSelector<TypeT>
21
  | null
22
  | undefined;
23
/** Raw Arrow selectors keyed by source-mappable path-family GPU input names. */
24
export type ArrowPathSourceVectorSelectors = {
25
  /** Source path coordinate column. Defaults to `paths`. */
26
  paths?: ArrowColumnSelector<ArrowVectorDataType<ArrowPathSourceVectors['paths']>>;
27
  /** Source path color column. Defaults to `colors`; `null` disables it. */
28
  colors?: OptionalArrowColumnSelector<
29
    ArrowVectorDataType<NonNullable<ArrowPathSourceVectors['colors']>>
30
  >;
31
  /** Source path width column. Defaults to `widths`; `null` disables it. */
32
  widths?: OptionalArrowColumnSelector<
33
    ArrowVectorDataType<NonNullable<ArrowPathSourceVectors['widths']>>
34
  >;
35
  /** Source path timestamp column. Defaults to `timestamps`; `null` disables it. */
36
  timestamps?: OptionalArrowColumnSelector<
37
    ArrowVectorDataType<NonNullable<ArrowPathSourceVectors['timestamps']>>
38
  >;
39
};
40
/** Schema-bearing Arrow path-family model constructor accepted by source mapping helpers. */
41
export type ArrowPathSourceMappingModel = {
42
  /** Runtime prepared GPU input contract. */
43
  readonly gpuInputSchema: GPUInputSchema;
44
  /** Constructor name used in mapping errors when available. */
45
  readonly name?: string;
46
};
47
/** Props for resolving raw Arrow path-family source columns. */
48
export type ResolveArrowPathSourceVectorsProps = {
49
  /** Raw Arrow table or record batch containing same-name or selected source columns. */
50
  data?: ArrowPathSourceData | null;
51
  /** Explicit raw Arrow column selectors keyed by declared source-mappable inputs. */
52
  selectors?: ArrowPathSourceVectorSelectors;
53
};
54
/** Source-mapped raw Arrow path vectors before source-only inputs such as `closed` are added. */
55
export type ArrowPathMappedSourceVectors = Omit<ArrowPathSourceVectors, 'closed'>;
56

57
/** Resolves raw Arrow path-family source vectors from one schema-bearing model declaration. */
58
export function resolveArrowPathSourceVectors(
59
  model: ArrowPathSourceMappingModel,
60
  props: ResolveArrowPathSourceVectorsProps = {}
×
61
): ArrowPathMappedSourceVectors {
62
  const modelName = model.name || 'PathModel';
9!
63
  const selectors = props.selectors || {};
9✔
64
  const table = getArrowPathSourceTable(props.data);
9✔
65
  const availablePaths = new Set(table ? getArrowPaths(table) : []);
9✔
66
  const sourceMappableInputs = getArrowPathSourceMappableInputs(model.gpuInputSchema);
9✔
67

68
  assertArrowPathSourceSelectors(modelName, sourceMappableInputs, selectors);
9✔
69

70
  const sourceVectors: Partial<ArrowPathMappedSourceVectors> = {};
8✔
71
  for (const input of sourceMappableInputs) {
8✔
72
    if (!isArrowPathSourceInputName(input.columnName)) {
25!
NEW
73
      throw new Error(
×
74
        `${modelName} source mapping does not support GPU input "${input.columnName}"`
75
      );
76
    }
77
    const vector = resolveArrowPathSourceVector(
25✔
78
      modelName,
79
      input,
80
      selectors[input.columnName],
81
      table,
82
      availablePaths
83
    );
84
    if (vector) {
23✔
85
      setArrowPathSourceVector(sourceVectors, input.columnName, vector);
19✔
86
    }
87
  }
88

89
  if (!sourceVectors.paths) {
6!
90
    throw new Error(`${modelName} source mapping requires paths`);
×
91
  }
92

93
  return sourceVectors as ArrowPathMappedSourceVectors;
6✔
94
}
95

96
function getArrowPathSourceTable(data: ArrowPathSourceData | null | undefined): Table | undefined {
97
  if (!data) {
9✔
98
    return undefined;
2✔
99
  }
100
  return data instanceof Table ? data : new Table([data]);
7✔
101
}
102

103
function getArrowPathSourceMappableInputs(schema: GPUInputSchema): GPUInputDeclaration[] {
104
  return schema.filter(input => !input.internal);
39✔
105
}
106

107
function assertArrowPathSourceSelectors(
108
  modelName: string,
109
  sourceMappableInputs: GPUInputDeclaration[],
110
  selectors: ArrowPathSourceVectorSelectors
111
): void {
112
  const sourceMappableInputNames = new Set(sourceMappableInputs.map(input => input.columnName));
30✔
113
  for (const [inputName, selector] of Object.entries(selectors)) {
9✔
114
    if (selector !== undefined && !sourceMappableInputNames.has(inputName)) {
8✔
115
      throw new Error(
1✔
116
        `${modelName} source selector "${inputName}" is not declared as source-mappable`
117
      );
118
    }
119
  }
120
}
121

122
function resolveArrowPathSourceVector(
123
  modelName: string,
124
  input: GPUInputDeclaration,
125
  selector: OptionalArrowColumnSelector,
126
  table: Table | undefined,
127
  availablePaths: Set<string>
128
): Vector | undefined {
129
  if (selector === null) {
25✔
130
    if (input.required) {
1!
NEW
131
      throw new Error(`${modelName} source selector "${input.columnName}" cannot be null`);
×
132
    }
133
    return undefined;
1✔
134
  }
135
  if (selector instanceof Vector) {
24✔
136
    return selector;
2✔
137
  }
138

139
  const columnPath = selector ?? input.columnName;
22✔
140
  if (!table) {
22✔
141
    if (selector === undefined && !input.required) {
1!
142
      return undefined;
1✔
143
    }
144
    throw new Error(
×
145
      `${modelName} source selector "${input.columnName}" requires data to resolve column "${columnPath}"`
146
    );
147
  }
148
  if (!availablePaths.has(columnPath)) {
21✔
149
    if (selector === undefined && !input.required) {
4✔
150
      return undefined;
2✔
151
    }
152
    throw new Error(
2✔
153
      `${modelName} source column "${columnPath}" for "${input.columnName}" is missing`
154
    );
155
  }
156

157
  return getArrowVectorByPath(table, columnPath);
17✔
158
}
159

160
function isArrowPathSourceInputName(inputName: string): inputName is ArrowPathSourceInputName {
161
  return (
25✔
162
    inputName === 'paths' ||
55✔
163
    inputName === 'colors' ||
164
    inputName === 'widths' ||
165
    inputName === 'timestamps'
166
  );
167
}
168

169
function setArrowPathSourceVector<InputName extends ArrowPathSourceInputName>(
170
  sourceVectors: Partial<ArrowPathMappedSourceVectors>,
171
  inputName: InputName,
172
  vector: Vector
173
): void {
174
  sourceVectors[inputName] = vector as ArrowPathMappedSourceVectors[InputName];
19✔
175
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc