Skip to content

perf: Implement O(1) Lookup Map for internalId #9076

@tobiu

Description

@tobiu

Context:
The recent adoption of internalId (#9070) introduced robust identity for Records and Raw Objects. However, resolving an item from its internalId currently relies on store.items.find(...), which is an O(N) operation.
In large datasets (e.g. 100k rows), this kills performance for selection, navigation, and drag-and-drop operations that rely on reverse lookup.

Objective:
Implement a secondary map (internalIdMap) in Neo.collection.Base to provide O(1) lookup for internalId (or any secondary key).

Architecture:

  1. Collection.Base:

    • Add trackInternalId config (or similar flag).
    • Add internalIdMap (Map).
    • Add getInternalKey(item) method (to be overridden).
    • Update splice (add/remove logic) to maintain internalIdMap in sync with the primary map.
    • Add getByInternalId(id) accessor.
  2. Store:

    • Enable tracking.
    • Override getInternalKey to return item[internalId].
  3. Refactor Consumers:

    • Update GridBody, TableBody, Helix, Gallery, SelectionModels to use store.getByInternalId(id) instead of store.items.find(...).

Result:
Restores O(1) performance for all ID-based lookups in the framework.

Metadata

Metadata

Assignees

Labels

aicoreCore framework functionalityperformancePerformance improvements and optimizations

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions