Skip to content

Commit 9ff9de2

Browse files
committed
Prettify per linter
1 parent b760974 commit 9ff9de2

File tree

3 files changed

+46
-26
lines changed

3 files changed

+46
-26
lines changed

dataframe-arrow/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/ArrowWriter.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@ import java.nio.channels.Channels
1515
import java.nio.channels.WritableByteChannel
1616

1717
public val ignoreMismatchMessage: (ConvertingMismatch) -> Unit = { message: ConvertingMismatch -> }
18-
public val writeMismatchMessage: (ConvertingMismatch) -> Unit = { message: ConvertingMismatch -> System.err.println(message) }
18+
public val writeMismatchMessage: (ConvertingMismatch) -> Unit = { message: ConvertingMismatch ->
19+
System.err.println(message)
20+
}
1921

2022
private val logger = LoggerFactory.getLogger(ArrowWriter::class.java)
2123

22-
public val logMismatchMessage: (ConvertingMismatch) -> Unit = { message: ConvertingMismatch -> logger.debug(message.toString()) }
24+
public val logMismatchMessage: (ConvertingMismatch) -> Unit = { message: ConvertingMismatch ->
25+
logger.debug(message.toString())
26+
}
2327

2428
/**
2529
* Save [dataFrame] content in Apache Arrow format (can be written to File, ByteArray, OutputStream or raw Channel) with [targetSchema].
@@ -137,5 +141,4 @@ public interface ArrowWriter : AutoCloseable {
137141
writeArrowFeather(stream)
138142
return stream.toByteArray()
139143
}
140-
141144
}

dataframe-arrow/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/ArrowWriterImpl.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ import org.jetbrains.kotlinx.dataframe.exceptions.TypeConverterNotFoundException
6060
*/
6161
internal class ArrowWriterImpl(
6262
override val dataFrame: DataFrame<*>,
63-
override val targetSchema: Schema,
63+
override val targetSchema: Schema,
6464
override val mode: ArrowWriter.Companion.Mode,
6565
override val mismatchSubscriber: (ConvertingMismatch) -> Unit = ignoreMismatchMessage
66-
): ArrowWriter {
66+
) : ArrowWriter {
6767

6868
private val allocator = RootAllocator()
6969

@@ -97,7 +97,7 @@ internal class ArrowWriterImpl(
9797
ArrowType.Int(64, true) -> column.convertToLong()
9898
// ArrowType.Int(8, false), ArrowType.Int(16, false), ArrowType.Int(32, false), ArrowType.Int(64, false) -> todo
9999
is ArrowType.Decimal -> column.convertToBigDecimal()
100-
ArrowType.FloatingPoint(FloatingPointPrecision.SINGLE) -> column.convertToDouble().convertToFloat() //Use [convertToDouble] as locale logic step
100+
ArrowType.FloatingPoint(FloatingPointPrecision.SINGLE) -> column.convertToDouble().convertToFloat() // Use [convertToDouble] as locale logic step
101101
ArrowType.FloatingPoint(FloatingPointPrecision.DOUBLE) -> column.convertToDouble()
102102
ArrowType.Date(DateUnit.DAY) -> column.convertToLocalDate()
103103
ArrowType.Date(DateUnit.MILLISECOND) -> column.convertToLocalDateTime()
@@ -181,11 +181,11 @@ internal class ArrowWriterImpl(
181181
}
182182

183183
val vector = if (!actualField.isNullable && containNulls) {
184-
var firstNullValue: Int? = null;
184+
var firstNullValue: Int? = null
185185
for (i in 0 until (column?.size() ?: -1)) {
186186
if (column!![i] == null) {
187-
firstNullValue = i;
188-
break;
187+
firstNullValue = i
188+
break
189189
}
190190
}
191191
if (strictNullable) {

dataframe-arrow/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/ConvertingMismatch.kt

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,49 +16,66 @@ public sealed class ConvertingMismatch(
1616
public open val cause: Exception?
1717
) {
1818

19-
public sealed class WideningMismatch(column: String): ConvertingMismatch(column, null, null) {
20-
public data class AddedColumn(override val column: String): WideningMismatch(column) {
19+
public sealed class WideningMismatch(column: String) : ConvertingMismatch(column, null, null) {
20+
public data class AddedColumn(override val column: String) : WideningMismatch(column) {
2121
override fun toString(): String = "Added column \"$column\" not described in target schema"
2222
}
23-
public data class RejectedColumn(override val column: String): WideningMismatch(column) {
23+
public data class RejectedColumn(override val column: String) : WideningMismatch(column) {
2424
override fun toString(): String = "Column \"$column\" is not described in target schema and was ignored"
2525
}
2626
}
27-
public sealed class NarrowingMismatch(column: String): ConvertingMismatch(column, null, null) {
28-
public data class NotPresentedColumnIgnored(override val column: String): NarrowingMismatch(column) {
27+
28+
public sealed class NarrowingMismatch(column: String) : ConvertingMismatch(column, null, null) {
29+
public data class NotPresentedColumnIgnored(override val column: String) : NarrowingMismatch(column) {
2930
override fun toString(): String = "Not nullable column \"$column\" is not presented in actual data, saving as is"
3031
}
31-
public data class NotPresentedColumnError(override val column: String): NarrowingMismatch(column) {
32+
public data class NotPresentedColumnError(override val column: String) : NarrowingMismatch(column) {
3233
override fun toString(): String = "Not nullable column \"$column\" is not presented in actual data, can not save"
3334
}
3435
}
35-
public sealed class TypeConversionNotFound(column: String, cause: TypeConverterNotFoundException): ConvertingMismatch(column, null, cause) {
36-
public data class ConversionNotFoundIgnored(override val column: String, override val cause: TypeConverterNotFoundException): TypeConversionNotFound(column, cause) {
36+
37+
public sealed class TypeConversionNotFound(
38+
column: String,
39+
cause: TypeConverterNotFoundException
40+
) : ConvertingMismatch(column, null, cause) {
41+
public data class ConversionNotFoundIgnored(override val column: String, override val cause: TypeConverterNotFoundException) : TypeConversionNotFound(column, cause) {
3742
override fun toString(): String = "${cause.message} for column \"$column\", saving as is"
3843
}
39-
public data class ConversionNotFoundError(override val column: String, val e: TypeConverterNotFoundException): TypeConversionNotFound(column, e) {
44+
public data class ConversionNotFoundError(override val column: String, val e: TypeConverterNotFoundException) : TypeConversionNotFound(column, e) {
4045
override fun toString(): String = "${e.message} for column \"$column\", can not save"
4146
}
4247
}
43-
public sealed class TypeConversionFail(column: String, row: Int?, public override val cause: CellConversionException): ConvertingMismatch(column, row, cause) {
44-
public data class ConversionFailIgnored(override val column: String, override val row: Int?, override val cause: CellConversionException): TypeConversionFail(column, row, cause) {
48+
49+
public sealed class TypeConversionFail(
50+
column: String, row: Int?,
51+
public override val cause: CellConversionException
52+
) : ConvertingMismatch(column, row, cause) {
53+
public data class ConversionFailIgnored(override val column: String, override val row: Int?, override val cause: CellConversionException) : TypeConversionFail(column, row, cause) {
4554
override fun toString(): String = "${cause.message}, saving as is"
4655
}
47-
public data class ConversionFailError(override val column: String, override val row: Int?, override val cause: CellConversionException): TypeConversionFail(column, row, cause) {
56+
public data class ConversionFailError(override val column: String, override val row: Int?, override val cause: CellConversionException) : TypeConversionFail(column, row, cause) {
4857
override fun toString(): String = "${cause.message}, can not save"
4958
}
5059
}
51-
public data class SavedAsString(override val column: String, val type: Class<*>): ConvertingMismatch(column, null, null) {
60+
61+
public data class SavedAsString(
62+
override val column: String,
63+
val type: Class<*>
64+
) : ConvertingMismatch(column, null, null) {
5265
override fun toString(): String = "Column \"$column\" has type ${type.canonicalName}, will be saved as String\""
5366
}
54-
public sealed class NullableMismatch(column: String, row: Int?): ConvertingMismatch(column, row, null) {
55-
public data class NullValueIgnored(override val column: String, override val row: Int?): NullableMismatch(column, row) {
67+
68+
public sealed class NullableMismatch(
69+
column: String,
70+
row: Int?
71+
) : ConvertingMismatch(column, row, null) {
72+
public data class NullValueIgnored(override val column: String, override val row: Int?) : NullableMismatch(column, row) {
5673
override fun toString(): String = "Column \"$column\" contains nulls in row $row but expected not nullable, saving as is"
5774
}
58-
public data class NullValueError(override val column: String, override val row: Int?): NullableMismatch(column, row) {
75+
public data class NullValueError(override val column: String, override val row: Int?) : NullableMismatch(column, row) {
5976
override fun toString(): String = "Column \"$column\" contains nulls in row $row but expected not nullable, can not save"
6077
}
6178
}
6279
}
6380

64-
public class ConvertingException(public val mismatchCase: ConvertingMismatch): IllegalArgumentException(mismatchCase.toString(), mismatchCase.cause)
81+
public class ConvertingException(public val mismatchCase: ConvertingMismatch) : IllegalArgumentException(mismatchCase.toString(), mismatchCase.cause)

0 commit comments

Comments
 (0)