Class ClickHousePipedOutputStream

All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public abstract class ClickHousePipedOutputStream extends ClickHouseOutputStream
SPSC(Single-producer single-consumer) channel for streaming.
  • Constructor Details

    • ClickHousePipedOutputStream

      protected ClickHousePipedOutputStream(Runnable postCloseAction)
  • Method Details

    • handleWriteResult

      protected static void handleWriteResult(CompletableFuture<?> future, long timeout, Runnable postCloseAction) throws UncheckedIOException
      Handles async write result.
      Parameters:
      future - async write result
      timeout - timeout in milliseconds
      postCloseAction - 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 writer
      output - non-null piped output stream
      Returns:
      non-null future
    • getInputStream

      public final ClickHouseInputStream getInputStream()
      Gets input stream to reada data being written into the output stream.
      Returns:
      non-null input stream
    • getInputStream

      public abstract ClickHouseInputStream getInputStream(Runnable postCloseAction)
      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