Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions velox/dwio/common/SelectiveColumnReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,10 @@ namespace facebook::velox::dwio::common {
// Template parameter to indicate no hook in fast scan path. This is
// referenced in decoders, thus needs to be declared in a header.
struct NoHook : public ValueHook {
std::string toString() const override {
return "NoHook";
}

void addValue(vector_size_t /*row*/, const void* FOLLY_NULLABLE /*value*/)
override {}
};
Expand Down
22 changes: 21 additions & 1 deletion velox/dwio/dwrf/reader/SelectiveLongDecimalColumnReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,27 @@ class SelectiveLongDecimalColumnReader
private:
template <bool dense>
void processValueHook(RowSet rows, ValueHook* hook) {
VELOX_FAIL("TODO: orc long decimal process ValueHook");
switch (hook->kind()) {
case aggregate::AggregationHook::kLongDecimalMax:
readHelper<dense, velox::common::AlwaysTrue>(
&dwio::common::alwaysTrue(),
rows,
dwio::common::ExtractToHook<
aggregate::MinMaxHook<UnscaledLongDecimal, false>>(hook));
break;
case aggregate::AggregationHook::kLongDecimalMin:
readHelper<dense, velox::common::AlwaysTrue>(
&dwio::common::alwaysTrue(),
rows,
dwio::common::ExtractToHook<
aggregate::MinMaxHook<UnscaledLongDecimal, true>>(hook));
break;
default:
readHelper<dense, velox::common::AlwaysTrue>(
&dwio::common::alwaysTrue(),
rows,
dwio::common::ExtractToGenericHook(hook));
}
}

template <bool dense, typename ExtractValues>
Expand Down
22 changes: 21 additions & 1 deletion velox/dwio/dwrf/reader/SelectiveShortDecimalColumnReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,27 @@ class SelectiveShortDecimalColumnReader
private:
template <bool dense>
void processValueHook(RowSet rows, ValueHook* hook) {
VELOX_FAIL("TODO: orc short decimal process ValueHook");
switch (hook->kind()) {
case aggregate::AggregationHook::kShortDecimalMax:
readHelper<dense, velox::common::AlwaysTrue>(
&dwio::common::alwaysTrue(),
rows,
dwio::common::ExtractToHook<
aggregate::MinMaxHook<UnscaledShortDecimal, false>>(hook));
break;
case aggregate::AggregationHook::kShortDecimalMin:
readHelper<dense, velox::common::AlwaysTrue>(
&dwio::common::alwaysTrue(),
rows,
dwio::common::ExtractToHook<
aggregate::MinMaxHook<UnscaledShortDecimal, true>>(hook));
break;
default:
readHelper<dense, velox::common::AlwaysTrue>(
&dwio::common::alwaysTrue(),
rows,
dwio::common::ExtractToGenericHook(hook));
}
}

template <bool dense, typename ExtractValues>
Expand Down
56 changes: 56 additions & 0 deletions velox/exec/AggregationHook.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class AggregationHook : public ValueHook {
static constexpr Kind kFloatMin = 8;
static constexpr Kind kDoubleMax = 9;
static constexpr Kind kDoubleMin = 10;
static constexpr Kind kShortDecimalMax = 11;
static constexpr Kind kShortDecimalMin = 12;
static constexpr Kind kLongDecimalMax = 13;
static constexpr Kind kLongDecimalMin = 14;

// Make null behavior known at compile time. This is useful when
// templating a column decoding loop with a hook.
Expand All @@ -53,6 +57,12 @@ class AggregationHook : public ValueHook {
groups_(groups),
numNulls_(numNulls) {}

std::string toString() const override {
char buf[256];
sprintf(buf, "AggregationHook kind:%d", (int)kind());
return buf;
}

bool acceptsNulls() const override final {
return false;
}
Expand Down Expand Up @@ -119,6 +129,17 @@ class SumHook final : public AggregationHook {
uint64_t* numNulls)
: AggregationHook(offset, nullByte, nullMask, groups, numNulls) {}

std::string toString() const override {
char buf[256];
sprintf(
buf,
"SumHook kind:%d TValue:%s TAggregate:%s",
(int)kind(),
typeid(TValue).name(),
typeid(TAggregate).name());
return buf;
}

Kind kind() const override {
if (std::is_same_v<TAggregate, double>) {
if (std::is_same_v<TValue, double>) {
Expand Down Expand Up @@ -160,6 +181,18 @@ class SimpleCallableHook final : public AggregationHook {
: AggregationHook(offset, nullByte, nullMask, groups, numNulls),
updateSingleValue_(updateSingleValue) {}

std::string toString() const override {
char buf[256];
sprintf(
buf,
"SimpleCallableHook kind:%d TValue:%s TAggregate:%s UpdateSingleValue:%s",
(int)kind(),
typeid(TValue).name(),
typeid(TAggregate).name(),
typeid(UpdateSingleValue).name());
return buf;
}

Kind kind() const override {
return kGeneric;
}
Expand Down Expand Up @@ -187,6 +220,17 @@ class MinMaxHook final : public AggregationHook {
uint64_t* numNulls)
: AggregationHook(offset, nullByte, nullMask, groups, numNulls) {}

std::string toString() const override {
char buf[256];
sprintf(
buf,
"MinMaxHook kind:%d T:%s isMin:%d",
(int)kind(),
typeid(T).name(),
(int)isMin);
return buf;
}

Kind kind() const override {
if (isMin) {
if (std::is_same_v<T, int64_t>) {
Expand All @@ -198,6 +242,12 @@ class MinMaxHook final : public AggregationHook {
if (std::is_same_v<T, double>) {
return kDoubleMin;
}
if (std::is_same_v<T, UnscaledShortDecimal>) {
return kShortDecimalMin;
}
if (std::is_same_v<T, UnscaledLongDecimal>) {
return kLongDecimalMin;
}
} else {
if (std::is_same_v<T, int64_t>) {
return kBigintMax;
Expand All @@ -208,6 +258,12 @@ class MinMaxHook final : public AggregationHook {
if (std::is_same_v<T, double>) {
return kDoubleMax;
}
if (std::is_same_v<T, UnscaledShortDecimal>) {
return kShortDecimalMax;
}
if (std::is_same_v<T, UnscaledLongDecimal>) {
return kLongDecimalMax;
}
}
return kGeneric;
}
Expand Down
4 changes: 4 additions & 0 deletions velox/vector/LazyVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ class ValueHook {

virtual ~ValueHook() = default;

virtual std::string toString() const {
return "ValueHook";
}

virtual bool acceptsNulls() const {
return false;
}
Expand Down