Class AbstractBinaryFormatReader
java.lang.Object
com.clickhouse.client.api.data_formats.internal.AbstractBinaryFormatReader
- All Implemented Interfaces:
ClickHouseBinaryFormatReader,AutoCloseable
- Direct Known Subclasses:
NativeFormatReader,RowBinaryFormatReader,RowBinaryWithNamesAndTypesFormatReader,RowBinaryWithNamesFormatReader
public abstract class AbstractBinaryFormatReader
extends Object
implements ClickHouseBinaryFormatReader
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BinaryStreamReaderprotected InputStreamprotected AtomicBoolean -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractBinaryFormatReader(InputStream inputStream, QuerySettings querySettings, TableSchema schema, BinaryStreamReader.ByteBufferAllocator byteBufferAllocator) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected voidgetBigDecimal(int index) Reads column with name `colName` as a BigDecimal.getBigDecimal(String colName) Reads column with name `colName` as a BigDecimal.getBigInteger(int index) Reads column with name `colName` as a BigInteger.getBigInteger(String colName) Reads column with name `colName` as a BigInteger.booleangetBoolean(int index) Reads column with name `colName` as a boolean.booleangetBoolean(String colName) Reads column with name `colName` as a boolean.boolean[]getBooleanArray(int index) boolean[]getBooleanArray(String colName) bytegetByte(int index) Reads column with name `colName` as a byte.byteReads column with name `colName` as a byte.byte[]getByteArray(int index) Reads column with name `colName` as a string.byte[]getByteArray(String colName) Reads column with name `colName` as a string.getClickHouseBitmap(int index) getClickHouseBitmap(String colName) Map[]doublegetDouble(int index) Reads column with name `colName` as a double.doubleReads column with name `colName` as a double.double[]getDoubleArray(int index) Reads column with name `colName` as a string.double[]getDoubleArray(String colName) Reads column with name `colName` as a string.getDuration(int index) Returns the value of the specified column as a Duration.getDuration(String colName) Returns the value of the specified column as a Duration.shortgetEnum16(int index) shortbytegetEnum8(int index) bytefloatgetFloat(int index) Reads column with name `colName` as a float.floatReads column with name `colName` as a float.float[]getFloatArray(int index) Reads column with name `colName` as a string.float[]getFloatArray(String colName) Reads column with name `colName` as a string.getGeoMultiPolygon(int index) Returns the value of the specified column as a ClickHouseGeoMultiPolygonValue.getGeoMultiPolygon(String colName) Returns the value of the specified column as a ClickHouseGeoMultiPolygonValue.getGeoPoint(int index) Returns the value of the specified column as a ClickHouseGeoPointValue.getGeoPoint(String colName) Returns the value of the specified column as a ClickHouseGeoPointValue.getGeoPolygon(int index) Returns the value of the specified column as a ClickHouseGeoPolygonValue.getGeoPolygon(String colName) Returns the value of the specified column as a ClickHouseGeoPolygonValue.getGeoRing(int index) Returns the value of the specified column as a ClickHouseGeoRingValue.getGeoRing(String colName) Returns the value of the specified column as a ClickHouseGeoRingValue.getInet4Address(int index) Returns the value of the specified column as an Inet4Address.getInet4Address(String colName) Returns the value of the specified column as an Inet4Address.getInet6Address(int index) Returns the value of the specified column as an Inet6Address.getInet6Address(String colName) Returns the value of the specified column as an Inet6Address.getInstant(int index) Returns the value of the specified column as an Instant.getInstant(String colName) Returns the value of the specified column as an Instant.int[]getIntArray(int index) Reads column with name `colName` as a string.int[]getIntArray(String colName) Reads column with name `colName` as a string.intgetInteger(int index) Reads column with name `colName` as an integer.intgetInteger(String colName) Reads column with name `colName` as an integer.<T> List<T>getList(int index) Reads column with name `colName` as a string.<T> List<T>Reads column with name `colName` as a string.getLocalDate(int index) getLocalDate(String colName) getLocalDateTime(int index) getLocalDateTime(String colName) longgetLong(int index) Reads column with name `colName` as a long.longReads column with name `colName` as a long.long[]getLongArray(int index) Reads column with name `colName` as a string.long[]getLongArray(String colName) Reads column with name `colName` as a string.getOffsetDateTime(int index) getOffsetDateTime(String colName) shortgetShort(int index) Reads column with name `colName` as a short.shortReads column with name `colName` as a short.getString(int index) Reads column with name `colName` as a string.Reads column with name `colName` as a string.getTemporalAmount(int index) getTemporalAmount(String colName) Object[]getTuple(int index) Object[]getUUID(int index) Returns the value of the specified column as a UUID.Returns the value of the specified column as a UUID.getZonedDateTime(int index) Returns the value of the specified column as a ZonedDateTime.getZonedDateTime(String colName) Returns the value of the specified column as a ZonedDateTime.booleanhasNext()Checks if there are more rows to read.booleanhasValue(int colIndex) booleannext()Moves cursor to the next row.static StringreadAsString(Object value, ClickHouseColumn column) Converts value in to a string representation.protected voidbooleanreadRecord(Map<String, Object> record) It is still internal method and should be used with care.booleanreadToPOJO(Map<String, POJOSetter> deserializers, Object obj) Reads next record into POJO object using set of serializers.<T> TreadValue(int colIndex) Reads a single value from the stream.<T> TReads a row to an array of objects.protected voidsetSchema(TableSchema schema)
-
Field Details
-
input
-
settings
-
binaryStreamReader
-
currentRecord
-
nextRecord
-
nextRecordEmpty
-
-
Constructor Details
-
AbstractBinaryFormatReader
protected AbstractBinaryFormatReader(InputStream inputStream, QuerySettings querySettings, TableSchema schema, BinaryStreamReader.ByteBufferAllocator byteBufferAllocator)
-
-
Method Details
-
readToPOJO
Reads next record into POJO object using set of serializers. There should be a serializer for each column in the record, otherwise it will silently skip a field It is done in such a way because it is not the reader concern. Calling code should validate this. Note: internal API- Parameters:
deserializers-obj-- Returns:
- Throws:
IOException
-
readRecord
It is still internal method and should be used with care. Usually this method is called to read next record into internal object and affects hasNext() method. So after calling this one: - hasNext(), next() should not be called - stream should be read with readRecord() method fully- Parameters:
record-- Returns:
- Throws:
IOException
-
readValue
public <T> T readValue(int colIndex) Description copied from interface:ClickHouseBinaryFormatReaderReads a single value from the stream.- Specified by:
readValuein interfaceClickHouseBinaryFormatReader- Returns:
-
readValue
Description copied from interface:ClickHouseBinaryFormatReaderReads a row to an array of objects.- Specified by:
readValuein interfaceClickHouseBinaryFormatReader- Returns:
-
hasNext
public boolean hasNext()Description copied from interface:ClickHouseBinaryFormatReaderChecks if there are more rows to read.- Specified by:
hasNextin interfaceClickHouseBinaryFormatReader- Returns:
-
readNextRecord
protected void readNextRecord() -
next
Description copied from interface:ClickHouseBinaryFormatReaderMoves cursor to the next row. Must be called before reading the first row. Returns reference to an internal record representation. It means that next call to the method will affect value in returned Map. This is done for memory usage optimization. Method is intended to be used only by the client not an application.- Specified by:
nextin interfaceClickHouseBinaryFormatReader- Returns:
- reference to a map filled with column values or null if no more records are available
-
endReached
protected void endReached() -
setSchema
-
getConvertions
-
getSchema
- Specified by:
getSchemain interfaceClickHouseBinaryFormatReader
-
getString
Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as a string.- Specified by:
getStringin interfaceClickHouseBinaryFormatReader- Parameters:
colName- - column name- Returns:
-
readAsString
Converts value in to a string representation. Does some formatting for selected data types- Returns:
- string representation of a value for specified column
-
getString
Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as a string.- Specified by:
getStringin interfaceClickHouseBinaryFormatReader- Returns:
-
getByte
Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as a byte.- Specified by:
getBytein interfaceClickHouseBinaryFormatReader- Parameters:
colName- - column name- Returns:
-
getShort
Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as a short.- Specified by:
getShortin interfaceClickHouseBinaryFormatReader- Parameters:
colName- - column name- Returns:
-
getInteger
Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as an integer.- Specified by:
getIntegerin interfaceClickHouseBinaryFormatReader- Parameters:
colName- - column name- Returns:
-
getLong
Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as a long.- Specified by:
getLongin interfaceClickHouseBinaryFormatReader- Parameters:
colName- - column name- Returns:
-
getFloat
Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as a float. Warning: this method may lose precision for float values.- Specified by:
getFloatin interfaceClickHouseBinaryFormatReader- Returns:
-
getDouble
Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as a double. Warning: this method may lose precision for double values.- Specified by:
getDoublein interfaceClickHouseBinaryFormatReader- Returns:
-
getBoolean
Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as a boolean.- Specified by:
getBooleanin interfaceClickHouseBinaryFormatReader- Returns:
-
getBigInteger
Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as a BigInteger.- Specified by:
getBigIntegerin interfaceClickHouseBinaryFormatReader- Returns:
-
getBigDecimal
Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as a BigDecimal.- Specified by:
getBigDecimalin interfaceClickHouseBinaryFormatReader- Returns:
-
getInstant
Description copied from interface:ClickHouseBinaryFormatReaderReturns the value of the specified column as an Instant. Timezone is derived from the column definition. If no timezone is specified in the column definition then UTC will be used. If column value is Date or Date32 it will return an Instant with time set to 00:00:00. If column value is DateTime or DateTime32 it will return an Instant with the time part.- Specified by:
getInstantin interfaceClickHouseBinaryFormatReader- Returns:
-
getZonedDateTime
Description copied from interface:ClickHouseBinaryFormatReaderReturns the value of the specified column as a ZonedDateTime. Timezone is derived from the column definition. If no timezone is specified in the column definition then UTC will be used. If column value is Date or Date32 it will return a ZonedDateTime with time set to 00:00:00. If column value is DateTime or DateTime32 it will return a ZonedDateTime with the time part.- Specified by:
getZonedDateTimein interfaceClickHouseBinaryFormatReader- Returns:
-
getDuration
Description copied from interface:ClickHouseBinaryFormatReaderReturns the value of the specified column as a Duration. If a stored value is bigger than Long.MAX_VALUE then exception will be thrown. In such case use asBigInteger() method. If value of IntervalQuarter then Duration will be in the unit of Months.- Specified by:
getDurationin interfaceClickHouseBinaryFormatReader- Returns:
- Duration in the unit of column type.
-
getTemporalAmount
- Specified by:
getTemporalAmountin interfaceClickHouseBinaryFormatReader
-
getInet4Address
Description copied from interface:ClickHouseBinaryFormatReaderReturns the value of the specified column as an Inet4Address.- Specified by:
getInet4Addressin interfaceClickHouseBinaryFormatReader- Returns:
-
getInet6Address
Description copied from interface:ClickHouseBinaryFormatReaderReturns the value of the specified column as an Inet6Address.- Specified by:
getInet6Addressin interfaceClickHouseBinaryFormatReader- Returns:
-
getUUID
Description copied from interface:ClickHouseBinaryFormatReaderReturns the value of the specified column as a UUID.- Specified by:
getUUIDin interfaceClickHouseBinaryFormatReader- Returns:
-
getGeoPoint
Description copied from interface:ClickHouseBinaryFormatReaderReturns the value of the specified column as a ClickHouseGeoPointValue.- Specified by:
getGeoPointin interfaceClickHouseBinaryFormatReader- Returns:
-
getGeoRing
Description copied from interface:ClickHouseBinaryFormatReaderReturns the value of the specified column as a ClickHouseGeoRingValue.- Specified by:
getGeoRingin interfaceClickHouseBinaryFormatReader- Returns:
-
getGeoPolygon
Description copied from interface:ClickHouseBinaryFormatReaderReturns the value of the specified column as a ClickHouseGeoPolygonValue.- Specified by:
getGeoPolygonin interfaceClickHouseBinaryFormatReader- Returns:
-
getGeoMultiPolygon
Description copied from interface:ClickHouseBinaryFormatReaderReturns the value of the specified column as a ClickHouseGeoMultiPolygonValue.- Specified by:
getGeoMultiPolygonin interfaceClickHouseBinaryFormatReader- Returns:
-
getList
Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as a string.- Specified by:
getListin interfaceClickHouseBinaryFormatReader- Parameters:
colName- - column name- Returns:
-
getByteArray
Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as a string.- Specified by:
getByteArrayin interfaceClickHouseBinaryFormatReader- Parameters:
colName- - column name- Returns:
-
getIntArray
Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as a string.- Specified by:
getIntArrayin interfaceClickHouseBinaryFormatReader- Parameters:
colName- - column name- Returns:
-
getLongArray
Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as a string.- Specified by:
getLongArrayin interfaceClickHouseBinaryFormatReader- Parameters:
colName- - column name- Returns:
-
getFloatArray
Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as a string.- Specified by:
getFloatArrayin interfaceClickHouseBinaryFormatReader- Parameters:
colName- - column name- Returns:
-
getDoubleArray
Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as a string.- Specified by:
getDoubleArrayin interfaceClickHouseBinaryFormatReader- Parameters:
colName- - column name- Returns:
-
getBooleanArray
- Specified by:
getBooleanArrayin interfaceClickHouseBinaryFormatReader- Returns:
-
hasValue
public boolean hasValue(int colIndex) - Specified by:
hasValuein interfaceClickHouseBinaryFormatReader
-
hasValue
- Specified by:
hasValuein interfaceClickHouseBinaryFormatReader
-
getByte
public byte getByte(int index) Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as a byte.- Specified by:
getBytein interfaceClickHouseBinaryFormatReader- Returns:
-
getShort
public short getShort(int index) Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as a short.- Specified by:
getShortin interfaceClickHouseBinaryFormatReader- Returns:
-
getInteger
public int getInteger(int index) Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as an integer.- Specified by:
getIntegerin interfaceClickHouseBinaryFormatReader- Returns:
-
getLong
public long getLong(int index) Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as a long.- Specified by:
getLongin interfaceClickHouseBinaryFormatReader- Returns:
-
getFloat
public float getFloat(int index) Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as a float. Warning: this method may lose precision for float values.- Specified by:
getFloatin interfaceClickHouseBinaryFormatReader- Returns:
-
getDouble
public double getDouble(int index) Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as a double. Warning: this method may lose precision for double values.- Specified by:
getDoublein interfaceClickHouseBinaryFormatReader- Returns:
-
getBoolean
public boolean getBoolean(int index) Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as a boolean.- Specified by:
getBooleanin interfaceClickHouseBinaryFormatReader- Returns:
-
getBigInteger
Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as a BigInteger.- Specified by:
getBigIntegerin interfaceClickHouseBinaryFormatReader- Returns:
-
getBigDecimal
Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as a BigDecimal.- Specified by:
getBigDecimalin interfaceClickHouseBinaryFormatReader- Returns:
-
getInstant
Description copied from interface:ClickHouseBinaryFormatReaderReturns the value of the specified column as an Instant. Timezone is derived from the column definition. If no timezone is specified in the column definition then UTC will be used. If column value is Date or Date32 it will return an Instant with time set to 00:00:00. If column value is DateTime or DateTime32 it will return an Instant with the time part.- Specified by:
getInstantin interfaceClickHouseBinaryFormatReader- Returns:
-
getZonedDateTime
Description copied from interface:ClickHouseBinaryFormatReaderReturns the value of the specified column as a ZonedDateTime. Timezone is derived from the column definition. If no timezone is specified in the column definition then UTC will be used. If column value is Date or Date32 it will return a ZonedDateTime with time set to 00:00:00. If column value is DateTime or DateTime32 it will return a ZonedDateTime with the time part.- Specified by:
getZonedDateTimein interfaceClickHouseBinaryFormatReader- Returns:
-
getDuration
Description copied from interface:ClickHouseBinaryFormatReaderReturns the value of the specified column as a Duration. If a stored value is bigger than Long.MAX_VALUE then exception will be thrown. In such case use asBigInteger() method. If value of IntervalQuarter then Duration will be in the unit of Months.- Specified by:
getDurationin interfaceClickHouseBinaryFormatReader- Returns:
- Duration in the unit of column type.
-
getTemporalAmount
- Specified by:
getTemporalAmountin interfaceClickHouseBinaryFormatReader
-
getInet4Address
Description copied from interface:ClickHouseBinaryFormatReaderReturns the value of the specified column as an Inet4Address.- Specified by:
getInet4Addressin interfaceClickHouseBinaryFormatReader- Returns:
-
getInet6Address
Description copied from interface:ClickHouseBinaryFormatReaderReturns the value of the specified column as an Inet6Address.- Specified by:
getInet6Addressin interfaceClickHouseBinaryFormatReader- Returns:
-
getUUID
Description copied from interface:ClickHouseBinaryFormatReaderReturns the value of the specified column as a UUID.- Specified by:
getUUIDin interfaceClickHouseBinaryFormatReader- Returns:
-
getGeoPoint
Description copied from interface:ClickHouseBinaryFormatReaderReturns the value of the specified column as a ClickHouseGeoPointValue.- Specified by:
getGeoPointin interfaceClickHouseBinaryFormatReader- Returns:
-
getGeoRing
Description copied from interface:ClickHouseBinaryFormatReaderReturns the value of the specified column as a ClickHouseGeoRingValue.- Specified by:
getGeoRingin interfaceClickHouseBinaryFormatReader- Returns:
-
getGeoPolygon
Description copied from interface:ClickHouseBinaryFormatReaderReturns the value of the specified column as a ClickHouseGeoPolygonValue.- Specified by:
getGeoPolygonin interfaceClickHouseBinaryFormatReader- Returns:
-
getGeoMultiPolygon
Description copied from interface:ClickHouseBinaryFormatReaderReturns the value of the specified column as a ClickHouseGeoMultiPolygonValue.- Specified by:
getGeoMultiPolygonin interfaceClickHouseBinaryFormatReader- Returns:
-
getList
Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as a string.- Specified by:
getListin interfaceClickHouseBinaryFormatReader- Parameters:
index- - column name- Returns:
-
getByteArray
public byte[] getByteArray(int index) Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as a string.- Specified by:
getByteArrayin interfaceClickHouseBinaryFormatReader- Parameters:
index- - column name- Returns:
-
getIntArray
public int[] getIntArray(int index) Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as a string.- Specified by:
getIntArrayin interfaceClickHouseBinaryFormatReader- Parameters:
index- - column name- Returns:
-
getLongArray
public long[] getLongArray(int index) Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as a string.- Specified by:
getLongArrayin interfaceClickHouseBinaryFormatReader- Parameters:
index- - column name- Returns:
-
getFloatArray
public float[] getFloatArray(int index) Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as a string.- Specified by:
getFloatArrayin interfaceClickHouseBinaryFormatReader- Parameters:
index- - column name- Returns:
-
getDoubleArray
public double[] getDoubleArray(int index) Description copied from interface:ClickHouseBinaryFormatReaderReads column with name `colName` as a string.- Specified by:
getDoubleArrayin interfaceClickHouseBinaryFormatReader- Parameters:
index- - column name- Returns:
-
getBooleanArray
public boolean[] getBooleanArray(int index) - Specified by:
getBooleanArrayin interfaceClickHouseBinaryFormatReader
-
getTuple
- Specified by:
getTuplein interfaceClickHouseBinaryFormatReader
-
getTuple
- Specified by:
getTuplein interfaceClickHouseBinaryFormatReader
-
getEnum8
- Specified by:
getEnum8in interfaceClickHouseBinaryFormatReader
-
getEnum8
public byte getEnum8(int index) - Specified by:
getEnum8in interfaceClickHouseBinaryFormatReader
-
getEnum16
- Specified by:
getEnum16in interfaceClickHouseBinaryFormatReader
-
getEnum16
public short getEnum16(int index) - Specified by:
getEnum16in interfaceClickHouseBinaryFormatReader
-
getLocalDate
- Specified by:
getLocalDatein interfaceClickHouseBinaryFormatReader
-
getLocalDate
- Specified by:
getLocalDatein interfaceClickHouseBinaryFormatReader
-
getLocalDateTime
- Specified by:
getLocalDateTimein interfaceClickHouseBinaryFormatReader
-
getLocalDateTime
- Specified by:
getLocalDateTimein interfaceClickHouseBinaryFormatReader
-
getOffsetDateTime
- Specified by:
getOffsetDateTimein interfaceClickHouseBinaryFormatReader
-
getOffsetDateTime
- Specified by:
getOffsetDateTimein interfaceClickHouseBinaryFormatReader
-
getClickHouseBitmap
- Specified by:
getClickHouseBitmapin interfaceClickHouseBinaryFormatReader
-
getClickHouseBitmap
- Specified by:
getClickHouseBitmapin interfaceClickHouseBinaryFormatReader
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-