Skip to content

vol2: DataSource type dispatch — replace instanceof with int type discriminant #6729

Description

@mdproctor

Context

Hot-path code in vol2 uses instanceof PropagatingDataStore to dispatch on DataSource type. instanceof checks have virtual dispatch cost and prevent the JIT from fully optimising tight loops.

Required design

Each DataSource implementation carries an int type() discriminant. Dispatch becomes:

switch (ds.type()) {
    case DataSourceTypes.PROPAGATING -> { PropagatingDataStore<?> pds = (PropagatingDataStore<?>) ds; ... }
    default -> throw new UnsupportedOperationException("DataSource type not yet supported: " + ds.getClass());
}

The explicit UnsupportedOperationException surfaces any TBD paths immediately rather than silently ignoring them.

Interim state

Until this is implemented, all instanceof checks should have a corresponding else { throw new UnsupportedOperationException("DataSource type not yet supported: " + ds.getClass()); } guard so unknown types don't silently no-op.

Refs #6724

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    📋 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions