Skip to content

Commit dc13119

Browse files
Automated commit of generated code
1 parent cce682b commit dc13119

File tree

3 files changed

+230
-17
lines changed

3 files changed

+230
-17
lines changed

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/annotations/Plugin.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.jetbrains.kotlinx.dataframe.annotations
22

3+
import kotlin.reflect.KClass
4+
35
@Target(AnnotationTarget.CLASS)
46
public annotation class HasSchema(val schemaArg: Int)
57

@@ -46,3 +48,9 @@ internal annotation class Check
4648
*/
4749
@Target(AnnotationTarget.FUNCTION)
4850
internal annotation class AccessApiOverload
51+
52+
/**
53+
* Provides argument to `ToSpecificType` interpreter - to what type compiler plugin should convert selected columns
54+
*/
55+
@Target(AnnotationTarget.FUNCTION)
56+
public annotation class Converter(val klass: KClass<*>, val nullable: Boolean = false)

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

Lines changed: 221 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import org.jetbrains.kotlinx.dataframe.DataRow
1717
import org.jetbrains.kotlinx.dataframe.RowColumnExpression
1818
import org.jetbrains.kotlinx.dataframe.RowValueExpression
1919
import org.jetbrains.kotlinx.dataframe.annotations.AccessApiOverload
20+
import org.jetbrains.kotlinx.dataframe.annotations.Converter
2021
import org.jetbrains.kotlinx.dataframe.annotations.HasSchema
2122
import org.jetbrains.kotlinx.dataframe.annotations.Interpretable
2223
import org.jetbrains.kotlinx.dataframe.annotations.Refine
@@ -295,13 +296,38 @@ public fun <T : Any> DataColumn<T?>.convertToBoolean(): DataColumn<Boolean?> = c
295296

296297
// region convert URL
297298

298-
public fun <T, R : URL?> Convert<T, R>.toIFrame(
299+
@JvmName("toIframeFromUrlNullable")
300+
@Refine
301+
@Converter(IFRAME::class, nullable = true)
302+
@Interpretable("ToSpecificType")
303+
public fun <T> Convert<T, URL?>.toIFrame(
304+
border: Boolean = false,
305+
width: Int? = null,
306+
height: Int? = null,
307+
): DataFrame<T> = to { it.map { url -> url?.let { IFRAME(url.toString(), border, width, height) } } }
308+
309+
@JvmName("toIframeFromUrl")
310+
@Refine
311+
@Converter(IFRAME::class, nullable = false)
312+
@Interpretable("ToSpecificType")
313+
public fun <T> Convert<T, URL>.toIFrame(
299314
border: Boolean = false,
300315
width: Int? = null,
301316
height: Int? = null,
302317
): DataFrame<T> = to { it.map { IFRAME(it.toString(), border, width, height) } }
303318

304-
public fun <T, R : URL?> Convert<T, R>.toImg(width: Int? = null, height: Int? = null): DataFrame<T> =
319+
@JvmName("toImgFromUrlNullable")
320+
@Refine
321+
@Converter(IMG::class, nullable = true)
322+
@Interpretable("ToSpecificType")
323+
public fun <T, R : URL?> Convert<T, URL?>.toImg(width: Int? = null, height: Int? = null): DataFrame<T> =
324+
to { it.map { url -> url?.let { IMG(url.toString(), width, height) } } }
325+
326+
@JvmName("toImgFromUrl")
327+
@Refine
328+
@Converter(IMG::class, nullable = false)
329+
@Interpretable("ToSpecificType")
330+
public fun <T, R : URL?> Convert<T, URL>.toImg(width: Int? = null, height: Int? = null): DataFrame<T> =
305331
to { it.map { IMG(it.toString(), width, height) } }
306332

307333
// endregion
@@ -313,7 +339,17 @@ public fun DataColumn<String>.convertToURL(): DataColumn<URL> = map { URL(it) }
313339
@JvmName("convertToURLFromStringNullable")
314340
public fun DataColumn<String?>.convertToURL(): DataColumn<URL?> = map { it?.let { URL(it) } }
315341

316-
public fun <T, R : String?> Convert<T, R>.toURL(): DataFrame<T> = to { it.convertToURL() }
342+
@JvmName("toUrlFromStringNullable")
343+
@Refine
344+
@Converter(URL::class, nullable = true)
345+
@Interpretable("ToSpecificType")
346+
public fun <T> Convert<T, String?>.toURL(): DataFrame<T> = to { it.convertToURL() }
347+
348+
@JvmName("toUrlFromString")
349+
@Refine
350+
@Converter(URL::class, nullable = false)
351+
@Interpretable("ToSpecificType")
352+
public fun <T> Convert<T, String>.toURL(): DataFrame<T> = to { it.convertToURL() }
317353

318354
// endregion
319355

@@ -324,7 +360,17 @@ public fun DataColumn<String>.convertToInstant(): DataColumn<Instant> = map { In
324360
@JvmName("convertToInstantFromStringNullable")
325361
public fun DataColumn<String?>.convertToInstant(): DataColumn<Instant?> = map { it?.let { Instant.parse(it) } }
326362

327-
public fun <T, R : String?> Convert<T, R>.toInstant(): DataFrame<T> = to { it.convertToInstant() }
363+
@JvmName("toInstantFromStringNullable")
364+
@Refine
365+
@Converter(Instant::class, nullable = true)
366+
@Interpretable("ToSpecificType")
367+
public fun <T> Convert<T, String?>.toInstant(): DataFrame<T> = to { it.convertToInstant() }
368+
369+
@JvmName("toInstantFromString")
370+
@Refine
371+
@Converter(Instant::class, nullable = false)
372+
@Interpretable("ToSpecificType")
373+
public fun <T> Convert<T, String>.toInstant(): DataFrame<T> = to { it.convertToInstant() }
328374

329375
// endregion
330376

@@ -363,17 +409,51 @@ public fun DataColumn<String?>.convertToLocalDate(
363409
return map { it?.let { converter(it.trim()) ?: error("Can't convert `$it` to LocalDate") } }
364410
}
365411

412+
@JvmName("toLocalDateFromTLongNullable")
413+
@Refine
414+
@Converter(LocalDate::class, nullable = true)
415+
@Interpretable("ToSpecificTypeZone")
416+
public fun <T> Convert<T, Long?>.toLocalDate(zone: TimeZone = defaultTimeZone): DataFrame<T> =
417+
to { it.convertToLocalDate(zone) }
418+
366419
@JvmName("toLocalDateFromTLong")
367-
public fun <T, R : Long?> Convert<T, R>.toLocalDate(zone: TimeZone = defaultTimeZone): DataFrame<T> =
420+
@Refine
421+
@Converter(LocalDate::class, nullable = false)
422+
@Interpretable("ToSpecificTypeZone")
423+
public fun <T> Convert<T, Long>.toLocalDate(zone: TimeZone = defaultTimeZone): DataFrame<T> =
368424
to { it.convertToLocalDate(zone) }
369425

370426
@JvmName("toLocalDateFromTInt")
371-
public fun <T, R : Int?> Convert<T, R>.toLocalDate(zone: TimeZone = defaultTimeZone): DataFrame<T> =
427+
@Refine
428+
@Converter(LocalDate::class, nullable = true)
429+
@Interpretable("ToSpecificTypeZone")
430+
public fun <T> Convert<T, Int?>.toLocalDate(zone: TimeZone = defaultTimeZone): DataFrame<T> =
372431
to { it.convertToLocalDate(zone) }
373432

374-
public fun <T, R : String?> Convert<T, R>.toLocalDate(pattern: String? = null, locale: Locale? = null): DataFrame<T> =
433+
@JvmName("toLocalDateFromTIntNullable")
434+
@Refine
435+
@Converter(LocalDate::class, nullable = false)
436+
@Interpretable("ToSpecificTypeZone")
437+
public fun <T> Convert<T, Int>.toLocalDate(zone: TimeZone = defaultTimeZone): DataFrame<T> =
438+
to { it.convertToLocalDate(zone) }
439+
440+
@JvmName("toLocalDateFromStringNullable")
441+
@Refine
442+
@Converter(LocalDate::class, nullable = true)
443+
@Interpretable("ToSpecificTypePattern")
444+
public fun <T> Convert<T, String?>.toLocalDate(pattern: String? = null, locale: Locale? = null): DataFrame<T> =
445+
to { it.convertToLocalDate(pattern, locale) }
446+
447+
@JvmName("toLocalDateFromString")
448+
@Refine
449+
@Converter(LocalDate::class, nullable = false)
450+
@Interpretable("ToSpecificTypePattern")
451+
public fun <T> Convert<T, String>.toLocalDate(pattern: String? = null, locale: Locale? = null): DataFrame<T> =
375452
to { it.convertToLocalDate(pattern, locale) }
376453

454+
@Refine
455+
@Converter(LocalDate::class, nullable = false)
456+
@Interpretable("ToSpecificType")
377457
public fun <T> Convert<T, *>.toLocalDate(): DataFrame<T> = to { it.convertTo<LocalDate>() }
378458

379459
// endregion
@@ -413,17 +493,51 @@ public fun DataColumn<String?>.convertToLocalTime(
413493
return map { it?.let { converter(it.trim()) ?: error("Can't convert `$it` to LocalTime") } }
414494
}
415495

496+
@JvmName("toLocalTimeFromTLongNullable")
497+
@Refine
498+
@Converter(LocalTime::class, nullable = true)
499+
@Interpretable("ToSpecificTypeZone")
500+
public fun <T> Convert<T, Long?>.toLocalTime(zone: TimeZone = defaultTimeZone): DataFrame<T> =
501+
to { it.convertToLocalTime(zone) }
502+
416503
@JvmName("toLocalTimeFromTLong")
417-
public fun <T, R : Long?> Convert<T, R>.toLocalTime(zone: TimeZone = defaultTimeZone): DataFrame<T> =
504+
@Refine
505+
@Converter(LocalTime::class, nullable = false)
506+
@Interpretable("ToSpecificTypeZone")
507+
public fun <T> Convert<T, Long>.toLocalTime(zone: TimeZone = defaultTimeZone): DataFrame<T> =
508+
to { it.convertToLocalTime(zone) }
509+
510+
@JvmName("toLocalTimeFromTIntNullable")
511+
@Refine
512+
@Converter(LocalTime::class, nullable = true)
513+
@Interpretable("ToSpecificTypeZone")
514+
public fun <T> Convert<T, Int?>.toLocalTime(zone: TimeZone = defaultTimeZone): DataFrame<T> =
418515
to { it.convertToLocalTime(zone) }
419516

420517
@JvmName("toLocalTimeFromTInt")
421-
public fun <T, R : Int?> Convert<T, R>.toLocalTime(zone: TimeZone = defaultTimeZone): DataFrame<T> =
518+
@Refine
519+
@Converter(LocalTime::class, nullable = false)
520+
@Interpretable("ToSpecificTypeZone")
521+
public fun <T> Convert<T, Int>.toLocalTime(zone: TimeZone = defaultTimeZone): DataFrame<T> =
422522
to { it.convertToLocalTime(zone) }
423523

424-
public fun <T, R : String?> Convert<T, R>.toLocalTime(pattern: String? = null, locale: Locale? = null): DataFrame<T> =
524+
@JvmName("toLocalTimeFromStringNullable")
525+
@Refine
526+
@Converter(LocalTime::class, nullable = true)
527+
@Interpretable("ToSpecificTypePattern")
528+
public fun <T> Convert<T, String?>.toLocalTime(pattern: String? = null, locale: Locale? = null): DataFrame<T> =
425529
to { it.convertToLocalTime(pattern, locale) }
426530

531+
@JvmName("toLocalTimeFromString")
532+
@Refine
533+
@Converter(LocalTime::class, nullable = false)
534+
@Interpretable("ToSpecificTypePattern")
535+
public fun <T> Convert<T, String>.toLocalTime(pattern: String? = null, locale: Locale? = null): DataFrame<T> =
536+
to { it.convertToLocalTime(pattern, locale) }
537+
538+
@Refine
539+
@Converter(LocalTime::class, nullable = false)
540+
@Interpretable("ToSpecificType")
427541
public fun <T> Convert<T, *>.toLocalTime(): DataFrame<T> = to { it.convertTo<LocalTime>() }
428542

429543
// endregion
@@ -471,65 +585,155 @@ public fun DataColumn<String?>.convertToLocalDateTime(
471585
return map { it?.let { converter(it.trim()) ?: error("Can't convert `$it` to LocalDateTime") } }
472586
}
473587

588+
@JvmName("toLocalDateTimeFromTLongNullable")
589+
@Refine
590+
@Converter(LocalDateTime::class, nullable = true)
591+
@Interpretable("ToSpecificTypeZone")
592+
public fun <T> Convert<T, Long?>.toLocalDateTime(zone: TimeZone = defaultTimeZone): DataFrame<T> =
593+
to { it.convertToLocalDateTime(zone) }
594+
474595
@JvmName("toLocalDateTimeFromTLong")
475-
public fun <T, R : Long?> Convert<T, R>.toLocalDateTime(zone: TimeZone = defaultTimeZone): DataFrame<T> =
596+
@Refine
597+
@Converter(LocalDateTime::class, nullable = false)
598+
@Interpretable("ToSpecificTypeZone")
599+
public fun <T> Convert<T, Long>.toLocalDateTime(zone: TimeZone = defaultTimeZone): DataFrame<T> =
600+
to { it.convertToLocalDateTime(zone) }
601+
602+
@JvmName("toLocalDateTimeFromTInstantNullable")
603+
@Refine
604+
@Converter(LocalDateTime::class, nullable = true)
605+
@Interpretable("ToSpecificTypeZone")
606+
public fun <T> Convert<T, Instant?>.toLocalDateTime(zone: TimeZone = defaultTimeZone): DataFrame<T> =
476607
to { it.convertToLocalDateTime(zone) }
477608

478609
@JvmName("toLocalDateTimeFromTInstant")
479-
public fun <T, R : Instant?> Convert<T, R>.toLocalDateTime(zone: TimeZone = defaultTimeZone): DataFrame<T> =
610+
@Refine
611+
@Converter(LocalDateTime::class, nullable = false)
612+
@Interpretable("ToSpecificTypeZone")
613+
public fun <T> Convert<T, Instant>.toLocalDateTime(zone: TimeZone = defaultTimeZone): DataFrame<T> =
614+
to { it.convertToLocalDateTime(zone) }
615+
616+
@JvmName("toLocalDateTimeFromTIntNullable")
617+
@Refine
618+
@Converter(LocalDateTime::class, nullable = true)
619+
@Interpretable("ToSpecificTypeZone")
620+
public fun <T> Convert<T, Int?>.toLocalDateTime(zone: TimeZone = defaultTimeZone): DataFrame<T> =
480621
to { it.convertToLocalDateTime(zone) }
481622

482623
@JvmName("toLocalDateTimeFromTInt")
483-
public fun <T, R : Int?> Convert<T, R>.toLocalDateTime(zone: TimeZone = defaultTimeZone): DataFrame<T> =
624+
@Refine
625+
@Converter(LocalDateTime::class, nullable = false)
626+
@Interpretable("ToSpecificTypeZone")
627+
public fun <T> Convert<T, Int>.toLocalDateTime(zone: TimeZone = defaultTimeZone): DataFrame<T> =
484628
to { it.convertToLocalDateTime(zone) }
485629

486-
public fun <T, R : String?> Convert<T, R>.toLocalDateTime(
487-
pattern: String? = null,
488-
locale: Locale? = null,
489-
): DataFrame<T> = to { it.convertToLocalDateTime(pattern, locale) }
630+
@JvmName("toLocalDateTimeFromStringNullable")
631+
@Refine
632+
@Converter(LocalDateTime::class, nullable = true)
633+
@Interpretable("ToSpecificTypePattern")
634+
public fun <T> Convert<T, String?>.toLocalDateTime(pattern: String? = null, locale: Locale? = null): DataFrame<T> =
635+
to { it.convertToLocalDateTime(pattern, locale) }
490636

637+
@JvmName("toLocalDateTimeFromString")
638+
@Refine
639+
@Converter(LocalDateTime::class, nullable = false)
640+
@Interpretable("ToSpecificTypePattern")
641+
public fun <T> Convert<T, String>.toLocalDateTime(pattern: String? = null, locale: Locale? = null): DataFrame<T> =
642+
to { it.convertToLocalDateTime(pattern, locale) }
643+
644+
@Refine
645+
@Converter(LocalDateTime::class, nullable = false)
646+
@Interpretable("ToSpecificType")
491647
public fun <T> Convert<T, *>.toLocalDateTime(): DataFrame<T> = to { it.convertTo<LocalDateTime>() }
492648

493649
// endregion
494650

495651
@JvmName("toIntTAny")
652+
@Refine
653+
@Converter(Int::class, nullable = false)
654+
@Interpretable("ToSpecificType")
496655
public fun <T> Convert<T, Any>.toInt(): DataFrame<T> = to<Int>()
497656

657+
@Refine
658+
@Converter(Int::class, nullable = true)
659+
@Interpretable("ToSpecificType")
498660
public fun <T> Convert<T, Any?>.toInt(): DataFrame<T> = to<Int?>()
499661

500662
@JvmName("toLongTAny")
663+
@Refine
664+
@Converter(Long::class, nullable = false)
665+
@Interpretable("ToSpecificType")
501666
public fun <T> Convert<T, Any>.toLong(): DataFrame<T> = to<Long>()
502667

668+
@Refine
669+
@Converter(Long::class, nullable = true)
670+
@Interpretable("ToSpecificType")
503671
public fun <T> Convert<T, Any?>.toLong(): DataFrame<T> = to<Long?>()
504672

505673
@JvmName("toStrTAny")
674+
@Refine
675+
@Converter(String::class, nullable = false)
676+
@Interpretable("ToSpecificType")
506677
public fun <T> Convert<T, Any>.toStr(): DataFrame<T> = to<String>()
507678

679+
@Refine
680+
@Converter(String::class, nullable = true)
681+
@Interpretable("ToSpecificType")
508682
public fun <T> Convert<T, Any?>.toStr(): DataFrame<T> = to<String?>()
509683

510684
@JvmName("toDoubleTAny")
685+
@Refine
686+
@Converter(Double::class, nullable = false)
687+
@Interpretable("ToSpecificType")
511688
public fun <T> Convert<T, Any>.toDouble(): DataFrame<T> = to<Double>()
512689

690+
@Refine
691+
@Converter(Double::class, nullable = true)
692+
@Interpretable("ToSpecificType")
513693
public fun <T> Convert<T, Any?>.toDouble(): DataFrame<T> = to<Double?>()
514694

515695
@JvmName("toFloatTAny")
696+
@Refine
697+
@Converter(Float::class, nullable = false)
698+
@Interpretable("ToSpecificType")
516699
public fun <T> Convert<T, Any>.toFloat(): DataFrame<T> = to<Float>()
517700

701+
@Refine
702+
@Converter(Float::class, nullable = true)
703+
@Interpretable("ToSpecificType")
518704
public fun <T> Convert<T, Any?>.toFloat(): DataFrame<T> = to<Float?>()
519705

520706
@JvmName("toBigDecimalTAny")
707+
@Refine
708+
@Converter(BigDecimal::class, nullable = false)
709+
@Interpretable("ToSpecificType")
521710
public fun <T> Convert<T, Any>.toBigDecimal(): DataFrame<T> = to<BigDecimal>()
522711

712+
@Refine
713+
@Converter(BigDecimal::class, nullable = true)
714+
@Interpretable("ToSpecificType")
523715
public fun <T> Convert<T, Any?>.toBigDecimal(): DataFrame<T> = to<BigDecimal?>()
524716

525717
@JvmName("toBigIntegerTAny")
718+
@Refine
719+
@Converter(BigInteger::class, nullable = false)
720+
@Interpretable("ToSpecificType")
526721
public fun <T> Convert<T, Any>.toBigInteger(): DataFrame<T> = to<BigInteger>()
527722

723+
@Refine
724+
@Converter(BigInteger::class, nullable = true)
725+
@Interpretable("ToSpecificType")
528726
public fun <T> Convert<T, Any?>.toBigInteger(): DataFrame<T> = to<BigInteger?>()
529727

530728
@JvmName("toBooleanTAny")
729+
@Refine
730+
@Converter(Boolean::class, nullable = false)
731+
@Interpretable("ToSpecificType")
531732
public fun <T> Convert<T, Any>.toBoolean(): DataFrame<T> = to<Boolean>()
532733

734+
@Refine
735+
@Converter(Boolean::class, nullable = true)
736+
@Interpretable("ToSpecificType")
533737
public fun <T> Convert<T, Any?>.toBoolean(): DataFrame<T> = to<Boolean?>()
534738

535739
public fun <T, C> Convert<T, List<List<C>>>.toDataFrames(containsColumns: Boolean = false): DataFrame<T> =

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/split.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ public fun <T, C> Split<T, DataFrame<C>>.into(
185185
public fun <T, A, B> Split<T, Pair<A, B>>.into(firstCol: String, secondCol: String): DataFrame<T> =
186186
by { listOf(it.first, it.second) }.into(firstCol, secondCol)
187187

188+
@AccessApiOverload
188189
public inline fun <T, reified A, reified B> Split<T, Pair<A, B>>.into(
189190
firstCol: ColumnAccessor<A>,
190191
secondCol: ColumnAccessor<B>,

0 commit comments

Comments
 (0)