Skip to content

Commit 1f91b30

Browse files
author
zuochunwei
committed
xx
1 parent aa23aca commit 1f91b30

File tree

5 files changed

+110
-2
lines changed

5 files changed

+110
-2
lines changed

velox/dwio/common/SelectiveColumnReader.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,10 @@ namespace facebook::velox::dwio::common {
631631
// Template parameter to indicate no hook in fast scan path. This is
632632
// referenced in decoders, thus needs to be declared in a header.
633633
struct NoHook : public ValueHook {
634+
std::string toString() const override {
635+
return "NoHook";
636+
}
637+
634638
void addValue(vector_size_t /*row*/, const void* FOLLY_NULLABLE /*value*/)
635639
override {}
636640
};

velox/dwio/dwrf/reader/SelectiveLongDecimalColumnReader.h

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,29 @@ class SelectiveLongDecimalColumnReader
115115
private:
116116
template <bool dense>
117117
void processValueHook(RowSet rows, ValueHook* hook) {
118-
VELOX_FAIL("TODO: orc long decimal process ValueHook");
118+
// std::cout << "long decimal hook: %s" << hook->toString() << std::endl;
119+
120+
switch (hook->kind()) {
121+
case aggregate::AggregationHook::kLongDecimalMax:
122+
readHelper<dense, velox::common::AlwaysTrue>(
123+
&dwio::common::alwaysTrue(),
124+
rows,
125+
dwio::common::ExtractToHook<
126+
aggregate::MinMaxHook<UnscaledLongDecimal, false>>(hook));
127+
break;
128+
case aggregate::AggregationHook::kLongDecimalMin:
129+
readHelper<dense, velox::common::AlwaysTrue>(
130+
&dwio::common::alwaysTrue(),
131+
rows,
132+
dwio::common::ExtractToHook<
133+
aggregate::MinMaxHook<UnscaledLongDecimal, true>>(hook));
134+
break;
135+
default:
136+
readHelper<dense, velox::common::AlwaysTrue>(
137+
&dwio::common::alwaysTrue(),
138+
rows,
139+
dwio::common::ExtractToGenericHook(hook));
140+
}
119141
}
120142

121143
template <bool dense, typename ExtractValues>

velox/dwio/dwrf/reader/SelectiveShortDecimalColumnReader.h

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,29 @@ class SelectiveShortDecimalColumnReader
121121
private:
122122
template <bool dense>
123123
void processValueHook(RowSet rows, ValueHook* hook) {
124-
VELOX_FAIL("TODO: orc short decimal process ValueHook");
124+
// std::cout << "short decimal hook: %s" << hook->toString() << std::endl;
125+
126+
switch (hook->kind()) {
127+
case aggregate::AggregationHook::kShortDecimalMax:
128+
readHelper<dense, velox::common::AlwaysTrue>(
129+
&dwio::common::alwaysTrue(),
130+
rows,
131+
dwio::common::ExtractToHook<
132+
aggregate::MinMaxHook<UnscaledShortDecimal, false>>(hook));
133+
break;
134+
case aggregate::AggregationHook::kShortDecimalMin:
135+
readHelper<dense, velox::common::AlwaysTrue>(
136+
&dwio::common::alwaysTrue(),
137+
rows,
138+
dwio::common::ExtractToHook<
139+
aggregate::MinMaxHook<UnscaledShortDecimal, true>>(hook));
140+
break;
141+
default:
142+
readHelper<dense, velox::common::AlwaysTrue>(
143+
&dwio::common::alwaysTrue(),
144+
rows,
145+
dwio::common::ExtractToGenericHook(hook));
146+
}
125147
}
126148

127149
template <bool dense, typename ExtractValues>

velox/exec/AggregationHook.h

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ class AggregationHook : public ValueHook {
3535
static constexpr Kind kFloatMin = 8;
3636
static constexpr Kind kDoubleMax = 9;
3737
static constexpr Kind kDoubleMin = 10;
38+
static constexpr Kind kShortDecimalMax = 11;
39+
static constexpr Kind kShortDecimalMin = 12;
40+
static constexpr Kind kLongDecimalMax = 13;
41+
static constexpr Kind kLongDecimalMin = 14;
3842

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

60+
std::string toString() const override {
61+
char buf[256];
62+
sprintf(buf, "AggregationHook kind:%d", (int)kind());
63+
return buf;
64+
}
65+
5666
bool acceptsNulls() const override final {
5767
return false;
5868
}
@@ -119,6 +129,17 @@ class SumHook final : public AggregationHook {
119129
uint64_t* numNulls)
120130
: AggregationHook(offset, nullByte, nullMask, groups, numNulls) {}
121131

132+
std::string toString() const override {
133+
char buf[256];
134+
sprintf(
135+
buf,
136+
"SumHook kind:%d TValue:%s TAggregate:%s",
137+
(int)kind(),
138+
typeid(TValue).name(),
139+
typeid(TAggregate).name());
140+
return buf;
141+
}
142+
122143
Kind kind() const override {
123144
if (std::is_same_v<TAggregate, double>) {
124145
if (std::is_same_v<TValue, double>) {
@@ -160,6 +181,18 @@ class SimpleCallableHook final : public AggregationHook {
160181
: AggregationHook(offset, nullByte, nullMask, groups, numNulls),
161182
updateSingleValue_(updateSingleValue) {}
162183

184+
std::string toString() const override {
185+
char buf[256];
186+
sprintf(
187+
buf,
188+
"SimpleCallableHook kind:%d TValue:%s TAggregate:%s UpdateSingleValue:%s",
189+
(int)kind(),
190+
typeid(TValue).name(),
191+
typeid(TAggregate).name(),
192+
typeid(UpdateSingleValue).name());
193+
return buf;
194+
}
195+
163196
Kind kind() const override {
164197
return kGeneric;
165198
}
@@ -187,6 +220,17 @@ class MinMaxHook final : public AggregationHook {
187220
uint64_t* numNulls)
188221
: AggregationHook(offset, nullByte, nullMask, groups, numNulls) {}
189222

223+
std::string toString() const override {
224+
char buf[256];
225+
sprintf(
226+
buf,
227+
"MinMaxHook kind:%d T:%s isMin:%d",
228+
(int)kind(),
229+
typeid(T).name(),
230+
(int)isMin);
231+
return buf;
232+
}
233+
190234
Kind kind() const override {
191235
if (isMin) {
192236
if (std::is_same_v<T, int64_t>) {
@@ -198,6 +242,12 @@ class MinMaxHook final : public AggregationHook {
198242
if (std::is_same_v<T, double>) {
199243
return kDoubleMin;
200244
}
245+
if (std::is_same_v<T, UnscaledShortDecimal>) {
246+
return kShortDecimalMin;
247+
}
248+
if (std::is_same_v<T, UnscaledLongDecimal>) {
249+
return kLongDecimalMin;
250+
}
201251
} else {
202252
if (std::is_same_v<T, int64_t>) {
203253
return kBigintMax;
@@ -208,6 +258,12 @@ class MinMaxHook final : public AggregationHook {
208258
if (std::is_same_v<T, double>) {
209259
return kDoubleMax;
210260
}
261+
if (std::is_same_v<T, UnscaledShortDecimal>) {
262+
return kShortDecimalMax;
263+
}
264+
if (std::is_same_v<T, UnscaledLongDecimal>) {
265+
return kLongDecimalMax;
266+
}
211267
}
212268
return kGeneric;
213269
}

velox/vector/LazyVector.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ class ValueHook {
4545

4646
virtual ~ValueHook() = default;
4747

48+
virtual std::string toString() const {
49+
return "ValueHook";
50+
}
51+
4852
virtual bool acceptsNulls() const {
4953
return false;
5054
}

0 commit comments

Comments
 (0)