Skip to content

Commit 2b38cbc

Browse files
fix Path overloads
1 parent 886af8b commit 2b38cbc

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,7 @@ public interface ArrowWriter : AutoCloseable {
100100

101101
/** Path overload for Arrow IPC writing. */
102102
public fun writeArrowIPC(path: Path, append: Boolean = true) {
103-
// For append=true use FileOutputStream on File to preserve semantics; otherwise use Files.newOutputStream
104-
if (append) {
105-
writeArrowIPC(FileOutputStream(path.toFile(), /* append = */ true))
106-
} else {
107-
Files.newOutputStream(path).use { os -> writeArrowIPC(os) }
108-
}
103+
writeArrowIPC(path.toFile(), append)
109104
}
110105

111106
/**
@@ -147,7 +142,7 @@ public interface ArrowWriter : AutoCloseable {
147142

148143
/** Path overload for Arrow Feather writing. */
149144
public fun writeArrowFeather(path: Path) {
150-
Files.newOutputStream(path).use { os -> writeArrowFeather(os) }
145+
writeArrowFeather(path.toFile())
151146
}
152147

153148
/**

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public fun DataFrame.Companion.readArrowFeather(
7575
public fun DataFrame.Companion.readArrowIPC(
7676
file: File,
7777
nullability: NullabilityOptions = NullabilityOptions.Infer,
78-
): AnyFrame = Files.newByteChannel(file.toPath()).use { readArrowIPC(it, nullability = nullability) }
78+
): AnyFrame = readArrowIPC(file.toPath(), nullability)
7979

8080
/** Path overload for reading Arrow IPC from file path. */
8181
public fun DataFrame.Companion.readArrowIPC(
@@ -134,7 +134,7 @@ public fun DataFrame.Companion.readArrowIPC(
134134
public fun DataFrame.Companion.readArrowFeather(
135135
file: File,
136136
nullability: NullabilityOptions = NullabilityOptions.Infer,
137-
): AnyFrame = Files.newByteChannel(file.toPath()).use { readArrowFeather(it, nullability = nullability) }
137+
): AnyFrame = readArrowFeather(file.toPath(), nullability)
138138

139139
/** Path overload for reading Arrow Feather from file path. */
140140
public fun DataFrame.Companion.readArrowFeather(

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ public fun AnyFrame.writeArrowIPC(file: File, append: Boolean = true) {
5454

5555
/** Path overload for IPC writing. */
5656
public fun AnyFrame.writeArrowIPC(path: Path, append: Boolean = true) {
57-
this.arrowWriter().use { writer ->
58-
writer.writeArrowIPC(path, append)
59-
}
57+
writeArrowIPC(path.toFile(), append)
6058
}
6159

6260
/**
@@ -99,9 +97,7 @@ public fun AnyFrame.writeArrowFeather(file: File) {
9997

10098
/** Path overload for Feather writing. */
10199
public fun AnyFrame.writeArrowFeather(path: Path) {
102-
this.arrowWriter().use { writer ->
103-
writer.writeArrowFeather(path)
104-
}
100+
writeArrowFeather(path.toFile())
105101
}
106102

107103
/**

0 commit comments

Comments
 (0)