Skip to content

Commit

Permalink
improv perf
Browse files Browse the repository at this point in the history
Signed-off-by: Xun Li <[email protected]>
  • Loading branch information
lixun910 committed Nov 2, 2023
1 parent 2631251 commit f924e80
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
5 changes: 4 additions & 1 deletion src/layers/src/base-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,10 @@ class Layer {
const dataUpdateTriggers = this.getDataUpdateTriggers(layerDataset);
const triggerChanged = this.getChangedTriggers(dataUpdateTriggers);

if (triggerChanged && triggerChanged.getMeta) {
// NOTES:
// 1) add checker `oldLayerData`: undefined oldLayerData means this is the first time layer is rendered
// and the updateLayerMeta() has already been called in setInitialLayerConfig
if (triggerChanged && triggerChanged.getMeta && Boolean(oldLayerData)) {
this.updateLayerMeta(dataContainer, getPosition);
}

Expand Down
14 changes: 7 additions & 7 deletions src/layers/src/geoarrow-layer/geoarrow-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export default class GeoArrowLayer extends GeoJsonLayer {
}

renderLayer(opts) {
const {data, gpuFilter, objectHovered, mapState, interactionConfig} = opts;
const {data: dataProps, gpuFilter, objectHovered, mapState, interactionConfig} = opts;

const {fixedRadius, featureTypes} = this.meta;
const radiusScale = this.getRadiusScaleByZoom(mapState, fixedRadius);
Expand Down Expand Up @@ -269,12 +269,12 @@ export default class GeoArrowLayer extends GeoJsonLayer {

const pickable = interactionConfig.tooltip.enabled;
const hoveredObject = this.hasHoveredObject(objectHovered);

const deckLayers = data.data.map((d, i) => {
const {data, ...props} = dataProps;
const deckLayers = data.map((d, i) => {
return new DeckGLGeoJsonLayer({
...defaultLayerProps,
...layerProps,
...data,
...props,
data: d,
id: `${this.id}-${i}`,
pickable,
Expand Down Expand Up @@ -314,9 +314,9 @@ export default class GeoArrowLayer extends GeoJsonLayer {
visible: defaultLayerProps.visible,
wrapLongitude: false,
data: [hoveredObject],
getLineWidth: data.getLineWidth,
getPointRadius: data.getPointRadius,
getElevation: data.getElevation,
getLineWidth: dataProps.getLineWidth,
getPointRadius: dataProps.getPointRadius,
getElevation: dataProps.getElevation,
getLineColor: this.config.highlightColor,
getFillColor: this.config.highlightColor,
// always draw outline
Expand Down
13 changes: 8 additions & 5 deletions src/utils/src/arrow-data-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export class ArrowDataContainer implements DataContainerInterface {
_numColumns: number;
_numRows: number;
_fields: Field[];
_colData: any[][];
// cache column data to make valueAt() faster
// _colData: any[][];

constructor(data: ArrowDataContainerInput) {
if (!data.cols) {
Expand All @@ -55,8 +56,8 @@ export class ArrowDataContainer implements DataContainerInterface {
this._numColumns = data.cols.length;
this._numRows = data.cols[0].length;
this._fields = data.fields || [];
// cache column data to make valueAt() faster
this._colData = data.cols.map(c => c.toArray());

// this._colData = data.cols.map(c => c.toArray());
}

numRows(): number {
Expand All @@ -68,7 +69,8 @@ export class ArrowDataContainer implements DataContainerInterface {
}

valueAt(rowIndex: number, columnIndex: number): any {
return this._colData[columnIndex][rowIndex];
// return this._colData[columnIndex][rowIndex];
return this._cols[columnIndex].get(rowIndex);
}

row(rowIndex: number, sharedRow?: SharedRowOptions): DataRow {
Expand All @@ -82,7 +84,8 @@ export class ArrowDataContainer implements DataContainerInterface {
}

rowAsArray(rowIndex: number): any[] {
return this._colData.map(col => col[rowIndex]);
// return this._colData.map(col => col[rowIndex]);
return this._cols.map(col => col.get(rowIndex));
}

rows(sharedRow: SharedRowOptions) {
Expand Down

0 comments on commit f924e80

Please sign in to comment.