@@ -184,22 +184,47 @@ public fun <T : Any> DataColumn<T>.convertToDouble(): DataColumn<Double> = conve
184
184
185
185
public fun <T : Any > DataColumn<T?>.convertToDouble (): DataColumn <Double ?> = convertTo()
186
186
187
+ /* * Parses a String column to Double considering locale (number format).
188
+ * If [locale] parameter is defined, it's number format is used for parsing.
189
+ * If [locale] parameter is null, the current system locale is used.
190
+ * If the column cannot be parsed, then the POSIX format is used. */
191
+ @JvmName(" convertToDoubleFromString" )
192
+ public fun DataColumn<String>.convertToDouble (locale : Locale ? = null): DataColumn <Double > =
193
+ convertToDouble(locale = locale, useFastDoubleParser = false )
194
+
187
195
/* *
188
- * Parse String column to Double considering locale (number format).
196
+ * Parses a String column to Double considering locale (number format).
189
197
* If [locale] parameter is defined, it's number format is used for parsing.
190
- * If [locale] parameter is null, the current system locale is used. If column can not be parsed, then POSIX format is used.
198
+ * If [locale] parameter is null, the current system locale is used.
199
+ * If the column cannot be parsed, then the POSIX format is used.
200
+ * @param useFastDoubleParser whether to use the new _experimental_ FastDoubleParser, defaults to `false` for now.
191
201
*/
192
202
@JvmName(" convertToDoubleFromString" )
193
- public fun DataColumn<String>.convertToDouble (locale : Locale ? = null): DataColumn <Double > =
194
- this .castToNullable().convertToDouble(locale).castToNotNullable()
203
+ public fun DataColumn<String>.convertToDouble (
204
+ locale : Locale ? = null,
205
+ useFastDoubleParser : Boolean ,
206
+ ): DataColumn <Double > = this .castToNullable().convertToDouble(locale, useFastDoubleParser).castToNotNullable()
207
+
208
+ /* * Parses a String column to Double considering locale (number format).
209
+ * If [locale] parameter is defined, it's number format is used for parsing.
210
+ * If [locale] parameter is null, the current system locale is used.
211
+ * If the column cannot be parsed, then the POSIX format is used. */
212
+ @JvmName(" convertToDoubleFromStringNullable" )
213
+ public fun DataColumn<String?>.convertToDouble (locale : Locale ? = null): DataColumn <Double ?> =
214
+ convertToDouble(locale = locale, useFastDoubleParser = false )
195
215
196
216
/* *
197
- * Parse String column to Double considering locale (number format).
217
+ * Parses a String column to Double considering locale (number format).
198
218
* If [locale] parameter is defined, it's number format is used for parsing.
199
- * If [locale] parameter is null, the current system locale is used. If column can not be parsed, then POSIX format is used.
219
+ * If [locale] parameter is null, the current system locale is used.
220
+ * If the column cannot be parsed, then the POSIX format is used.
221
+ * @param useFastDoubleParser whether to use the new _experimental_ FastDoubleParser, defaults to `false` for now.
200
222
*/
201
223
@JvmName(" convertToDoubleFromStringNullable" )
202
- public fun DataColumn<String?>.convertToDouble (locale : Locale ? = null): DataColumn <Double ?> {
224
+ public fun DataColumn<String?>.convertToDouble (
225
+ locale : Locale ? = null,
226
+ useFastDoubleParser : Boolean ,
227
+ ): DataColumn <Double ?> {
203
228
fun applyParser (parser : (String ) -> Double? ): DataColumn <Double ?> {
204
229
var currentRow = 0
205
230
try {
@@ -220,14 +245,14 @@ public fun DataColumn<String?>.convertToDouble(locale: Locale? = null): DataColu
220
245
}
221
246
222
247
return if (locale != null ) {
223
- val explicitParser = Parsers .getDoubleParser(locale)
248
+ val explicitParser = Parsers .getDoubleParser(locale, useFastDoubleParser )
224
249
applyParser(explicitParser)
225
250
} else {
226
251
try {
227
- val defaultParser = Parsers .getDoubleParser()
252
+ val defaultParser = Parsers .getDoubleParser(useFastDoubleParser = useFastDoubleParser )
228
253
applyParser(defaultParser)
229
254
} catch (e: TypeConversionException ) {
230
- val posixParser = Parsers .getDoubleParser(Locale .forLanguageTag(" C.UTF-8" ))
255
+ val posixParser = Parsers .getDoubleParser(Locale .forLanguageTag(" C.UTF-8" ), useFastDoubleParser )
231
256
applyParser(posixParser)
232
257
}
233
258
}
0 commit comments