Skip to content

Commit

Permalink
Internal duckdb#330: Quantile Performance Review
Browse files Browse the repository at this point in the history
Incorporate Carlo's review (thanks!)
  • Loading branch information
hawkfish committed Oct 30, 2023
1 parent 300e8c0 commit 67f0fd4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/core_functions/aggregate/holistic/quantile.cpp
Expand Up @@ -733,9 +733,13 @@ struct QuantileState {
return qst64->WindowScalar<INPUT_TYPE, RESULT_TYPE, DISCRETE>(data, frames, n, result, q);
} else if (s) {
// Find the position(s) needed
Interpolator<DISCRETE> interp(q, s->size(), false);
s->at(interp.FRN, interp.CRN - interp.FRN + 1, dest);
return interp.template Extract<INPUT_TYPE, RESULT_TYPE>(dest.data(), result);
try {
Interpolator<DISCRETE> interp(q, s->size(), false);
s->at(interp.FRN, interp.CRN - interp.FRN + 1, dest);
return interp.template Extract<INPUT_TYPE, RESULT_TYPE>(dest.data(), result);
} catch (const duckdb_skiplistlib::skip_list::IndexError &idx_err) {
throw InternalException(idx_err.message());
}
} else {
throw InternalException("No accelerator for scalar QUANTILE");
}
Expand Down
3 changes: 2 additions & 1 deletion third_party/skiplist/Node.h
Expand Up @@ -38,6 +38,7 @@
#define SkipList_Node_h

#include "IntegrityEnums.h"
#include <random>

#if __cplusplus < 201103L
#define nullptr NULL
Expand Down Expand Up @@ -129,7 +130,7 @@ class Node {
Node<T, _Compare> *_adjRemoveRefs(size_t level, Node<T, _Compare> *pNode);

void Initialize(const T &value) {
_value = value;
::std::independent_bits_engine<::std::default_random_engine, /*bits*/ 1, int> tossCoin;
_nodeRefs.clear();
do {
_nodeRefs.push_back(this, _nodeRefs.height() ? 0 : 1);
Expand Down
1 change: 1 addition & 0 deletions third_party/skiplist/SkipList.h
Expand Up @@ -446,6 +446,7 @@
#include <vector>
#include <set> // Used for HeadNode::_lacksIntegrityNodeReferencesNotInList()
#include <string> // Used for class Exception
#include <random>

#ifdef DEBUG
#include <cassert>
Expand Down

0 comments on commit 67f0fd4

Please sign in to comment.