in flink-connector-hbase-base/src/main/java/org/apache/flink/connector/hbase/util/HBaseSerde.java [455:511]
private static FieldDecoder createFieldDecoder(LogicalType fieldType) {
// ordered by type root definition
switch (fieldType.getTypeRoot()) {
case CHAR:
case VARCHAR:
// reuse bytes
return StringData::fromBytes;
case BOOLEAN:
return Bytes::toBoolean;
case BINARY:
case VARBINARY:
return value -> value;
case DECIMAL:
return createDecimalDecoder((DecimalType) fieldType);
case TINYINT:
return value -> value[0];
case SMALLINT:
return Bytes::toShort;
case INTEGER:
case DATE:
case INTERVAL_YEAR_MONTH:
return Bytes::toInt;
case TIME_WITHOUT_TIME_ZONE:
final int timePrecision = getPrecision(fieldType);
if (timePrecision < MIN_TIME_PRECISION || timePrecision > MAX_TIME_PRECISION) {
throw new UnsupportedOperationException(
String.format(
"The precision %s of TIME type is out of the range [%s, %s] supported by "
+ "HBase connector",
timePrecision, MIN_TIME_PRECISION, MAX_TIME_PRECISION));
}
return Bytes::toInt;
case BIGINT:
case INTERVAL_DAY_TIME:
return Bytes::toLong;
case FLOAT:
return Bytes::toFloat;
case DOUBLE:
return Bytes::toDouble;
case TIMESTAMP_WITHOUT_TIME_ZONE:
case TIMESTAMP_WITH_LOCAL_TIME_ZONE:
final int timestampPrecision = getPrecision(fieldType);
if (timestampPrecision < MIN_TIMESTAMP_PRECISION
|| timestampPrecision > MAX_TIMESTAMP_PRECISION) {
throw new UnsupportedOperationException(
String.format(
"The precision %s of TIMESTAMP type is out of the range [%s, %s] supported by "
+ "HBase connector",
timestampPrecision,
MIN_TIMESTAMP_PRECISION,
MAX_TIMESTAMP_PRECISION));
}
return createTimestampDecoder();
default:
throw new UnsupportedOperationException("Unsupported type: " + fieldType);
}
}