Skip to content

Commit

Permalink
Output statistics before chunk indexes, like the others
Browse files Browse the repository at this point in the history
  • Loading branch information
Muon committed Jan 17, 2025
1 parent ac19a1a commit c4a1163
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions rust/src/sans_io/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -904,9 +904,9 @@ mod tests {
op::MESSAGE_INDEX,
op::DATA_END,
op::CHANNEL,
op::STATISTICS,
op::CHUNK_INDEX,
op::CHUNK_INDEX,
op::STATISTICS,
op::SUMMARY_OFFSET,
op::SUMMARY_OFFSET,
op::SUMMARY_OFFSET,
Expand Down Expand Up @@ -988,9 +988,9 @@ mod tests {
op::MESSAGE_INDEX,
op::DATA_END,
op::CHANNEL,
op::STATISTICS,
op::CHUNK_INDEX,
op::CHUNK_INDEX,
op::STATISTICS,
op::SUMMARY_OFFSET,
op::SUMMARY_OFFSET,
op::SUMMARY_OFFSET,
Expand Down Expand Up @@ -1034,9 +1034,9 @@ mod tests {
op::MESSAGE_INDEX,
op::DATA_END,
op::CHANNEL,
op::STATISTICS,
op::CHUNK_INDEX,
op::CHUNK_INDEX,
op::STATISTICS,
op::SUMMARY_OFFSET,
op::SUMMARY_OFFSET,
op::SUMMARY_OFFSET,
Expand Down
22 changes: 11 additions & 11 deletions rust/src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,17 @@ impl<W: Write + Seek> Writer<W> {
});
}

if self.options.output_statistics {
let statistics_start = summary_end;
write_record(&mut ccw, &Record::Statistics(stats))?;
summary_end = posit(&mut ccw)?;
offsets.push(records::SummaryOffset {
group_opcode: op::STATISTICS,
group_start: statistics_start,
group_length: summary_end - statistics_start,
});
}

if self.options.output_chunk_indexes && !chunk_indexes.is_empty() {
// Write all chunk indexes.
let chunk_indexes_start = summary_end;
Expand Down Expand Up @@ -1024,17 +1035,6 @@ impl<W: Write + Seek> Writer<W> {
});
}

if self.options.output_statistics {
let statistics_start = summary_end;
write_record(&mut ccw, &Record::Statistics(stats))?;
summary_end = posit(&mut ccw)?;
offsets.push(records::SummaryOffset {
group_opcode: op::STATISTICS,
group_start: statistics_start,
group_length: summary_end - statistics_start,
});
}

// Write the summary offsets we've been accumulating
if self.options.output_summary_offsets {
summary_offset_start = summary_end;
Expand Down
4 changes: 2 additions & 2 deletions rust/tests/round_trip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ fn demo_round_trip_for_opts(opts: WriteOptions) -> Result<()> {
match (i, offset.group_opcode) {
(0, op::SCHEMA) => (),
(1, op::CHANNEL) => (),
(2, op::CHUNK_INDEX) => (),
(3, op::STATISTICS) => (),
(2, op::STATISTICS) => (),
(3, op::CHUNK_INDEX) => (),
_ => panic!("Summary offset {i} was {offset:?}"),
};

Expand Down

0 comments on commit c4a1163

Please sign in to comment.