Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.nio.file.Path;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.vector.ipc.ArrowFileReader;
import org.apache.arrow.vector.ipc.ArrowReader;
Expand Down Expand Up @@ -69,13 +70,7 @@ public CompletableFuture<Void> show() {
DataFrames.showDataframe(
runtimePointer,
dataframe,
(String errString) -> {
if (ErrorUtil.containsError(errString)) {
future.completeExceptionally(new RuntimeException(errString));
} else {
future.complete(null);
}
});
new RuntimeExceptionCallback(future));
return future;
}

Expand All @@ -89,13 +84,7 @@ public CompletableFuture<Void> writeParquet(Path path) {
runtimePointer,
dataframe,
path.toAbsolutePath().toString(),
(String errString) -> {
if (ErrorUtil.containsError(errString)) {
future.completeExceptionally(new RuntimeException(errString));
} else {
future.complete(null);
}
});
new RuntimeExceptionCallback(future));
return future;
}

Expand All @@ -109,13 +98,7 @@ public CompletableFuture<Void> writeCsv(Path path) {
runtimePointer,
dataframe,
path.toAbsolutePath().toString(),
(String errString) -> {
if (ErrorUtil.containsError(errString)) {
future.completeExceptionally(new RuntimeException(errString));
} else {
future.complete(null);
}
});
new RuntimeExceptionCallback(future));
return future;
}

Expand All @@ -130,4 +113,21 @@ public TableProvider intoView() {
void doClose(long pointer) {
DataFrames.destroyDataFrame(pointer);
}

private static class RuntimeExceptionCallback implements Consumer<String> {
private final CompletableFuture<?> future;

private RuntimeExceptionCallback(CompletableFuture<?> future) {
this.future = future;
}

@Override
public void accept(String errString) {
if (ErrorUtil.containsError(errString)) {
future.completeExceptionally(new RuntimeException(errString));
} else {
future.complete(null);
}
}
}
}
Loading