Skip to content

feat(sdk): add ScalarRecord/ObjectRecord for parser-controlled timestamps#92

Merged
facontidavide merged 4 commits into
mainfrom
feat/scalar-record-timestamp-override
May 25, 2026
Merged

feat(sdk): add ScalarRecord/ObjectRecord for parser-controlled timestamps#92
facontidavide merged 4 commits into
mainfrom
feat/scalar-record-timestamp-override

Conversation

@pabloinigoblasco
Copy link
Copy Markdown
Collaborator

@pabloinigoblasco pabloinigoblasco commented May 25, 2026

Summary

Introduce `ScalarRecord { optional ts, vector fields }` and `ObjectRecord { optional ts, BuiltinObject object }` as the new return types of the `SchemaHandler` `parse_scalars` / `parse_object` callables.

When `ts` is `nullopt` the host uses the message receive time as before; when set, the parser-provided timestamp is used instead — restoring the ability to align rows with timestamps embedded in the payload (e.g. ROS `Header.stamp`, JSON `"timestamp"` field, sensor capture time).

`parse_scalars` returns a single `ScalarRecord` (one allocation, same shape as the previous `vector` plus the optional timestamp). Multi-row batch from a single payload is intentionally out of scope to keep the hot path one-allocation; if a real batch use case appears it can grow into a dedicated API without changing the `ScalarRecord` shape.

API change

Signatures change in `SchemaHandler`:

  • `parse_scalars`: returns `Expected` instead of `Expected<std::vector>`.
  • `parse_object`: returns `Expected` instead of `Expected`.

Parsers that don't care about embedded timestamps can leave `ts = std::nullopt` and keep their previous behaviour. Parsers that do can now place the value where the host actually reads it.

Test plan

  • CI green
  • Update at least one parser that reads embedded timestamps and verify rows land on the correct time axis

pabloinigoblasco and others added 4 commits May 25, 2026 14:24
…amps

Introduce ScalarRecord {optional<Timestamp> ts, vector<NamedFieldValue>}
and ObjectRecord {optional<Timestamp> ts, BuiltinObject} as the new
return types of the SchemaHandler parse_scalars / parse_object
callables.

When ts is nullopt the host uses the message receive time as before;
when set, the parser-provided timestamp is used instead — restoring
the ability to align rows with timestamps embedded in the payload
(e.g. ROS Header.stamp, JSON "timestamp" field, sensor capture time).

The default parse() now iterates the returned records and respects each
record's timestamp, also enabling multi-row output from a single payload
(useful for batch messages such as JSON arrays).
…oc per call

Review feedback: returning std::vector<ScalarRecord> meant every call
ended up doing two heap allocations in the common case (outer vector +
the fields vector inside the only record), even for single-row decoding
on a hot streaming path.

The parser-controlled timestamp was the actual ask from the client;
multi-row batch was added speculatively for JSON arrays and is not a
shipping requirement. Drop the outer vector and return a single
ScalarRecord; one allocation total, same shape as the pre-change API
plus the optional<Timestamp>.

Parsers that need to emit multiple rows per payload can stage a batch
API later if/when a concrete use case shows up — the SchemaHandler
shape leaves room for that without breaking ScalarRecord.
@facontidavide facontidavide merged commit a98f458 into main May 25, 2026
2 checks passed
@facontidavide facontidavide deleted the feat/scalar-record-timestamp-override branch May 25, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants