inner Join By Key
fun <TValue2, TValueOut> innerJoinByKey(other: SortedKeyValueIteratorProvider<TKey, TValue2>, mergeFn: (TKey, TValue, TValue2) -> TValueOut): SortedKeyValueSequence<TKey, TValueOut>
Performs an inner join with another sorted sequence.
Example:
val seq1 = sequenceOf(1 to "a", 2 to "b", 2 to "c").assertSorted()
val seq2 = sequenceOf(2 to "x", 2 to "y", 3 to "z").assertSorted()
val result = seq1.innerJoinByKey(seq2) { _, v1, v2 -> "$v1$v2" }
assertEquals(
listOf(
2 to "bx",
2 to "by",
2 to "cx",
2 to "cy"
),
result.toList()
)
Content copied to clipboard
Return
A new sorted sequence with merged values for keys present in both sequences
Parameters
other
The sequence to join with
merge Fn
Function that defines how to merge values for matching keys
fun <TValue2> innerJoinByKey(other: SortedKeyValueIteratorProvider<TKey, TValue2>): SortedKeyValueSequence<TKey, Pair<TValue, TValue2>>
Performs an inner join with another sorted sequence using default pairing of values.
Example:
val seq1 = sequenceOf(1 to "a", 2 to "b", 2 to "c").assertSorted()
val seq2 = sequenceOf(2 to "x", 2 to "y", 3 to "z").assertSorted()
val result = seq1.innerJoinByKey(seq2)
assertEquals(
listOf(
2 to ("b" to "x"),
2 to ("b" to "y"),
2 to ("c" to "x"),
2 to ("c" to "y"),
),
result.toList()
)
Content copied to clipboard
Return
A new sorted sequence with paired values for keys present in both sequences
Parameters
other
The sequence to join with