Skip to content

Commit 57d492f

Browse files
committed
avoiding binary incompatibility issues by modifying the public API
1 parent a22a2df commit 57d492f

File tree

3 files changed

+64
-8
lines changed

3 files changed

+64
-8
lines changed

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/convert.kt

+20-8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import org.jetbrains.kotlinx.dataframe.columns.ColumnReference
2424
import org.jetbrains.kotlinx.dataframe.columns.toColumnSet
2525
import org.jetbrains.kotlinx.dataframe.dataTypes.IFRAME
2626
import org.jetbrains.kotlinx.dataframe.dataTypes.IMG
27+
import org.jetbrains.kotlinx.dataframe.documentation.ExcludeFromSources
2728
import org.jetbrains.kotlinx.dataframe.exceptions.CellConversionException
2829
import org.jetbrains.kotlinx.dataframe.exceptions.TypeConversionException
2930
import org.jetbrains.kotlinx.dataframe.impl.api.Parsers
@@ -189,27 +190,38 @@ public fun <T : Any> DataColumn<T?>.convertToDouble(): DataColumn<Double?> = con
189190
* If [locale] parameter is defined, it's number format is used for parsing.
190191
* If [locale] parameter is null, the current system locale is used.
191192
* If the column cannot be parsed, then the POSIX format is used.
192-
*
193+
*/
194+
@ExcludeFromSources
195+
private interface DataColumnStringConvertToDoubleDoc
196+
197+
/** @include [DataColumnStringConvertToDoubleDoc] */
198+
@JvmName("convertToDoubleFromString")
199+
public fun DataColumn<String>.convertToDouble(locale: Locale? = null): DataColumn<Double> =
200+
convertToDouble(locale = locale, useFastDoubleParser = false)
201+
202+
/**
203+
* @include [DataColumnStringConvertToDoubleDoc]
193204
* @param useFastDoubleParser whether to use the new _experimental_ FastDoubleParser, defaults to `false` for now.
194205
*/
195206
@JvmName("convertToDoubleFromString")
196207
public fun DataColumn<String>.convertToDouble(
197208
locale: Locale? = null,
198-
useFastDoubleParser: Boolean = false,
209+
useFastDoubleParser: Boolean,
199210
): DataColumn<Double> = this.castToNullable().convertToDouble(locale, useFastDoubleParser).castToNotNullable()
200211

212+
/** @include [DataColumnStringConvertToDoubleDoc] */
213+
@JvmName("convertToDoubleFromStringNullable")
214+
public fun DataColumn<String?>.convertToDouble(locale: Locale? = null): DataColumn<Double?> =
215+
convertToDouble(locale = locale, useFastDoubleParser = false)
216+
201217
/**
202-
* Parses a String column to Double considering locale (number format).
203-
* If [locale] parameter is defined, it's number format is used for parsing.
204-
* If [locale] parameter is null, the current system locale is used.
205-
* If the column cannot be parsed, then the POSIX format is used.
206-
*
218+
* @include [DataColumnStringConvertToDoubleDoc]
207219
* @param useFastDoubleParser whether to use the new _experimental_ FastDoubleParser, defaults to `false` for now.
208220
*/
209221
@JvmName("convertToDoubleFromStringNullable")
210222
public fun DataColumn<String?>.convertToDouble(
211223
locale: Locale? = null,
212-
useFastDoubleParser: Boolean = false,
224+
useFastDoubleParser: Boolean,
213225
): DataColumn<Double?> {
214226
fun applyParser(parser: (String) -> Double?): DataColumn<Double?> {
215227
var currentRow = 0

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/parse.kt

+40
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import org.jetbrains.kotlinx.dataframe.impl.api.StringParser
1111
import org.jetbrains.kotlinx.dataframe.impl.api.parseImpl
1212
import org.jetbrains.kotlinx.dataframe.impl.api.tryParseImpl
1313
import org.jetbrains.kotlinx.dataframe.typeClass
14+
import org.jetbrains.kotlinx.dataframe.util.PARSER_OPTIONS
15+
import org.jetbrains.kotlinx.dataframe.util.PARSER_OPTIONS_COPY
1416
import java.time.format.DateTimeFormatter
1517
import java.util.Locale
1618
import kotlin.reflect.KProperty
@@ -64,6 +66,44 @@ public data class ParserOptions(
6466
val nullStrings: Set<String>? = null,
6567
val useFastDoubleParser: Boolean = false,
6668
) {
69+
70+
/** For binary compatibility. */
71+
@Deprecated(
72+
message = PARSER_OPTIONS,
73+
level = DeprecationLevel.HIDDEN,
74+
)
75+
public constructor(
76+
locale: Locale? = null,
77+
dateTimeFormatter: DateTimeFormatter? = null,
78+
dateTimePattern: String? = null,
79+
nullStrings: Set<String>? = null,
80+
) : this(
81+
locale = locale,
82+
dateTimeFormatter = dateTimeFormatter,
83+
dateTimePattern = dateTimePattern,
84+
nullStrings = nullStrings,
85+
useFastDoubleParser = false,
86+
)
87+
88+
/** For binary compatibility. */
89+
@Deprecated(
90+
message = PARSER_OPTIONS_COPY,
91+
level = DeprecationLevel.HIDDEN,
92+
)
93+
public fun copy(
94+
locale: Locale? = this.locale,
95+
dateTimeFormatter: DateTimeFormatter? = this.dateTimeFormatter,
96+
dateTimePattern: String? = this.dateTimePattern,
97+
nullStrings: Set<String>? = this.nullStrings,
98+
): ParserOptions =
99+
ParserOptions(
100+
locale = locale,
101+
dateTimeFormatter = dateTimeFormatter,
102+
dateTimePattern = dateTimePattern,
103+
nullStrings = nullStrings,
104+
useFastDoubleParser = useFastDoubleParser,
105+
)
106+
67107
internal fun getDateTimeFormatter(): DateTimeFormatter? =
68108
when {
69109
dateTimeFormatter != null -> dateTimeFormatter

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/util/deprecationMessages.kt

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ internal const val DF_READ_NO_CSV = "This function is deprecated and should be r
1515
internal const val DF_READ_NO_CSV_REPLACE =
1616
"this.readCSV(fileOrUrl, delimiter, header, colTypes, skipLines, readLines, duplicate, charset)"
1717

18+
internal const val PARSER_OPTIONS = "This constructor is only here for binary compatibility. $MESSAGE_0_16"
19+
20+
internal const val PARSER_OPTIONS_COPY = "This function is only here for binary compatibility. $MESSAGE_0_16"
21+
1822
// endregion
1923

2024
// region WARNING in 0.16, ERROR in 0.17

0 commit comments

Comments
 (0)