Skip to content

Implement start position read API (issue #23)#46

Merged
JamesWiresmith merged 2 commits intomainfrom
session/agent_b39d2032-2b53-4f17-8481-02ba1015e5a9
Jan 30, 2026
Merged

Implement start position read API (issue #23)#46
JamesWiresmith merged 2 commits intomainfrom
session/agent_b39d2032-2b53-4f17-8481-02ba1015e5a9

Conversation

@kiloconnect
Copy link
Contributor

@kiloconnect kiloconnect bot commented Jan 22, 2026

Summary

This PR implements the start position read API as outlined in the implementation plan (issue #23). It adds the ability to read channel data starting from a specific sample position, with optimizations for skipping entire data blocks.

Changes

New API

  • Added read_channel_from(channel, start, output) method to TdmsFile
  • Refactored existing read_channel() to use read_channel_from() internally for consistency

Implementation Details

  • Added read_single_from() and read_from() methods to DataBlock
  • Extended MultiChannelContigousReader with read_from() for offset support
  • Extended MultiChannelInterleavedReader with read_from() for offset support

Performance Optimizations

  • Block-level skipping: Entire data blocks are skipped when the start position is beyond them
  • Contiguous layout: Seeks directly to the offset within channel data
  • Interleaved layout: Skips entire rows before reading

Testing

  • Added comprehensive unit tests in tests/read_with_offset.rs
  • Tests cover:
    • Reading from position 0 (should match normal read)
    • Reading from middle of data
    • Reading with small output buffers
    • Reading beyond available data
    • Reading at various positions
    • Backward compatibility

Backward Compatibility

The implementation maintains full backward compatibility:

  • The original read_channel() method signature is unchanged
  • Existing code will continue to work without modifications
  • The new functionality is opt-in via the new read_channel_from() method

Related Issues

Closes #23

Testing

All existing tests should pass, and new tests have been added to verify the offset reading functionality.

Documentation

The new method includes comprehensive documentation explaining:

  • Parameters and their purpose
  • Performance characteristics
  • Usage examples in the doc comments

@kiloconnect kiloconnect bot force-pushed the session/agent_b39d2032-2b53-4f17-8481-02ba1015e5a9 branch from adc244b to db31ca1 Compare January 22, 2026 10:42
@JamesWiresmith JamesWiresmith force-pushed the session/agent_b39d2032-2b53-4f17-8481-02ba1015e5a9 branch 3 times, most recently from be6cc18 to ede0813 Compare January 30, 2026 05:20
* Added the ability to select a start offset in the read API (#23)
* This involved significant refactoring of the read logic.
@JamesWiresmith JamesWiresmith force-pushed the session/agent_b39d2032-2b53-4f17-8481-02ba1015e5a9 branch from ede0813 to 294cabe Compare January 30, 2026 05:29
@JamesWiresmith JamesWiresmith self-requested a review January 30, 2026 05:36
@JamesWiresmith JamesWiresmith added this pull request to the merge queue Jan 30, 2026
Merged via the queue into main with commit 3f2c0fa Jan 30, 2026
3 checks passed
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.

Random Read Access

1 participant

Comments