in velox/dwio/dwrf/reader/SelectiveColumnReader.cpp [338:435]
std::unique_ptr<SelectiveColumnReader> SelectiveColumnReader::build(
const std::shared_ptr<const TypeWithId>& requestedType,
const std::shared_ptr<const TypeWithId>& dataType,
StripeStreams& stripe,
common::ScanSpec* scanSpec,
FlatMapContext flatMapContext) {
CompatChecker::check(*dataType->type, *requestedType->type);
EncodingKey ek{dataType->id, flatMapContext.sequence};
switch (dataType->type->kind()) {
case TypeKind::INTEGER:
return buildIntegerReader(
requestedType,
std::move(flatMapContext),
dataType,
stripe,
INT_BYTE_SIZE,
scanSpec);
case TypeKind::BIGINT:
return buildIntegerReader(
requestedType,
std::move(flatMapContext),
dataType,
stripe,
LONG_BYTE_SIZE,
scanSpec);
case TypeKind::SMALLINT:
return buildIntegerReader(
requestedType,
std::move(flatMapContext),
dataType,
stripe,
SHORT_BYTE_SIZE,
scanSpec);
case TypeKind::ARRAY:
return std::make_unique<SelectiveListColumnReader>(
requestedType, dataType, stripe, scanSpec, flatMapContext);
case TypeKind::MAP:
if (stripe.getEncoding(ek).kind() ==
proto::ColumnEncoding_Kind_MAP_FLAT) {
VELOX_UNSUPPORTED("SelectiveColumnReader does not support flat maps");
}
return std::make_unique<SelectiveMapColumnReader>(
requestedType, dataType, stripe, scanSpec, std::move(flatMapContext));
case TypeKind::REAL:
if (requestedType->type->kind() == TypeKind::REAL) {
return std::make_unique<
SelectiveFloatingPointColumnReader<float, float>>(
requestedType, stripe, scanSpec, std::move(flatMapContext));
} else {
return std::make_unique<
SelectiveFloatingPointColumnReader<float, double>>(
requestedType, stripe, scanSpec, std::move(flatMapContext));
}
case TypeKind::DOUBLE:
return std::make_unique<
SelectiveFloatingPointColumnReader<double, double>>(
requestedType, stripe, scanSpec, std::move(flatMapContext));
case TypeKind::ROW:
return std::make_unique<SelectiveStructColumnReader>(
requestedType, dataType, stripe, scanSpec, std::move(flatMapContext));
case TypeKind::BOOLEAN:
return std::make_unique<SelectiveByteRleColumnReader>(
requestedType,
dataType,
stripe,
scanSpec,
true,
std::move(flatMapContext));
case TypeKind::TINYINT:
return std::make_unique<SelectiveByteRleColumnReader>(
requestedType,
dataType,
stripe,
scanSpec,
false,
std::move(flatMapContext));
case TypeKind::VARBINARY:
case TypeKind::VARCHAR:
switch (static_cast<int64_t>(stripe.getEncoding(ek).kind())) {
case proto::ColumnEncoding_Kind_DIRECT:
return std::make_unique<SelectiveStringDirectColumnReader>(
requestedType, stripe, scanSpec, std::move(flatMapContext));
case proto::ColumnEncoding_Kind_DICTIONARY:
return std::make_unique<SelectiveStringDictionaryColumnReader>(
requestedType, stripe, scanSpec, std::move(flatMapContext));
default:
DWIO_RAISE("buildReader string unknown encoding");
}
case TypeKind::TIMESTAMP:
return std::make_unique<SelectiveTimestampColumnReader>(
requestedType, stripe, scanSpec, std::move(flatMapContext));
default:
DWIO_RAISE(
"buildReader unhandled type: " +
mapTypeKindToName(dataType->type->kind()));
}
}