Class ClickHouseSimpleResponse

java.lang.Object
com.clickhouse.client.ClickHouseSimpleResponse
All Implemented Interfaces:
ClickHouseResponse, Serializable, AutoCloseable

public class ClickHouseSimpleResponse extends Object implements ClickHouseResponse
A simple response built on top of two lists: columns and records.
See Also:
  • Constructor Details

  • Method Details

    • of

      public static ClickHouseResponse of(ClickHouseConfig config, List<ClickHouseColumn> columns, Object[][] values)
      Creates a response object using columns definition and raw values.
      Parameters:
      config - non-null config
      columns - list of columns
      values - raw values, which may or may not be null
      Returns:
      response object
    • of

      public static ClickHouseResponse of(ClickHouseConfig config, List<ClickHouseColumn> columns, Object[][] values, ClickHouseResponseSummary summary, TimeZone timeZone)
      Creates a response object using columns definition and raw values.
      Parameters:
      config - non-null config
      columns - list of columns
      values - raw values, which may or may not be null
      summary - response summary
      Returns:
      response object
    • of

      public static ClickHouseResponse of(ClickHouseResponse response)
      Creates a response object by copying columns and values from the given one. Same as of(response, null).
      Parameters:
      response - response to copy
      Returns:
      new response object
    • of

      Creates a response object by copying columns and values from the given one. You should never use this method against a large response, because it will load everything into memory. Worse than that, when func is not null, it will be applied to every single row, which is going to be slow when original response contains many records.
      Parameters:
      response - response to copy
      func - optinal function to update value by column index
      Returns:
      new response object
    • getColumns

      public List<ClickHouseColumn> getColumns()
      Description copied from interface: ClickHouseResponse
      Gets list of columns.
      Specified by:
      getColumns in interface ClickHouseResponse
      Returns:
      non-null list of column
    • getSummary

      public ClickHouseResponseSummary getSummary()
      Description copied from interface: ClickHouseResponse
      Gets summary of this response. Keep in mind that the summary may change over time until response is closed.
      Specified by:
      getSummary in interface ClickHouseResponse
      Returns:
      non-null summary of this response
    • getInputStream

      public ClickHouseInputStream getInputStream()
      Description copied from interface: ClickHouseResponse
      Gets input stream of the response. In general, this is the most memory-efficient way for streaming data from server to client. However, this also means additional work is required for deserialization, especially when using a binary format.
      Specified by:
      getInputStream in interface ClickHouseResponse
      Returns:
      non-null input stream for getting raw data returned from server
    • getTimeZone

      public TimeZone getTimeZone()
      Description copied from interface: ClickHouseResponse
      Returns a server timezone if it is returned by server in a header X-ClickHouse-Timezone or other way. If not, it returns null
      Specified by:
      getTimeZone in interface ClickHouseResponse
      Returns:
      server timezone from server response or null
    • records

      public Iterable<ClickHouseRecord> records()
      Description copied from interface: ClickHouseResponse
      Returns an iterable collection of records which can be walked through in a foreach loop. Please pay attention that: 1) UncheckedIOException might be thrown when iterating through the collection; and 2) it's not supposed to be called for more than once.
      Specified by:
      records in interface ClickHouseResponse
      Returns:
      non-null iterable collection
    • records

      public <T> Iterable<T> records(Class<T> objClass)
      Description copied from interface: ClickHouseResponse
      Returns an iterable collection of mapped objects which can be walked through in a foreach loop. When objClass is null or ClickHouseRecord, it's same as calling ClickHouseResponse.records().
      Specified by:
      records in interface ClickHouseResponse
      Type Parameters:
      T - type of the mapped object
      Parameters:
      objClass - non-null class of the mapped object
      Returns:
      non-null iterable collection
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface ClickHouseResponse
    • isClosed

      public boolean isClosed()
      Description copied from interface: ClickHouseResponse
      Checks whether the response has been closed or not.
      Specified by:
      isClosed in interface ClickHouseResponse
      Returns:
      true if the response has been closed; false otherwise