You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* If [restrictWidening] is true, [dataFrame] columns not described in [targetSchema] would not be saved (otherwise, would be saved as is).
99
+
* If [restrictNarrowing] is true, [targetSchema] fields that are not nullable and do not exist in [dataFrame] will produce exception (otherwise, would not be saved).
100
+
* If [strictType] is true, [dataFrame] columns described in [targetSchema] with non-compatible type will produce exception (otherwise, would be saved as is).
101
+
* If [strictNullable] is true, [targetSchema] fields that are not nullable and contain nulls in [dataFrame] will produce exception (otherwise, would be saved as is with nullable = true).
@@ -201,117 +236,185 @@ public class ArrowWriter(public val dataFrame: DataFrame<*>, public val targetSc
201
236
}
202
237
203
238
/**
204
-
* Create Arrow VectorSchemaRoot with [dataFrame] content cast to [targetSchema].
205
-
* If [restrictWidening] is true, [dataFrame] columns not described in [targetSchema] would not be saved (otherwise, would be saved as is).
206
-
* If [restrictNarrowing] is true, [targetSchema] fields that are not nullable and do not exist in [dataFrame] will produce exception (otherwise, would not be saved).
207
-
* If [strictType] is true, [dataFrame] columns described in [targetSchema] with non-compatible type will produce exception (otherwise, would be saved as is).
208
-
* If [strictNullable] is true, [targetSchema] fields that are not nullable and contain nulls in [dataFrame] will produce exception (otherwise, would be saved as is with nullable = true).
239
+
* Create Arrow VectorSchemaRoot with [dataFrame] content cast to [targetSchema] according to the [mode].
* Save data to [Arrow interprocess streaming format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-streaming-format), write to opened [channel].
* Save data to [Arrow interprocess streaming format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-streaming-format), write to opened [stream].
280
+
*/
281
+
publicfunwriteArrowIPC(stream:OutputStream) {
282
+
writeArrowIPC(Channels.newChannel(stream))
283
+
}
284
+
285
+
/**
286
+
* Save data to [Arrow interprocess streaming format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-streaming-format), write to new or existing [file].
287
+
* If file exists, it can be recreated or expanded.
* Save data to [Arrow interprocess streaming format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-streaming-format), write to new [ByteArray]
295
+
*/
296
+
publicfunsaveArrowIPCToByteArray(): ByteArray {
297
+
val stream =ByteArrayOutputStream()
298
+
writeArrowIPC(stream)
299
+
return stream.toByteArray()
300
+
}
301
+
302
+
// Feather saving block
303
+
304
+
/**
305
+
* Save data to [Arrow random access format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-random-access-files), write to opened [channel].
* Save data to [Arrow random access format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-random-access-files), write to opened [stream].
* Save data to [Arrow random access format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-random-access-files), write to new or existing [file].
324
+
* If file exists, it would be recreated.
325
+
*/
326
+
publicfunwriteArrowFeather(file:File) {
327
+
writeArrowFeather(FileOutputStream(file))
328
+
}
329
+
330
+
/**
331
+
* Save data to [Arrow random access format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-random-access-files), write to new [ByteArray]
// * Save data to [Arrow interprocess streaming format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-streaming-format), write to new or existing [file].
282
-
// * If file exists, it can be recreated or expanded.
283
-
// */
284
-
//public fun AnyFrame.writeArrowIPC(file: File, append: Boolean = true) {
285
-
//
286
-
//}
287
-
//
288
-
///**
289
-
// * Save data to [Arrow interprocess streaming format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-streaming-format), write to [ByteArray]
290
-
// */
291
-
//public fun AnyFrame.writeArrowIPCToByteArray() {
292
-
//
293
-
//}
294
-
//
295
-
//// Feather saving block
296
-
//
297
-
///**
298
-
// * Save data to [Arrow random access format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-random-access-files), write to new or existing [file].
299
-
// * If file exists, it would be recreated.
300
-
// */
301
-
//public fun AnyFrame.writeArrowFeather(file: File) {
302
-
//
303
-
//}
304
-
//
305
-
///**
306
-
// * Save data to [Arrow random access format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-random-access-files), write to [ByteArray]
307
-
// */
308
-
//public fun DataFrame.Companion.writeArrowFeatherToByteArray(): ByteArray {
309
-
//
310
-
//}
311
-
//
312
-
///**
313
-
// * Write [Arrow random access format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-random-access-files) from existing [stream]
314
-
// */
315
-
//public fun DataFrame.Companion.writeArrowFeather(stream: OutputStream) {
316
-
//
317
-
//}
343
+
344
+
// IPC saving block with default parameters
345
+
346
+
/**
347
+
* Save data to [Arrow interprocess streaming format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-streaming-format), write to opened [channel].
* Save data to [Arrow interprocess streaming format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-streaming-format), write to opened [stream].
* Save data to [Arrow interprocess streaming format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-streaming-format), write to new or existing [file].
366
+
* If file exists, it can be recreated or expanded.
* Save data to [Arrow interprocess streaming format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-streaming-format), write to new [ByteArray]
* Save data to [Arrow random access format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-random-access-files), write to opened [channel].
* Save data to [Arrow random access format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-random-access-files), write to opened [stream].
* Save data to [Arrow random access format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-random-access-files), write to new or existing [file].
405
+
* If file exists, it would be recreated.
406
+
*/
407
+
publicfun AnyFrame.writeArrowFeather(file:File) {
408
+
this.arrowWriter().use { writer ->
409
+
writer.writeArrowFeather(file)
410
+
}
411
+
}
412
+
413
+
/**
414
+
* Save data to [Arrow random access format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-random-access-files), write to new [ByteArray]
0 commit comments