-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b496a69
commit c5c3d3c
Showing
4 changed files
with
144 additions
and
0 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
31 changes: 31 additions & 0 deletions
31
partiql-eval/src/main/kotlin/org/partiql/eval/internal/operator/rel/RelDistinct.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,31 @@ | ||
package org.partiql.eval.internal.operator.rel | ||
|
||
import org.partiql.eval.internal.Record | ||
import org.partiql.eval.internal.operator.Operator | ||
|
||
internal class RelDistinct( | ||
val input: Operator.Relation | ||
) : Operator.Relation { | ||
|
||
private val seen = mutableSetOf<Record>() | ||
|
||
override fun open() { | ||
input.open() | ||
} | ||
|
||
override fun next(): Record? { | ||
var next = input.next() | ||
while (next != null) { | ||
if (seen.contains(next).not()) { | ||
seen.add(next) | ||
return next | ||
} | ||
next = input.next() | ||
} | ||
return null | ||
} | ||
|
||
override fun close() { | ||
input.close() | ||
} | ||
} |
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