Skip to content

Commit 8c81603

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

File tree

3 files changed

+68
-8
lines changed

3 files changed

+68
-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

+42
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ 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
16+
import org.jetbrains.kotlinx.dataframe.util.PARSER_OPTIONS_COPY_REPLACE
17+
import org.jetbrains.kotlinx.dataframe.util.PARSER_OPTIONS_REPLACE
1418
import java.time.format.DateTimeFormatter
1519
import java.util.Locale
1620
import kotlin.reflect.KProperty
@@ -64,6 +68,44 @@ public data class ParserOptions(
6468
val nullStrings: Set<String>? = null,
6569
val useFastDoubleParser: Boolean = false,
6670
) {
71+
72+
@Deprecated(
73+
message = PARSER_OPTIONS,
74+
replaceWith = ReplaceWith(PARSER_OPTIONS_REPLACE),
75+
level = DeprecationLevel.HIDDEN,
76+
)
77+
public constructor(
78+
locale: Locale? = null,
79+
dateTimeFormatter: DateTimeFormatter? = null,
80+
dateTimePattern: String? = null,
81+
nullStrings: Set<String>? = null,
82+
) : this(
83+
locale = locale,
84+
dateTimeFormatter = dateTimeFormatter,
85+
dateTimePattern = dateTimePattern,
86+
nullStrings = nullStrings,
87+
useFastDoubleParser = false,
88+
)
89+
90+
@Deprecated(
91+
message = PARSER_OPTIONS_COPY,
92+
replaceWith = ReplaceWith(PARSER_OPTIONS_COPY_REPLACE),
93+
level = DeprecationLevel.HIDDEN,
94+
)
95+
public fun copy(
96+
locale: Locale? = this.locale,
97+
dateTimeFormatter: DateTimeFormatter? = this.dateTimeFormatter,
98+
dateTimePattern: String? = this.dateTimePattern,
99+
nullStrings: Set<String>? = this.nullStrings,
100+
): ParserOptions =
101+
ParserOptions(
102+
locale = locale,
103+
dateTimeFormatter = dateTimeFormatter,
104+
dateTimePattern = dateTimePattern,
105+
nullStrings = nullStrings,
106+
useFastDoubleParser = useFastDoubleParser,
107+
)
108+
67109
internal fun getDateTimeFormatter(): DateTimeFormatter? =
68110
when {
69111
dateTimeFormatter != null -> dateTimeFormatter

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

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ 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+
internal const val PARSER_OPTIONS_REPLACE = "ParserOptions(locale, dateTimeFormatter, dateTimePattern, nullStrings, false)"
20+
21+
internal const val PARSER_OPTIONS_COPY = "This function is only here for binary compatibility. $MESSAGE_0_16"
22+
internal const val PARSER_OPTIONS_COPY_REPLACE = "copy(locale, dateTimeFormatter, dateTimePattern, nullStrings, false)"
23+
1824
// endregion
1925

2026
// region WARNING in 0.16, ERROR in 0.17

0 commit comments

Comments
 (0)