GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: add TimestampOrderChecker, out of order and duplicate timestamps by alxkm · Pull Request #7733 · TheAlgorithms/Java

Conversation

@alxkm

@alxkm alxkm commented Nov 7, 2026

Copy link
Copy Markdown
Member

Adds TimestampOrderChecker to the streaming package. It checks each timestamp against the previous one and reports it as increasing, duplicate or backwards. It does not reorder or drop anything. It also keeps the worst backwards step, which tells you how big a reordering buffer would need to be to fix the stream. O(1) per sample.

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • All new algorithms include a corresponding test class that validates their functionality.
  • All new code is formatted with clang-format -i --style=file path/to/your/file.java

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@codecov-commenter

codecov-commenter commented Nov 7, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.77778% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.37%. Comparing base (c3ce690) to head (8cbc088).

Files with missing lines Patch % Lines
...thealgorithms/streaming/TimestampOrderChecker.java 97.77% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #7733      +/-   ##
============================================
+ Coverage     82.34%   82.37%   +0.03%     
- Complexity     8447     8467      +20     
============================================
  Files           843      844       +1     
  Lines         26156    26201      +45     
  Branches       5110     5115       +5     
============================================
+ Hits          21538    21583      +45     
  Misses         3830     3830              
  Partials        788      788              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@alxkm
alxkm marked this pull request as ready for review November 7, 2026 09:57
@alxkm
alxkm requested review from DenizAltunkapan and yanglbme as code owners November 7, 2026 09:57
@alxkm
feat: add TimestampOrderChecker, out of order and duplicate timestamps
4ba6857
Windowed algorithms assume time moves forward. When it does not, nothing fails loudly: a window holds samples that never coexisted, a rate is computed over a negative interval, a duplicate is counted twice. Retries, buffers flushed after a reconnect, several producers writing into one topic and a clock stepped backwards all cause this, and the cheap defence is to check the order explicitly.

Each timestamp is compared with the previous one and classified as INCREASING, DUPLICATE or BACKWARDS. The checker only reports, it does not reorder or drop anything, so lastTimestamp is always the most recent sample, not the largest. It also keeps the worst backwards step, which is what you need to size a reordering buffer. O(1) time per sample and O(1) state; non-finite timestamps are refused.

Tests: the first timestamp is always accepted, an ordered stream has no violations, duplicates and backwards steps are counted separately, the worst step is the largest one and not the last one, the stream is not reordered, scan returns one verdict per timestamp, and reset restores the initial state.

Signed-off-by: alxkm <[email protected]>
@alxkm
alxkm force-pushed the feat/timestamp-order-checker branch from ea480b2 to 4ba6857 Compare November 7, 2026 09:59
alxkm and others added 2 commits November 7, 2026 11:06
@alxkm
Merge branch 'master' into feat/timestamp-order-checker
5e161b1
Signed-off-by: alxkm <[email protected]>
@alxkm
Merge branch 'master' into feat/timestamp-order-checker
8cbc088
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@DenizAltunkapan DenizAltunkapan Awaiting requested review from DenizAltunkapan DenizAltunkapan is a code owner
@yanglbme yanglbme Awaiting requested review from yanglbme yanglbme is a code owner

At least 1 approving review is required to merge this pull request.

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@alxkm @codecov-commenter
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.