Class ClickHousePassThruStream

java.lang.Object
com.clickhouse.data.ClickHousePassThruStream
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ClickHouseFile

public class ClickHousePassThruStream extends Object implements Serializable
This class encapsulates custom input and output stream to ensure no compression/decompression will be applied during execution.
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • of

      public static ClickHousePassThruStream of(InputStream in, ClickHouseCompression compression, ClickHouseFormat format)
    • of

      public static ClickHousePassThruStream of(InputStream in, ClickHouseCompression compression, int compressionLevel, ClickHouseFormat format)
    • of

      public static ClickHousePassThruStream of(ClickHouseWriter writer, ClickHouseCompression compression, ClickHouseFormat format)
    • of

      public static ClickHousePassThruStream of(ClickHouseWriter writer, ClickHouseCompression compression, int compressionLevel, ClickHouseFormat format)
    • of

      public static ClickHousePassThruStream of(OutputStream out, ClickHouseCompression compression, ClickHouseFormat format)
    • of

      public static ClickHousePassThruStream of(OutputStream out, ClickHouseCompression compression, int compressionLevel, ClickHouseFormat format)
    • of

      public static ClickHousePassThruStream of(InputStream in, OutputStream out, ClickHouseCompression compression, int compressionLevel, ClickHouseFormat format)
    • getInputStream

      public ClickHouseInputStream getInputStream()
      Gets the input stream for reading. Please pay attention that the returned input stream has nothing to do with this pass-thru stream, as getInputStream().getUnderlyingStream() is always NULL.
      Returns:
      non-null input stream
    • newInputStream

      public ClickHouseInputStream newInputStream(int bufferSize, Runnable postCloseAction)
      Creates a wrapped input stream for reading. Calling this method multiple times will generate multiple ClickHouseInputStream instances pointing to the same input stream, so it does not make sense to call this more than once. Unlike getInputStream(), the returned input stream is associated with this pass-thru stream, so newInputStream(...).getUnderlyingStream() simply returns the current pass-thru stream.
      Parameters:
      bufferSize - buffer size which is always greater than zero(usually 4096 or larger)
      postCloseAction - custom action will be performed right after closing the input stream
      Returns:
      non-null wrapped input stream
    • getOutputStream

      public ClickHouseOutputStream getOutputStream()
      Gets the output stream for writing. Please pay attention that the returned output stream has nothing to do with this pass-thru stream, as getOutputStream().getUnderlyingStream() is always NULL.
      Returns:
      non-null output stream
    • newOutputStream

      public ClickHouseOutputStream newOutputStream(int bufferSize, Runnable postCloseAction)
      Creates a wrapped output stream for writing. Calling this method multiple times will generate multiple ClickHouseOutputStream instances, so it does not make sense to call this more than once. Unlike getOutputStream(), the returned output stream is associated with this pass-thru stream, so newOutputStream(...).getUnderlyingStream() simply returns the current pass-thru stream.
      Parameters:
      bufferSize - buffer size which is always greater than zero(usually 4096 or larger)
      postCloseAction - custom action will be performed right after closing the output stream
      Returns:
      non-null wrapped output stream
    • getCompressionAlgorithm

      public ClickHouseCompression getCompressionAlgorithm()
      Gets compression algorithm, which could be null. Use hasCompression() to check first.
      Returns:
      compression algorithm, could be null
    • getCompressionLevel

      public int getCompressionLevel()
      Gets compression level.
      Returns:
      compression level
    • getFormat

      public ClickHouseFormat getFormat()
      Gets data format, which could be null. Use hasFormat() to check first.
      Returns:
      data format, could be null
    • hasCompression

      public boolean hasCompression()
      Checks if the compression algorithm is defined or not.
      Returns:
      true if the compression algorithm is defined; false otherwise
    • hasFormat

      public boolean hasFormat()
      Checks if the data format is defined or not.
      Returns:
      true if the data format is defined; false otherwise
    • hasInput

      public boolean hasInput()
      Checks if input stream is available or not.
      Returns:
      true if input stream is available; false otherwise
    • hasOutput

      public boolean hasOutput()
      Checks if output stream is available or not.
      Returns:
      true if output stream is available; false otherwise
    • isCompressed

      public boolean isCompressed()
      Checks if the data is compressed or not.
      Returns:
      true if the data is compressed; false otherwise