Skip to content

Commit

Permalink
Add error if concatenating unsorted mcap files
Browse files Browse the repository at this point in the history
  • Loading branch information
kevswims committed Nov 15, 2023
1 parent 5dc836c commit df18340
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion go/cli/mcap/cmd/concat.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ func (m *mcapConcatenator) addMetadata(w *mcap.Writer, metadata *mcap.Metadata)
func (m *mcapConcatenator) addChannel(w *mcap.Writer, inputID int, channel *mcap.Channel) (uint16, error) {
outputSchemaID, ok := m.outputSchemaID(inputID, channel.SchemaID)
if !ok {
return 0, fmt.Errorf("unknown schema on channel %d for input %d topic %s", channel.ID, inputID, channel.Topic)
return 0, fmt.Errorf("unknown schema on channel %d for input %d topic %s",
channel.ID, inputID, channel.Topic)
}
key := channelID{inputID, channel.ID}
newChannel := &mcap.Channel{
Expand Down Expand Up @@ -243,6 +244,10 @@ func (m *mcapConcatenator) concatenateInputs(w io.Writer, inputs []namedReader)
return fmt.Errorf("error on input %s: %w", inputName, err)
}

if newMessage.LogTime < timestampOffset {
return fmt.Errorf("timestamp %d is less than offset %d, sort input files before concatenating", newMessage.LogTime, timestampOffset)
}

newMessage.LogTime -= timestampOffset
lastTimestamp = newMessage.LogTime

Expand Down

0 comments on commit df18340

Please sign in to comment.