Package com.clickhouse.client
Class ClickHouseSimpleResponse
java.lang.Object
com.clickhouse.client.ClickHouseSimpleResponse
- All Implemented Interfaces:
ClickHouseResponse,Serializable,AutoCloseable
A simple response built on top of two lists: columns and records.
- See Also:
-
Field Summary
Fields inherited from interface com.clickhouse.client.ClickHouseResponse
EMPTY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedClickHouseSimpleResponse(List<ClickHouseColumn> columns, ClickHouseValue[][] values, ClickHouseResponseSummary summary) protectedClickHouseSimpleResponse(List<ClickHouseColumn> columns, List<ClickHouseRecord> records, ClickHouseResponseSummary summary) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Gets list of columns.Gets input stream of the response.Gets summary of this response.booleanisClosed()Checks whether the response 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.records()Returns an iterable collection of records which can be walked through in a foreach loop.<T> Iterable<T>Returns an iterable collection of mapped objects 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, waitMethods inherited from interface com.clickhouse.client.ClickHouseResponse
firstRecord, firstRecord, pipe, stream, stream
-
Constructor Details
-
ClickHouseSimpleResponse
protected ClickHouseSimpleResponse(List<ClickHouseColumn> columns, List<ClickHouseRecord> records, ClickHouseResponseSummary summary) -
ClickHouseSimpleResponse
protected ClickHouseSimpleResponse(List<ClickHouseColumn> columns, ClickHouseValue[][] values, ClickHouseResponseSummary summary)
-
-
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 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 nullsummary- response summary- Returns:
- response object
-
of
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
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
Description copied from interface:ClickHouseResponseGets list of columns.- Specified by:
getColumnsin interfaceClickHouseResponse- Returns:
- non-null list of column
-
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
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:
- non-null input stream for getting raw data returned from server
-
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
-
records
Description copied from interface:ClickHouseResponseReturns an iterable collection of mapped objects which can be walked through in a foreach loop. WhenobjClassis null orClickHouseRecord, it's same as callingClickHouseResponse.records().- Specified by:
recordsin interfaceClickHouseResponse- 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceClickHouseResponse
-
isClosed
public boolean isClosed()Description copied from interface:ClickHouseResponseChecks whether the response has been closed or not.- Specified by:
isClosedin interfaceClickHouseResponse- Returns:
- true if the response has been closed; false otherwise
-