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

keplergl / kepler.gl / 23880914138

02 Apr 2026 02:34AM UTC coverage: 60.661% (-1.0%) from 61.699%
23880914138

Pull #3271

github

web-flow
Merge f1dfa1060 into bc59e880b
Pull Request #3271: chore: deck.gl 9.2 upgrade & loaders.gl, luma.gl upgrades

6519 of 12785 branches covered (50.99%)

Branch coverage included in aggregate %.

270 of 740 new or added lines in 50 files covered. (36.49%)

102 existing lines in 12 files now uncovered.

13280 of 19854 relevant lines covered (66.89%)

79.44 hits per line

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

38.1
/src/utils/src/data-container-utils.ts
1
// SPDX-License-Identifier: MIT
2
// Copyright contributors to the kepler.gl project
3

4
import {ArrowDataContainer} from './arrow-data-container';
5
import {RowDataContainer} from './row-data-container';
6
import {IndexedDataContainer} from './indexed-data-container';
7

8
import {DataContainerInterface} from './data-container-interface';
9
import {ProtoDatasetField} from '@kepler.gl/types';
10
import * as arrow from 'apache-arrow';
11

12
export type DataContainerOptions = {
13
  inputDataFormat?: string; // one of DataForm
14
  fields?: ProtoDatasetField[];
15
  arrowTable?: arrow.Table;
16
};
17

18
export const DataForm = {
15✔
19
  ROWS_ARRAY: 'ROWS_ARRAY',
20
  COLS_ARRAY: 'COLS_ARRAY'
21
};
22

23
const defaultOptions: DataContainerOptions = {
15✔
24
  inputDataFormat: DataForm.ROWS_ARRAY
25
};
26

27
/**
28
 * Creates a data container wrapper for the data.
29
 * @param data Data.
30
 * @param options Options.
31
 * @returns A data container object which is based on data and options.
32
 */
33
export function createDataContainer(
34
  data: any[],
35
  options: DataContainerOptions = defaultOptions
179✔
36
): DataContainerInterface {
37
  options = {...defaultOptions, ...options};
341✔
38

39
  if (options.inputDataFormat === DataForm.ROWS_ARRAY) {
341!
40
    return new RowDataContainer({rows: data, fields: options.fields});
341✔
41
  } else if (options.inputDataFormat === DataForm.COLS_ARRAY) {
×
NEW
42
    return new ArrowDataContainer({
×
43
      cols: data,
44
      fields: options.fields,
45
      arrowTable: options.arrowTable
46
    });
47
  }
48

UNCOV
49
  throw Error('Failed to create a data container: not implemented format');
×
50
}
51

52
/**
53
 * Creates a data container wrapper around another data container.
54
 * @param dataContainer Parent data container.
55
 * @param indices An array of row indices in the parent data container.
56
 */
57
export function createIndexedDataContainer(
58
  dataContainer: DataContainerInterface,
59
  indices: number[]
60
): DataContainerInterface {
61
  return new IndexedDataContainer(dataContainer, indices);
1✔
62
}
63

64
/**
65
 * Get a sample of rows from a data container.
66
 * @param dataContainer Data container to get samples from.
67
 * @param sampleSize Max number of samples.
68
 * @returns A data container which contains samples from the original data container.
69
 */
70
export function getSampleData(
71
  dataContainer: DataContainerInterface,
72
  sampleSize = 500
×
73
): DataContainerInterface {
UNCOV
74
  const numberOfRows = dataContainer.numRows();
×
UNCOV
75
  const sampleStep = Math.max(Math.floor(numberOfRows / sampleSize), 1);
×
76

UNCOV
77
  const indices: number[] = [];
×
78
  for (let i = 0; i < numberOfRows; i += sampleStep) {
×
79
    indices.push(i);
×
80
  }
81

82
  return createIndexedDataContainer(dataContainer, indices);
×
83
}
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