in velox/dwio/dwrf/reader/ColumnReader.cpp [2089:2175]
std::unique_ptr<ColumnReader> ColumnReader::build(
const std::shared_ptr<const dwio::common::TypeWithId>& requestedType,
const std::shared_ptr<const dwio::common::TypeWithId>& dataType,
StripeStreams& stripe,
FlatMapContext flatMapContext) {
CompatChecker::check(*dataType->type, *requestedType->type);
EncodingKey ek{dataType->id, flatMapContext.sequence};
switch (dataType->type->kind()) {
case TypeKind::INTEGER:
return buildIntegerReader(
dataType,
requestedType->type->kind(),
INT_BYTE_SIZE,
std::move(flatMapContext),
stripe);
case TypeKind::BIGINT:
return buildIntegerReader(
dataType,
requestedType->type->kind(),
LONG_BYTE_SIZE,
std::move(flatMapContext),
stripe);
case TypeKind::SMALLINT:
return buildIntegerReader(
dataType,
requestedType->type->kind(),
SHORT_BYTE_SIZE,
std::move(flatMapContext),
stripe);
case TypeKind::VARBINARY:
case TypeKind::VARCHAR:
switch (static_cast<int64_t>(stripe.getEncoding(ek).kind())) {
case proto::ColumnEncoding_Kind_DICTIONARY:
case proto::ColumnEncoding_Kind_DICTIONARY_V2:
return std::make_unique<StringDictionaryColumnReader>(
dataType, stripe, std::move(flatMapContext));
case proto::ColumnEncoding_Kind_DIRECT:
case proto::ColumnEncoding_Kind_DIRECT_V2:
return std::make_unique<StringDirectColumnReader>(
dataType, stripe, std::move(flatMapContext));
default:
DWIO_RAISE("buildReader unhandled string encoding");
}
case TypeKind::BOOLEAN:
return buildByteRleColumnReader<bool>(
dataType,
requestedType->type->kind(),
stripe,
std::move(flatMapContext));
case TypeKind::TINYINT:
return buildByteRleColumnReader<int8_t>(
dataType,
requestedType->type->kind(),
stripe,
std::move(flatMapContext));
case TypeKind::ARRAY:
return std::make_unique<ListColumnReader>(
requestedType, dataType, stripe, std::move(flatMapContext));
case TypeKind::MAP:
if (stripe.getEncoding(ek).kind() ==
proto::ColumnEncoding_Kind_MAP_FLAT) {
return FlatMapColumnReaderFactory::create(
requestedType, dataType, stripe, std::move(flatMapContext));
}
return std::make_unique<MapColumnReader>(
requestedType, dataType, stripe, std::move(flatMapContext));
case TypeKind::ROW:
return std::make_unique<StructColumnReader>(
requestedType, dataType, stripe, std::move(flatMapContext));
case TypeKind::REAL:
if (requestedType->type->kind() == TypeKind::REAL) {
return std::make_unique<FloatingPointColumnReader<float, float>>(
dataType, stripe, std::move(flatMapContext));
} else {
return std::make_unique<FloatingPointColumnReader<float, double>>(
dataType, stripe, std::move(flatMapContext));
}
case TypeKind::DOUBLE:
return std::make_unique<FloatingPointColumnReader<double, double>>(
dataType, stripe, std::move(flatMapContext));
case TypeKind::TIMESTAMP:
return std::make_unique<TimestampColumnReader>(
dataType, stripe, std::move(flatMapContext));
default:
DWIO_RAISE("buildReader unhandled type");
}
}