Skip to content

Commit 513c4e3

Browse files
Automated commit of generated code
1 parent f6444b3 commit 513c4e3

File tree

8 files changed

+54
-22
lines changed

8 files changed

+54
-22
lines changed

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

+18
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import org.jetbrains.kotlinx.dataframe.DataColumn
55
import org.jetbrains.kotlinx.dataframe.Predicate
66
import org.jetbrains.kotlinx.dataframe.columns.ColumnReference
77
import java.math.BigDecimal
8+
import java.math.BigInteger
89

910
public operator fun DataColumn<Boolean>.not(): DataColumn<Boolean> = map { !it }
1011

@@ -169,6 +170,23 @@ public operator fun DataColumn<BigDecimal>.div(value: BigDecimal): DataColumn<Bi
169170

170171
public operator fun BigDecimal.div(column: DataColumn<BigDecimal>): DataColumn<BigDecimal> = column.map { this / it }
171172

173+
public operator fun DataColumn<BigInteger>.plus(value: BigInteger): DataColumn<BigInteger> = map { it + value }
174+
175+
public operator fun DataColumn<BigInteger>.minus(value: BigInteger): DataColumn<BigInteger> = map { it - value }
176+
177+
public operator fun BigInteger.plus(column: DataColumn<BigInteger>): DataColumn<BigInteger> = column.map { this + it }
178+
179+
public operator fun BigInteger.minus(column: DataColumn<BigInteger>): DataColumn<BigInteger> = column.map { this - it }
180+
181+
@JvmName("unaryMinusBigInteger")
182+
public operator fun DataColumn<BigInteger>.unaryMinus(): DataColumn<BigInteger> = map { -it }
183+
184+
public operator fun DataColumn<BigInteger>.times(value: BigInteger): DataColumn<BigInteger> = map { it * value }
185+
186+
public operator fun DataColumn<BigInteger>.div(value: BigInteger): DataColumn<BigInteger> = map { it / value }
187+
188+
public operator fun BigInteger.div(column: DataColumn<BigInteger>): DataColumn<BigInteger> = column.map { this / it }
189+
172190
public infix fun <T> DataColumn<T>.eq(value: T): DataColumn<Boolean> = isMatching { it == value }
173191

174192
public infix fun <T> DataColumn<T>.neq(value: T): DataColumn<Boolean> = isMatching { it != value }

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

+11
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import org.jetbrains.kotlinx.dataframe.impl.api.withRowCellImpl
3636
import org.jetbrains.kotlinx.dataframe.impl.headPlusArray
3737
import org.jetbrains.kotlinx.dataframe.io.toDataFrame
3838
import java.math.BigDecimal
39+
import java.math.BigInteger
3940
import java.net.URL
4041
import java.util.Locale
4142
import kotlin.reflect.KProperty
@@ -273,6 +274,11 @@ public fun <T : Any> DataColumn<T>.convertToBigDecimal(): DataColumn<BigDecimal>
273274

274275
public fun <T : Any> DataColumn<T?>.convertToBigDecimal(): DataColumn<BigDecimal?> = convertTo()
275276

277+
@JvmName("convertToBigIntegerFromT")
278+
public fun <T : Any> DataColumn<T>.convertToBigInteger(): DataColumn<BigInteger> = convertTo()
279+
280+
public fun <T : Any> DataColumn<T?>.convertToBigInteger(): DataColumn<BigInteger?> = convertTo()
281+
276282
@JvmName("convertToBooleanFromT")
277283
public fun <T : Any> DataColumn<T>.convertToBoolean(): DataColumn<Boolean> = convertTo()
278284

@@ -507,6 +513,11 @@ public fun <T> Convert<T, Any>.toBigDecimal(): DataFrame<T> = to<BigDecimal>()
507513

508514
public fun <T> Convert<T, Any?>.toBigDecimal(): DataFrame<T> = to<BigDecimal?>()
509515

516+
@JvmName("toBigIntegerTAny")
517+
public fun <T> Convert<T, Any>.toBigInteger(): DataFrame<T> = to<BigInteger>()
518+
519+
public fun <T> Convert<T, Any?>.toBigInteger(): DataFrame<T> = to<BigInteger?>()
520+
510521
@JvmName("toBooleanTAny")
511522
public fun <T> Convert<T, Any>.toBoolean(): DataFrame<T> = to<Boolean>()
512523

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/TypeUtils.kt

-14
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import kotlin.reflect.full.superclasses
3131
import kotlin.reflect.full.withNullability
3232
import kotlin.reflect.jvm.jvmErasure
3333
import kotlin.reflect.typeOf
34-
import kotlin.toBigDecimal as toBigDecimalKotlin
3534

3635
internal inline fun <reified T> KClass<*>.createTypeUsing() = typeOf<T>().projectTo(this)
3736

@@ -649,16 +648,3 @@ internal fun Any.asArrayAsListOrNull(): List<*>? =
649648
}
650649

651650
internal fun Any.isBigNumber(): Boolean = this is BigInteger || this is BigDecimal
652-
653-
internal fun Number.toBigDecimal(): BigDecimal =
654-
when (this) {
655-
is BigDecimal -> this
656-
is BigInteger -> this.toBigDecimalKotlin()
657-
is Int -> this.toBigDecimalKotlin()
658-
is Byte -> this.toInt().toBigDecimalKotlin()
659-
is Short -> this.toInt().toBigDecimalKotlin()
660-
is Long -> this.toBigDecimalKotlin()
661-
is Float -> this.toBigDecimalKotlin()
662-
is Double -> this.toBigDecimalKotlin()
663-
else -> BigDecimal(this.toString())
664-
}

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/Utils.kt

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ internal fun <T> List<T>.removeAt(index: Int) = subList(0, index) + subList(inde
6464

6565
internal inline fun <reified T : Any> Int.cast() = convert(this, T::class)
6666

67+
// TODO remove in favor of column convert logic, Issue #971
6768
internal fun <T : Any> convert(src: Int, tartypeOf: KClass<T>): T =
6869
when (tartypeOf) {
6970
Double::class -> src.toDouble() as T

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

+18-7
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,13 @@ import kotlin.reflect.full.withNullability
5555
import kotlin.reflect.jvm.jvmErasure
5656
import kotlin.reflect.typeOf
5757
import kotlin.text.trim
58+
import kotlin.toBigDecimal
5859
import java.time.Instant as JavaInstant
5960
import java.time.LocalDate as JavaLocalDate
6061
import java.time.LocalDateTime as JavaLocalDateTime
6162
import java.time.LocalTime as JavaLocalTime
63+
import kotlin.toBigDecimal as toBigDecimalKotlin
64+
import kotlin.toBigInteger as toBigIntegerKotlin
6265

6366
@PublishedApi
6467
internal fun <T, C, R> Convert<T, C>.withRowCellImpl(
@@ -716,17 +719,25 @@ internal val defaultTimeZone = TimeZone.currentSystemDefault()
716719
internal fun Number.toBigDecimal(): BigDecimal =
717720
when (this) {
718721
is BigDecimal -> this
719-
is BigInteger -> BigDecimal(this)
720-
is Double -> BigDecimal.valueOf(this)
721-
is Int -> BigDecimal(this)
722-
is Long -> BigDecimal.valueOf(this)
723-
else -> BigDecimal.valueOf(this.toDouble())
722+
is BigInteger -> this.toBigDecimalKotlin()
723+
is Int -> this.toBigDecimalKotlin()
724+
is Byte -> this.toInt().toBigDecimalKotlin()
725+
is Short -> this.toInt().toBigDecimalKotlin()
726+
is Long -> this.toBigDecimalKotlin()
727+
is Float -> this.toBigDecimalKotlin()
728+
is Double -> this.toBigDecimalKotlin()
729+
else -> BigDecimal(this.toString())
724730
}
725731

726732
internal fun Number.toBigInteger(): BigInteger =
727733
when (this) {
728734
is BigInteger -> this
729735
is BigDecimal -> this.toBigInteger()
730-
is Long -> BigInteger.valueOf(this)
731-
else -> BigInteger.valueOf(this.toLong())
736+
is Int -> this.toBigIntegerKotlin()
737+
is Byte -> this.toInt().toBigIntegerKotlin()
738+
is Short -> this.toInt().toBigIntegerKotlin()
739+
is Long -> this.toBigIntegerKotlin()
740+
is Float -> this.roundToInt().toBigIntegerKotlin()
741+
is Double -> this.roundToLong().toBigIntegerKotlin()
742+
else -> BigInteger(this.toString())
732743
}

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

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import org.jetbrains.kotlinx.dataframe.impl.columns.addPath
3030
import org.jetbrains.kotlinx.dataframe.impl.columns.asAnyFrameColumn
3131
import org.jetbrains.kotlinx.dataframe.impl.isBigNumber
3232
import org.jetbrains.kotlinx.dataframe.impl.renderType
33-
import org.jetbrains.kotlinx.dataframe.impl.toBigDecimal
3433
import org.jetbrains.kotlinx.dataframe.index
3534
import org.jetbrains.kotlinx.dataframe.kind
3635
import org.jetbrains.kotlinx.dataframe.type

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

+3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import org.jetbrains.kotlinx.dataframe.io.isUrl
3939
import org.jetbrains.kotlinx.dataframe.io.readJsonStr
4040
import org.jetbrains.kotlinx.dataframe.values
4141
import java.math.BigDecimal
42+
import java.math.BigInteger
4243
import java.net.URL
4344
import java.text.ParsePosition
4445
import java.time.format.DateTimeFormatter
@@ -390,6 +391,8 @@ internal object Parsers : GlobalParserOptions {
390391
posixParserToDoubleWithOptions,
391392
// Boolean
392393
stringParser<Boolean> { it.toBooleanOrNull() },
394+
// BigInteger
395+
stringParser<BigInteger> { it.toBigIntegerOrNull() },
393396
// BigDecimal
394397
stringParser<BigDecimal> { it.toBigDecimalOrNull() },
395398
// JSON array as DataFrame<*>

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/csv.kt

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import java.io.Reader
3838
import java.io.StringReader
3939
import java.io.StringWriter
4040
import java.math.BigDecimal
41+
import java.math.BigInteger
4142
import java.net.URL
4243
import java.nio.charset.Charset
4344
import java.util.zip.GZIPInputStream
@@ -298,6 +299,7 @@ public enum class ColType {
298299
Double,
299300
Boolean,
300301
BigDecimal,
302+
BigInteger,
301303
LocalDate,
302304
LocalTime,
303305
LocalDateTime,
@@ -329,6 +331,7 @@ public fun ColType.toKType(): KType =
329331
ColType.Double -> typeOf<Double>()
330332
ColType.Boolean -> typeOf<Boolean>()
331333
ColType.BigDecimal -> typeOf<BigDecimal>()
334+
ColType.BigInteger -> typeOf<BigInteger>()
332335
ColType.LocalDate -> typeOf<LocalDate>()
333336
ColType.LocalTime -> typeOf<LocalTime>()
334337
ColType.LocalDateTime -> typeOf<LocalDateTime>()

0 commit comments

Comments
 (0)