Skip to content

Commit ec78459

Browse files
committed
moved tuples to separate module
1 parent 2de0732 commit ec78459

File tree

23 files changed

+344
-25
lines changed

23 files changed

+344
-25
lines changed

kotlin-spark-api/3.2/pom_2.12.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
<groupId>org.jetbrains.kotlinx.spark</groupId>
2828
<artifactId>core-3.2_${scala.compat.version}</artifactId>
2929
</dependency>
30+
<dependency>
31+
<groupId>org.jetbrains.kotlinx.spark</groupId>
32+
<artifactId>scala-tuples-in-kotlin</artifactId>
33+
</dependency>
3034

3135

3236
<!-- Provided dependencies -->
@@ -75,6 +79,7 @@
7579
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
7680
<directory>target/${scala.compat.version}</directory>
7781
<plugins>
82+
7883
<plugin>
7984
<groupId>org.jetbrains.kotlin</groupId>
8085
<artifactId>kotlin-maven-plugin</artifactId>
@@ -93,10 +98,12 @@
9398
</execution>
9499
</executions>
95100
</plugin>
101+
96102
<plugin>
97103
<groupId>org.apache.maven.plugins</groupId>
98104
<artifactId>maven-surefire-plugin</artifactId>
99105
</plugin>
106+
100107
<plugin>
101108
<groupId>org.jetbrains.dokka</groupId>
102109
<artifactId>dokka-maven-plugin</artifactId>
@@ -121,17 +128,20 @@
121128
</execution>
122129
</executions>
123130
</plugin>
131+
124132
<plugin>
125133
<groupId>io.qameta.allure</groupId>
126134
<artifactId>allure-maven</artifactId>
127135
<configuration>
128136
<resultsDirectory>${project.basedir}/allure-results/${scala.compat.version}</resultsDirectory>
129137
</configuration>
130138
</plugin>
139+
131140
<plugin>
132141
<groupId>org.jacoco</groupId>
133142
<artifactId>jacoco-maven-plugin</artifactId>
134143
</plugin>
144+
135145
</plugins>
136146
</build>
137147
</project>

kotlin-spark-api/3.2/src/main/kotlin/org/jetbrains/kotlinx/spark/api/Conversions.kt

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -167,45 +167,24 @@ fun <A, B> ScalaConcurrentMap<A, B>.asKotlinConcurrentMap(): ConcurrentMap<A, B>
167167
JavaConverters.mapAsJavaConcurrentMap<A, B>(this)
168168

169169

170-
/**
171-
* Returns a new [Tuple2] based on the arguments in the current [Pair].
172-
*/
173-
fun <T1, T2> Pair<T1, T2>.toTuple(): Tuple2<T1, T2> = Tuple2<T1, T2>(first, second)
174-
175170
/**
176171
* Returns a new [Arity2] based on the arguments in the current [Pair].
177172
*/
178173
@Deprecated("Use Scala tuples instead.", ReplaceWith("this.toTuple()", "scala.Tuple2"))
179174
fun <T1, T2> Pair<T1, T2>.toArity(): Arity2<T1, T2> = Arity2<T1, T2>(first, second)
180175

181-
/**
182-
* Returns a new [Pair] based on the arguments in the current [Tuple2].
183-
*/
184-
fun <T1, T2> Tuple2<T1, T2>.toPair(): Pair<T1, T2> = Pair<T1, T2>(_1(), _2())
185-
186176
/**
187177
* Returns a new [Pair] based on the arguments in the current [Arity2].
188178
*/
189179
@Deprecated("Use Scala tuples instead.", ReplaceWith(""))
190180
fun <T1, T2> Arity2<T1, T2>.toPair(): Pair<T1, T2> = Pair<T1, T2>(_1, _2)
191181

192-
193-
/**
194-
* Returns a new [Tuple3] based on the arguments in the current [Triple].
195-
*/
196-
fun <T1, T2, T3> Triple<T1, T2, T3>.toTuple(): Tuple3<T1, T2, T3> = Tuple3<T1, T2, T3>(first, second, third)
197-
198182
/**
199183
* Returns a new [Arity3] based on the arguments in the current [Triple].
200184
*/
201185
@Deprecated("Use Scala tuples instead.", ReplaceWith("this.toTuple()", "scala.Tuple3"))
202186
fun <T1, T2, T3> Triple<T1, T2, T3>.toArity(): Arity3<T1, T2, T3> = Arity3<T1, T2, T3>(first, second, third)
203187

204-
/**
205-
* Returns a new [Triple] based on the arguments in the current [Tuple3].
206-
*/
207-
fun <T1, T2, T3> Tuple3<T1, T2, T3>.toTriple(): Triple<T1, T2, T3> = Triple<T1, T2, T3>(_1(), _2(), _3())
208-
209188
/**
210189
* Returns a new [Triple] based on the arguments in the current [Arity3].
211190
*/

kotlin-spark-api/3.2/src/test/kotlin/org/jetbrains/kotlinx/spark/api/DatasetFunctionTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,11 @@ class DatasetFunctionTest : ShouldSpec({
215215
}
216216

217217
should("be able to cogroup grouped datasets") {
218-
val groupedDataset1 = listOf(1 to "a", 1 to "b", 2 to "c").map { it.toTuple() }
218+
val groupedDataset1 = listOf(1 X "a", 1 X "b", 2 X "c")
219219
.toDS()
220220
.groupByKey { it._1 }
221221

222-
val groupedDataset2 = listOf(1 to "d", 5 to "e", 3 to "f").map { it.toTuple() }
222+
val groupedDataset2 = listOf(1 X "d", 5 X "e", 3 X "f")
223223
.toDS()
224224
.groupByKey { it._1 }
225225

pom_2.12.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
<modules>
2222
<module>core/3.2/pom_2.12.xml</module>
23+
<module>scala-tuples-in-kotlin/pom_2.12.xml</module>
2324
<module>kotlin-spark-api/3.2/pom_2.12.xml</module>
2425
<module>examples/pom-3.2_2.12.xml</module>
2526
</modules>
@@ -31,6 +32,11 @@
3132
<artifactId>core-3.2_${scala.compat.version}</artifactId>
3233
<version>${project.version}</version>
3334
</dependency>
35+
<dependency>
36+
<groupId>org.jetbrains.kotlinx.spark</groupId>
37+
<artifactId>scala-tuples-in-kotlin</artifactId>
38+
<version>${project.version}</version>
39+
</dependency>
3440
</dependencies>
3541
</dependencyManagement>
3642
</project>
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<name>Kotlin Spark API: Scala Tuples in Kotlin</name>
6+
<description>Scala Tuple helper functions for kotlin</description>
7+
<artifactId>scala-tuples-in-kotlin</artifactId>
8+
<parent>
9+
<groupId>org.jetbrains.kotlinx.spark</groupId>
10+
<artifactId>kotlin-spark-api-parent_2.12</artifactId>
11+
<version>1.0.4-SNAPSHOT</version>
12+
<relativePath>../pom_2.12.xml</relativePath>
13+
</parent>
14+
15+
<dependencies>
16+
<dependency>
17+
<groupId>org.scala-lang</groupId>
18+
<artifactId>scala-library</artifactId>
19+
<version>${scala.version}</version>
20+
</dependency>
21+
<dependency>
22+
<groupId>org.jetbrains.kotlin</groupId>
23+
<artifactId>kotlin-stdlib-jdk8</artifactId>
24+
<version>${kotlin.version}</version>
25+
</dependency>
26+
27+
<!-- Test dependencies -->
28+
<dependency>
29+
<groupId>io.kotest</groupId>
30+
<artifactId>kotest-runner-junit5-jvm</artifactId>
31+
<version>${kotest.version}</version>
32+
<scope>test</scope>
33+
</dependency>
34+
<dependency>
35+
<groupId>io.kotest.extensions</groupId>
36+
<artifactId>kotest-extensions-allure</artifactId>
37+
<version>${kotest-extension-allure.version}</version>
38+
<scope>test</scope>
39+
</dependency>
40+
<dependency>
41+
<groupId>com.beust</groupId>
42+
<artifactId>klaxon</artifactId>
43+
<version>${klaxon.version}</version>
44+
<scope>test</scope>
45+
</dependency>
46+
<dependency>
47+
<groupId>ch.tutteli.atrium</groupId>
48+
<artifactId>atrium-fluent-en_GB</artifactId>
49+
<version>${atrium.version}</version>
50+
<scope>test</scope>
51+
</dependency>
52+
53+
<dependency>
54+
<groupId>org.jetbrains.kotlin</groupId>
55+
<artifactId>kotlin-test</artifactId>
56+
<version>${kotlin.version}</version>
57+
<scope>test</scope>
58+
</dependency>
59+
</dependencies>
60+
61+
<build>
62+
<sourceDirectory>src/main/kotlin</sourceDirectory>
63+
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
64+
<directory>target/${scala.compat.version}</directory>
65+
<plugins>
66+
67+
<plugin>
68+
<groupId>org.jetbrains.dokka</groupId>
69+
<artifactId>dokka-maven-plugin</artifactId>
70+
<version>${dokka.version}</version>
71+
<configuration>
72+
<jdkVersion>8</jdkVersion>
73+
</configuration>
74+
<executions>
75+
<execution>
76+
<id>dokka</id>
77+
<goals>
78+
<goal>dokka</goal>
79+
</goals>
80+
<phase>pre-site</phase>
81+
</execution>
82+
<execution>
83+
<id>javadocjar</id>
84+
<goals>
85+
<goal>javadocJar</goal>
86+
</goals>
87+
<phase>pre-integration-test</phase>
88+
</execution>
89+
</executions>
90+
</plugin>
91+
92+
<plugin>
93+
<groupId>org.jetbrains.kotlin</groupId>
94+
<artifactId>kotlin-maven-plugin</artifactId>
95+
<version>${kotlin.version}</version>
96+
<executions>
97+
<execution>
98+
<id>compile</id>
99+
<phase>compile</phase>
100+
<goals>
101+
<goal>compile</goal>
102+
</goals>
103+
</execution>
104+
<execution>
105+
<id>test-compile</id>
106+
<phase>test-compile</phase>
107+
<goals>
108+
<goal>test-compile</goal>
109+
</goals>
110+
</execution>
111+
</executions>
112+
<configuration>
113+
<jvmTarget>1.8</jvmTarget>
114+
</configuration>
115+
</plugin>
116+
117+
<plugin>
118+
<groupId>org.apache.maven.plugins</groupId>
119+
<artifactId>maven-assembly-plugin</artifactId>
120+
<version>${maven-assembly-plugin.version}</version>
121+
<configuration>
122+
<descriptorRefs>
123+
<descriptorRef>jar-with-dependencies</descriptorRef>
124+
</descriptorRefs>
125+
<archive>
126+
<manifest>
127+
<mainClass>org.jetbrains.spark.api.examples.WordCountKt</mainClass>
128+
</manifest>
129+
</archive>
130+
</configuration>
131+
</plugin>
132+
133+
<plugin>
134+
<groupId>org.apache.maven.plugins</groupId>
135+
<artifactId>maven-site-plugin</artifactId>
136+
<configuration>
137+
<skip>true</skip>
138+
</configuration>
139+
</plugin>
140+
141+
<plugin>
142+
<groupId>org.apache.maven.plugins</groupId>
143+
<artifactId>maven-deploy-plugin</artifactId>
144+
<configuration>
145+
<skip>true</skip>
146+
</configuration>
147+
</plugin>
148+
149+
<plugin>
150+
<groupId>org.sonatype.plugins</groupId>
151+
<artifactId>nexus-staging-maven-plugin</artifactId>
152+
<configuration>
153+
<skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo>
154+
</configuration>
155+
</plugin>
156+
157+
</plugins>
158+
</build>
159+
</project>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*-
2+
* =LICENSE=
3+
* Kotlin Spark API: API for Spark 3.0+ (Scala 2.12)
4+
* ----------
5+
* Copyright (C) 2019 - 2021 JetBrains
6+
* ----------
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* =LICENSEEND=
19+
*/
20+
21+
/**
22+
* This files contains conversions of Tuples between the Scala-
23+
* and Kotlin/Java variants.
24+
*/
25+
26+
@file:Suppress("NOTHING_TO_INLINE", "RemoveExplicitTypeArguments", "unused")
27+
28+
package org.jetbrains.kotlinx.spark.api
29+
30+
import scala.*
31+
32+
33+
/**
34+
* Returns a new [Tuple2] based on the arguments in the current [Pair].
35+
*/
36+
fun <T1, T2> Pair<T1, T2>.toTuple(): Tuple2<T1, T2> = Tuple2<T1, T2>(first, second)
37+
38+
/**
39+
* Returns a new [Pair] based on the arguments in the current [Tuple2].
40+
*/
41+
fun <T1, T2> Tuple2<T1, T2>.toPair(): Pair<T1, T2> = Pair<T1, T2>(_1(), _2())
42+
43+
/**
44+
* Returns a new [Tuple3] based on the arguments in the current [Triple].
45+
*/
46+
fun <T1, T2, T3> Triple<T1, T2, T3>.toTuple(): Tuple3<T1, T2, T3> = Tuple3<T1, T2, T3>(first, second, third)
47+
48+
/**
49+
* Returns a new [Triple] based on the arguments in the current [Tuple3].
50+
*/
51+
fun <T1, T2, T3> Tuple3<T1, T2, T3>.toTriple(): Triple<T1, T2, T3> = Triple<T1, T2, T3>(_1(), _2(), _3())

kotlin-spark-api/3.2/src/main/kotlin/org/jetbrains/kotlinx/spark/api/tuples/DestructuredTupleBuilders.kt renamed to scala-tuples-in-kotlin/src/main/kotlin/org/jetbrains/kotlinx/spark/api/tuples/DestructuredTupleBuilders.kt

File renamed without changes.

kotlin-spark-api/3.2/src/main/kotlin/org/jetbrains/kotlinx/spark/api/tuples/DropFunctions.kt renamed to scala-tuples-in-kotlin/src/main/kotlin/org/jetbrains/kotlinx/spark/api/tuples/DropFunctions.kt

File renamed without changes.

kotlin-spark-api/3.2/src/main/kotlin/org/jetbrains/kotlinx/spark/api/tuples/EmptyTuple.kt renamed to scala-tuples-in-kotlin/src/main/kotlin/org/jetbrains/kotlinx/spark/api/tuples/EmptyTuple.kt

File renamed without changes.

kotlin-spark-api/3.2/src/main/kotlin/org/jetbrains/kotlinx/spark/api/tuples/MapTuples.kt renamed to scala-tuples-in-kotlin/src/main/kotlin/org/jetbrains/kotlinx/spark/api/tuples/MapTuples.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*-
2+
* =LICENSE=
3+
* Kotlin Spark API: Scala Tuples in Kotlin
4+
* ----------
5+
* Copyright (C) 2019 - 2022 JetBrains
6+
* ----------
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* =LICENSEEND=
19+
*/
120
package org.jetbrains.kotlinx.spark.api.tuples
221

322
import scala.*

0 commit comments

Comments
 (0)