Skip to content

fix: sqlite reader restores master-table order instead of type grouping - #66

Merged
katsut merged 1 commit into
mainfrom
fix/sqlite-reader-event-order
Jul 5, 2026
Merged

fix: sqlite reader restores master-table order instead of type grouping#66
katsut merged 1 commit into
mainfrom
fix/sqlite-reader-event-order

Conversation

@katsut

@katsut katsut commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Found by reading real-data numbers, not code: the top issue variant of the sharkdp/fd measurement log read label > open issue > ... — a label before the issue exists.

Cause: the reader assembles events one per-type table at a time (alphabetical via event_map_type), so log.events comes back grouped by type. ocel-mine breaks timestamp ties by log index; 564/974 fd issues carry a label stamped the same second as their open event, and every one of those ties resolved to label-first from .sqlite while the JSON reader (which preserves file order) resolves them open-first. Same log, different variants per format.

Fix: after assembly, reorder events/objects by the master event/object table rowid order — exactly the order the writer wrote (write_base_rows inserts in ocel.events order), matching JSON semantics. Ids missing from the master tables sort last with relative order preserved (stable sort).

  • new test: read_restores_write_order_not_type_grouping — log order deliberately disagrees with alphabetical type order for both events and objects
  • verified on the real fd log: ocel convert fd.sqlite → json now shows open issue before its same-second label (issue #574 spot-checked)
  • existing round-trip/stability tests unchanged and green

Closes #65

Events and objects were assembled one per-type table at a time
(alphabetical), so log.events came back grouped by type. ocel-mine
breaks timestamp ties by log index, which made tie resolution
format-dependent: the same log read from .sqlite put 'label' before
'open issue' in every same-second trace (564/974 issues in the
sharkdp/fd measurement log), while the JSON reader preserved the
written order.

The reader now reorders events/objects by the master event/object
table's rowid order — exactly what the writer wrote, matching JSON
semantics. Ids missing from the master table sort last, keeping their
relative order (stable sort).

Closes #65
@katsut
katsut merged commit 9814e02 into main Jul 5, 2026
4 checks passed
@katsut
katsut deleted the fix/sqlite-reader-event-order branch July 5, 2026 17:23
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.

sqlite reader groups events by type, making timestamp-tie order format-dependent

1 participant