-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for the SequenceId Ordering Problem (#221)
SequenceIds are currently ordered lexicographically, which is wrong as the SDC standards define no order on them. We hence order them by the timestamp of the first message that they were used in. # Checklist The following aspects have been respected by the author of this pull request, confirmed by both pull request assignee **and** reviewer: * Adherence to coding conventions * [x] Pull Request Assignee * [x] Reviewer (midtuna) * Adherence to javadoc conventions * [x] Pull Request Assignee * [x] Reviewer (midtuna) * Changelog update (necessity checked and entry added or not added respectively) * [x] Pull Request Assignee * [x] Reviewer (midtuna) * README update (necessity checked and entry added or not added respectively) * [x] Pull Request Assignee * [x] Reviewer (midtuna) * config update (necessity checked and entry added or not added respectively) * [x] Pull Request Assignee * [x] Reviewer (midtuna) * SDCcc executable ran against a test device (if necessary) * [x] Pull Request Assignee * [x] Reviewer (midtuna) --------- Co-authored-by: midttuna <[email protected]>
- Loading branch information
1 parent
c7ff37e
commit 729356b
Showing
4 changed files
with
171 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
sdccc/src/main/java/com/draeger/medical/sdccc/messages/OrderedStreamIterator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the MIT License. | ||
* Copyright (c) 2023-2024 Draegerwerk AG & Co. KGaA. | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
package com.draeger.medical.sdccc.messages | ||
|
||
import org.hibernate.query.spi.CloseableIterator | ||
import org.hibernate.query.spi.ScrollableResultsImplementor | ||
|
||
/** | ||
* Iterator to be used to create Streams with the ORDERED characteristic from ScrollableResults. | ||
*/ | ||
class OrderedStreamIterator<T>(private val results: ScrollableResultsImplementor) : CloseableIterator<T> { | ||
|
||
override fun close() { | ||
results.close() | ||
} | ||
|
||
override fun remove() { | ||
throw UnsupportedOperationException( | ||
"this stream does not support the" + | ||
" remove operation" | ||
) | ||
} | ||
|
||
override fun hasNext(): Boolean { | ||
if (results.isClosed) { | ||
return false | ||
} | ||
return results.next() | ||
} | ||
|
||
override fun next(): T { | ||
val element = results.get() | ||
@Suppress("UNCHECKED_CAST") | ||
return if (element.size == 1) { | ||
element[0] | ||
} else { | ||
element | ||
} as T | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters