summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/ce/ce_test_utils.h
diff options
context:
space:
mode:
authorMilena Ivanova <milena.ivanova@mongodb.com>2022-09-30 12:08:38 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-09-30 13:04:57 +0000
commit1c4fafd4ae5c082f36a8af1442aa48174962b1b4 (patch)
tree5f06af8c2227d5505daada02ea8746a09e6a89ed /src/mongo/db/query/ce/ce_test_utils.h
parent5b1663a2e449ec0f563e0f9a7f80c0fddb709596 (diff)
downloadmongo-6/0.tar.gz
SERVER-68446 Unit testing of simple histogram CE with all data types6/0
Diffstat (limited to 'src/mongo/db/query/ce/ce_test_utils.h')
-rw-r--r--src/mongo/db/query/ce/ce_test_utils.h20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/mongo/db/query/ce/ce_test_utils.h b/src/mongo/db/query/ce/ce_test_utils.h
index 667a3b70dc3..9e6ebdeb5e8 100644
--- a/src/mongo/db/query/ce/ce_test_utils.h
+++ b/src/mongo/db/query/ce/ce_test_utils.h
@@ -32,6 +32,7 @@
#include <cstddef>
#include <sys/types.h>
+#include "mongo/db/query/ce/histogram_estimation.h"
#include "mongo/db/query/ce/scalar_histogram.h"
#include "mongo/db/query/optimizer/cascades/interfaces.h"
#include "mongo/db/query/optimizer/opt_phase_manager.h"
@@ -71,14 +72,15 @@ const OptPhaseManager::PhaseSet kNoOptPhaseSet{};
* expecting.
*/
-#define _ASSERT_MATCH_CE(ce, predicate, expectedCE) \
- if constexpr (kCETestLogOnly) { \
- if (std::abs(ce.getCE(predicate) - expectedCE) > kMaxCEError) { \
- std::cout << "ERROR: expected " << expectedCE << std::endl; \
- } \
- ASSERT_APPROX_EQUAL(1.0, 1.0, kMaxCEError); \
- } else { \
- ASSERT_APPROX_EQUAL(expectedCE, ce.getCE(predicate), kMaxCEError); \
+#define _ASSERT_MATCH_CE(ce, predicate, expectedCE) \
+ if constexpr (kCETestLogOnly) { \
+ if (std::abs(ce.getCE(predicate) - expectedCE) > kMaxCEError) { \
+ std::cout << "ERROR: cardinality " << ce.getCE(predicate) << " expected " \
+ << expectedCE << std::endl; \
+ } \
+ ASSERT_APPROX_EQUAL(1.0, 1.0, kMaxCEError); \
+ } else { \
+ ASSERT_APPROX_EQUAL(expectedCE, ce.getCE(predicate), kMaxCEError); \
}
#define _PREDICATE(field, predicate) (str::stream() << "{" << field << ": " << predicate "}")
#define _ELEMMATCH_PREDICATE(field, predicate) \
@@ -159,5 +161,7 @@ struct BucketData {
ScalarHistogram createHistogram(const std::vector<BucketData>& data);
+double estimateIntValCard(const ScalarHistogram& hist, int v, EstimationType type);
+
} // namespace ce
} // namespace mongo