Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Commit e0abac4

Browse files
committed
Fix review comments.
Signed-off-by: ienkovich <[email protected]>
1 parent 1e39f96 commit e0abac4

File tree

4 files changed

+30
-25
lines changed

4 files changed

+30
-25
lines changed

omniscidb/QueryEngine/CgenState.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ void CgenState::maybeCloneFunctionRecursive(llvm::Function* fn, bool is_l0) {
201201
if (llvm::isa<llvm::CallInst>(*it)) {
202202
auto& call = llvm::cast<llvm::CallInst>(*it);
203203
// Ignore indirect calls (e.g. virtual function calls).
204-
if (call.getCalledFunction()) {
204+
if (!call.isIndirectCall()) {
205205
maybeCloneFunctionRecursive(call.getCalledFunction(), is_l0);
206206
}
207207
}

omniscidb/QueryEngine/GroupByRuntime.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -412,17 +412,17 @@ DEF_AGG_TOPK_ALL(double, double)
412412
#undef DEF_AGG_TOPK_SKIP_VAL
413413
#undef DEF_AGG_TOPK
414414

415-
#define DEF_AGG_QUANTILE(val_type, suffix) \
416-
extern "C" RUNTIME_EXPORT DEVICE void agg_quantile_impl_##suffix(int64_t* agg, \
417-
val_type val); \
418-
extern "C" RUNTIME_EXPORT ALWAYS_INLINE DEVICE void agg_quantile_##suffix( \
419-
int64_t* agg, val_type val) { \
420-
agg_quantile_impl_##suffix(agg, val); \
415+
#define DEF_AGG_QUANTILE(val_type, suffix) \
416+
extern "C" RUNTIME_EXPORT DEVICE void agg_quantile_impl_##suffix( \
417+
GENERIC_ADDR_SPACE int64_t* agg, val_type val); \
418+
extern "C" RUNTIME_EXPORT ALWAYS_INLINE DEVICE void agg_quantile_##suffix( \
419+
GENERIC_ADDR_SPACE int64_t* agg, val_type val) { \
420+
agg_quantile_impl_##suffix(agg, val); \
421421
}
422422

423423
#define DEF_AGG_QUANTILE_SKIP_VAL(val_type, suffix) \
424424
extern "C" RUNTIME_EXPORT ALWAYS_INLINE DEVICE void agg_quantile_##suffix##_skip_val( \
425-
int64_t* agg, val_type val, val_type skip_val) { \
425+
GENERIC_ADDR_SPACE int64_t* agg, val_type val, val_type skip_val) { \
426426
if (val != skip_val) { \
427427
agg_quantile_##suffix(agg, val); \
428428
} \

omniscidb/QueryEngine/RowFuncBuilder.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -815,8 +815,9 @@ llvm::Value* RowFuncBuilder::convertNullIfAny(const hdk::ir::Type* arg_type,
815815
CHECK(agg_info.agg_kind == hdk::ir::AggType::kTopK);
816816
agg_type = agg_type->as<hdk::ir::ArrayBaseType>()->elemType();
817817
} else if (agg_info.agg_kind == hdk::ir::AggType::kQuantile) {
818-
// Quantile collects orginal values and we don't care about the
819-
// result type at the moment.
818+
// Quantile aggregate slot doesn't hold the result but holds a pointer to the object
819+
// that collects orginal values. The result type is used on aggregate finalization
820+
// only and aggregate collection works with an argument type only.
820821
agg_type = arg_type;
821822
}
822823
const size_t chosen_bytes = agg_type->size();

omniscidb/Shared/quantile.h

+19-15
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ class ChunkedArray {
2424
public:
2525
struct Chunk {
2626
int8_t* data;
27-
// Size holds number of elements, not bytes. Element size
28-
// is determined on push.
29-
size_t size;
27+
// Max number of elements that can be stored in a chunk. Element type is determined on
28+
// push when chunk is allocated. Elements of different types shouldn't be pushed into
29+
// the same chunk.
30+
size_t max_elems;
3031
};
3132

3233
// Random access iterator to be used with std::nth_element.
@@ -49,15 +50,16 @@ class ChunkedArray {
4950
if (chunk_idx_ == other.chunk_idx_) {
5051
return chunk_offs_ - other.chunk_offs_;
5152
} else if (chunk_idx_ > other.chunk_idx_) {
52-
auto res = (*chunks_)[other.chunk_idx_].size - other.chunk_offs_ + chunk_offs_;
53+
auto res =
54+
(*chunks_)[other.chunk_idx_].max_elems - other.chunk_offs_ + chunk_offs_;
5355
for (auto i = other.chunk_idx_ + 1; i < chunk_idx_; ++i) {
54-
res += (*chunks_)[i].size;
56+
res += (*chunks_)[i].max_elems;
5557
}
5658
return (int64_t)res;
5759
} else {
58-
auto res = (*chunks_)[chunk_idx_].size - chunk_offs_ + other.chunk_offs_;
60+
auto res = (*chunks_)[chunk_idx_].max_elems - chunk_offs_ + other.chunk_offs_;
5961
for (auto i = chunk_idx_ + 1; i < other.chunk_idx_; ++i) {
60-
res += (*chunks_)[i].size;
62+
res += (*chunks_)[i].max_elems;
6163
}
6264
return -(int64_t)res;
6365
}
@@ -68,7 +70,7 @@ class ChunkedArray {
6870
operator-=(-i);
6971
} else {
7072
while (true) {
71-
int64_t rem = int64_t((*chunks_)[chunk_idx_].size - chunk_offs_);
73+
int64_t rem = int64_t((*chunks_)[chunk_idx_].max_elems - chunk_offs_);
7274
if (rem > i) {
7375
chunk_offs_ += i;
7476
break;
@@ -95,7 +97,7 @@ class ChunkedArray {
9597
while ((int64_t)chunk_offs_ < i) {
9698
--chunk_idx_;
9799
i -= chunk_offs_;
98-
chunk_offs_ = (*chunks_)[chunk_idx_].size;
100+
chunk_offs_ = (*chunks_)[chunk_idx_].max_elems;
99101
}
100102
chunk_offs_ -= i;
101103
}
@@ -110,7 +112,7 @@ class ChunkedArray {
110112

111113
Iterator& operator++() {
112114
++chunk_offs_;
113-
if (chunk_offs_ == (*chunks_)[chunk_idx_].size) {
115+
if (chunk_offs_ == (*chunks_)[chunk_idx_].max_elems) {
114116
++chunk_idx_;
115117
chunk_offs_ = 0;
116118
}
@@ -126,7 +128,7 @@ class ChunkedArray {
126128
Iterator& operator--() {
127129
if (!chunk_offs_) {
128130
--chunk_idx_;
129-
chunk_offs_ = (*chunks_)[chunk_idx_].size;
131+
chunk_offs_ = (*chunks_)[chunk_idx_].max_elems;
130132
}
131133
--chunk_offs_;
132134
return *this;
@@ -177,7 +179,7 @@ class ChunkedArray {
177179
template <typename T>
178180
void push(T value) {
179181
// Check if we need to allocate a new chunk.
180-
if (chunks_.empty() || cur_idx_ == chunks_.back().size) {
182+
if (chunks_.empty() || cur_idx_ == chunks_.back().max_elems) {
181183
// Allocator is most probably a RowSetMemoryOwner object. It is not supposed to be
182184
// used to allocate very small objects, so we start with 1 KB and double it each
183185
// time with 64KB limit.
@@ -195,7 +197,7 @@ class ChunkedArray {
195197
// We are not going to add values to the current last chunk anymore, so fix-up
196198
// its size for proper iteration.
197199
if (!chunks_.empty()) {
198-
chunks_.back().size = cur_idx_;
200+
chunks_.back().max_elems = cur_idx_;
199201
}
200202
chunks_.insert(chunks_.end(), other.chunks_.begin(), other.chunks_.end());
201203
cur_idx_ = other.cur_idx_;
@@ -212,7 +214,7 @@ class ChunkedArray {
212214
// Chunk offset in iterator is always expected to be less than chunk size. So, end
213215
// iterator for a full chunk is supposed to point the start of the next chunk.
214216
// Take care of it if all chunks are full.
215-
if (!chunks_.empty() && cur_idx_ == chunks_.back().size) {
217+
if (!chunks_.empty() && cur_idx_ == chunks_.back().max_elems) {
216218
return Iterator<T>(&chunks_, chunks_.size(), 0);
217219
}
218220
return Iterator<T>(&chunks_, chunks_.size() - 1, cur_idx_);
@@ -227,7 +229,7 @@ class ChunkedArray {
227229

228230
size_t res = cur_idx_;
229231
for (size_t i = 0; i < chunks_.size() - 1; ++i) {
230-
res += chunks_[i].size;
232+
res += chunks_[i].max_elems;
231233
}
232234
return res;
233235
}
@@ -236,6 +238,8 @@ class ChunkedArray {
236238

237239
private:
238240
SimpleAllocator* allocator_;
241+
// All chunks except the last one should be full, i.e. they hold
242+
// chunk.max_elems elements.
239243
std::vector<Chunk> chunks_;
240244
// Insertion position in the last chunk.
241245
size_t cur_idx_;

0 commit comments

Comments
 (0)