Package com.clickhouse.client.data
Class ClickHouseSimpleResponse
- java.lang.Object
-
- com.clickhouse.client.data.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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static ClickHouseSimpleResponseEMPTY
-
Constructor Summary
Constructors Modifier Constructor Description protectedClickHouseSimpleResponse(List<ClickHouseColumn> columns, ClickHouseValue[][] values, ClickHouseResponseSummary summary)protectedClickHouseSimpleResponse(List<ClickHouseColumn> columns, List<ClickHouseRecord> records, ClickHouseResponseSummary summary)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()List<ClickHouseColumn>getColumns()Gets list of columns.InputStreamgetInputStream()Gets input stream of the response.ClickHouseResponseSummarygetSummary()Gets summary of this response.booleanisClosed()Checks whether the reponse has been closed or not.static ClickHouseResponseof(ClickHouseConfig config, List<ClickHouseColumn> columns, Object[][] values)Creates a response object using columns definition and raw values.static ClickHouseResponseof(ClickHouseConfig config, List<ClickHouseColumn> columns, Object[][] values, ClickHouseResponseSummary summary)Creates a response object using columns definition and raw values.static ClickHouseResponseof(ClickHouseResponse response)Creates a response object by copying columns and values from the given one.static ClickHouseResponseof(ClickHouseResponse response, ClickHouseRecordTransformer func)Creates a response object by copying columns and values from the given one.Iterable<ClickHouseRecord>records()Returns an iterable collection of records which can be walked through in a foreach loop.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.clickhouse.client.ClickHouseResponse
firstRecord, pipe, stream
-
-
-
-
Field Detail
-
EMPTY
public static final ClickHouseSimpleResponse EMPTY
-
-
Constructor Detail
-
ClickHouseSimpleResponse
protected ClickHouseSimpleResponse(List<ClickHouseColumn> columns, List<ClickHouseRecord> records, ClickHouseResponseSummary summary)
-
ClickHouseSimpleResponse
protected ClickHouseSimpleResponse(List<ClickHouseColumn> columns, ClickHouseValue[][] values, ClickHouseResponseSummary summary)
-
-
Method Detail
-
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 configcolumns- list of columnsvalues- 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)
Creates a response object using columns definition and raw values.- Parameters:
config- non-null configcolumns- list of columnsvalues- raw values, which may or may not be null- Returns:
- response object
-
of
public static ClickHouseResponse of(ClickHouseResponse response)
Creates a response object by copying columns and values from the given one. Same asof(response, null).- Parameters:
response- response to copy- Returns:
- new response object
-
of
public static ClickHouseResponse of(ClickHouseResponse response, ClickHouseRecordTransformer func)
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, whenfuncis 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 copyfunc- optinal function to update value by column index- Returns:
- new response object
-
getColumns
public List<ClickHouseColumn> getColumns()
Description copied from interface:ClickHouseResponseGets list of columns.- Specified by:
getColumnsin interfaceClickHouseResponse- Returns:
- non-null list of column
-
getSummary
public ClickHouseResponseSummary getSummary()
Description copied from interface:ClickHouseResponseGets summary of this response. Keep in mind that the summary may change over time until response is closed.- Specified by:
getSummaryin interfaceClickHouseResponse- Returns:
- non-null summary of this response
-
getInputStream
public InputStream getInputStream()
Description copied from interface:ClickHouseResponseGets 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:
getInputStreamin interfaceClickHouseResponse- Returns:
- input stream for getting raw data returned from server
-
records
public Iterable<ClickHouseRecord> records()
Description copied from interface:ClickHouseResponseReturns an iterable collection of records which can be walked through in a foreach loop. Please pay attention that: 1)UncheckedIOExceptionmight be thrown when iterating through the collection; and 2) it's not supposed to be called for more than once.- Specified by:
recordsin interfaceClickHouseResponse- Returns:
- non-null iterable collection
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceClickHouseResponse
-
isClosed
public boolean isClosed()
Description copied from interface:ClickHouseResponseChecks whether the reponse has been closed or not.- Specified by:
isClosedin interfaceClickHouseResponse- Returns:
- true if the response has been closed; false otherwise
-
-