Jayyadav1903 opened a new pull request, #4171:
URL: https://github.com/apache/streampipes/pull/4171
## Extend FileReplayAdapter with Configurable Timestamp Strategies
### Motivation
The FileReplayAdapter previously assumed that each file line contains a
timestamp.
However, some use cases involve files where:
- No per-line timestamp exists
- A single timestamp is stored in the file name
- Real-time ingestion time should be used instead of replay time
This PR introduces configurable timestamp strategies while preserving full
backward compatibility.
---
### Changes
#### Configuration
Added `TIMESTAMP_MODE` with three options:
- `timestampFromFile` (default – existing behavior)
- `processingTime`
- `fileNameTimestamp`
For `fileNameTimestamp`, added:
- `TIMESTAMP_REGEX`
- `TIMESTAMP_FORMAT` (optional; if empty, epoch millis is assumed)
---
#### Implementation
Updated `FileReplayAdapter.java`:
- Added timestamp mode handling
- Implemented:
- `processingTime` → uses `System.currentTimeMillis()`
- `fileNameTimestamp` → extracts timestamp from filename via regex
- Refactored timestamp resolution logic
- Added protected setters to enable isolated unit testing
Updated `FileReplayAdapterTest.java`:
Added unit tests covering:
- Processing time mode
- Filename timestamp (epoch)
- Filename timestamp (date format)
- Regex mismatch handling
- Default behavior preservation
---
### Backward Compatibility
- Default mode remains `timestampFromFile`
- No migration required
- Existing adapters behave identically
- Replay speed logic unchanged for default mode
---
### Verification
Run in module:
```bash
mvn test -Dtest=FileReplayAdapterTest
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]