Skip to content

Add support for parsing raw events using custom transform in PushInputAdapter#678

Merged
arhamchopra merged 4 commits intomainfrom
ac/custom_input_adapter
Feb 17, 2026
Merged

Add support for parsing raw events using custom transform in PushInputAdapter#678
arhamchopra merged 4 commits intomainfrom
ac/custom_input_adapter

Conversation

@arhamchopra
Copy link
Collaborator

@arhamchopra arhamchopra commented Feb 13, 2026

Summary

  • Add a transformRawEvent virtual hook to PushInputAdapter that allows subclasses to apply arbitrary transformations to pushed events on the engine thread before they are consumed by the csp engine.
  • Change consumeEvent return type from bool to PushEvent * (nullptr = consumed, non-null = defer to next cycle) and add a reconsuming flag to skip transformation on events already transformed in a prior pass.
  • This enables push adapters to push raw payloads from the adapter thread and have them transformed into final tick values on the engine thread — useful when the transformation requires engine-thread state, deferred evaluation, type conversion, or arbitrary C++ logic.
  • Add a test C++ adapter (CallablePyPushInputAdapter) and Python tests demonstrating the feature, including reconsume correctness for both ungrouped and grouped adapters.

Design

A new transformEvents flag on PushInputAdapter (set via constructor) routes events through a single virtual hook in consumeEvent:

  • transformRawEvent(PushEvent * raw_event) — transform the pushed event into a new parsed event for the engine. The subclass implementation must:
    • Delete the original raw event
    • Preserve event properties (e.g. isGroupEnd flag) on the new event

The transform runs before the group LOCKED check in consumeEvent, so events stored in PendingPushEvents are always already-transformed. On reconsuming (second pass), consumeEvent receives reconsuming=true and skips transformRawEvent to avoid double-transformation.

Return value of consumeEvent changed from bool to PushEvent *:

  • nullptr — event was consumed
  • Non-null — event was not consumed (e.g. group LOCKED, ungrouped NC already ticked this cycle); returned event is added to PendingPushEvents for the next engine cycle

Signed-off-by: Arham Chopra <arham.chopra@cubistsystematic.com>
Signed-off-by: Arham Chopra <arham.chopra@cubistsystematic.com>
@timkpaine timkpaine added type: enhancement Issues and PRs related to improvements to existing features adapter: general Issues and PRs related to input/output adapters in general labels Feb 14, 2026
Signed-off-by: Arham Chopra <arham.chopra@cubistsystematic.com>
@arhamchopra arhamchopra force-pushed the ac/custom_input_adapter branch from b6188c3 to cfb0384 Compare February 16, 2026 19:49
Signed-off-by: Arham Chopra <arham.chopra@cubistsystematic.com>
@robambalu robambalu self-requested a review February 17, 2026 14:48
@robambalu
Copy link
Collaborator

gtg if you want to remove it from draft

@arhamchopra arhamchopra marked this pull request as ready for review February 17, 2026 17:55
@arhamchopra arhamchopra changed the title Add support for a callback event parser in PushInputAdapter Add support for parsing raw events using custom transform in PushInputAdapter Feb 17, 2026
@arhamchopra arhamchopra merged commit ef9ff93 into main Feb 17, 2026
25 checks passed
@arhamchopra arhamchopra deleted the ac/custom_input_adapter branch February 17, 2026 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adapter: general Issues and PRs related to input/output adapters in general type: enhancement Issues and PRs related to improvements to existing features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants