Package com.clickhouse.data
Class ClickHousePipedOutputStream
java.lang.Object
java.io.OutputStream
com.clickhouse.data.ClickHouseOutputStream
com.clickhouse.data.ClickHousePipedOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
SPSC(Single-producer single-consumer) channel for streaming.
-
Field Summary
Fields inherited from class com.clickhouse.data.ClickHouseOutputStream
closed, DEFAULT_BUFFER_SIZE, ERROR_NULL_BYTES, ERROR_REUSE_BUFFER, ERROR_STREAM_CLOSED, postCloseAction, stream, TYPE_NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal ClickHouseInputStreamGets input stream to reada data being written into the output stream.abstract ClickHouseInputStreamgetInputStream(Runnable postCloseAction) Gets input stream to reada data being written into the output stream.protected static voidhandleWriteResult(CompletableFuture<?> future, long timeout, Runnable postCloseAction) Handles async write result.protected static CompletableFuture<Void>writeAsync(ClickHouseWriter writer, ClickHousePipedOutputStream output) Writes data to the piped output stream in a separate thread.Methods inherited from class com.clickhouse.data.ClickHouseOutputStream
close, empty, ensureOpen, getUnderlyingFile, getUnderlyingStream, hasUnderlyingStream, isClosed, of, of, of, of, of, transferBytes, transferBytes, transferBytes, write, write, write, writeAsciiString, writeBoolean, writeBuffer, writeByte, writeBytes, writeBytes, writeBytes, writeCustom, writeString, writeUnicodeString, writeUnsignedVarInt, writeVarIntMethods inherited from class java.io.OutputStream
flush, nullOutputStream
-
Constructor Details
-
ClickHousePipedOutputStream
-
-
Method Details
-
handleWriteResult
protected static void handleWriteResult(CompletableFuture<?> future, long timeout, Runnable postCloseAction) throws UncheckedIOException Handles async write result.- Parameters:
future- async write resulttimeout- timeout in millisecondspostCloseAction- post close aciton, could be null- Throws:
UncheckedIOException- when writing failed
-
writeAsync
protected static CompletableFuture<Void> writeAsync(ClickHouseWriter writer, ClickHousePipedOutputStream output) Writes data to the piped output stream in a separate thread. The given piped output stream will be closed automatically at the end of writing.- Parameters:
writer- non-null custom writeroutput- non-null piped output stream- Returns:
- non-null future
-
getInputStream
Gets input stream to reada data being written into the output stream.- Returns:
- non-null input stream
-
getInputStream
Gets input stream to reada data being written into the output stream.- Parameters:
postCloseAction- custom action will be performed right after closing the input stream- Returns:
- non-null input stream
-