1616 * specific language governing permissions and limitations
1717 * under the License.
1818 */
19- // #include <iostream>
20- //
21- // #include <catch2/catch.hpp>
22- //
23- // #include "collapsing_highest_dense_store.hpp"
24- // #include "collapsing_lowest_dense_store.hpp"
25- // #include "dense_store.hpp"
26- // #include "index_mapping.hpp"
27- // #include "sparse_store.hpp"
28- // #include "unbounded_size_dense_store.hpp"
29- // #include"ddsketch.hpp"
30- // #include "logarithmic_mapping.hpp"
31- // #include "linearly_interpolated_mapping.hpp"
32-
33- // #include <catch2/catch.hpp>
34- // #include <vector>
35- // #include <random>
36- // #include <algorithm>
37- // #include <cmath>
38- // #include <stdexcept>
39- //
40- // #include "ddsketch.hpp"
41- // #include "index_mapping.hpp"
42- // #include "logarithmic_mapping.hpp"
43- // #include "linearly_interpolated_mapping.hpp"
44- // #include "quadratically_interpolated_mapping.hpp"
45- // #include "quartically_interpolated_mapping.hpp"
46- // #include "unbounded_size_dense_store.hpp"
47- // #include "collapsing_highest_dense_store.hpp"
48- // #include "collapsing_lowest_dense_store.hpp"
49- // #include "sparse_store.hpp"
50- // namespace datasketches {
51- // using A = std::allocator<double>;
52- // TEST_CASE("ddsketch", "[ddsketch]") {
53- // std::cout << "ddsketch test" << std::endl;
54- //
55- // CollapsingHighestDenseStore<std::allocator<uint64_t>> store_hi(1024);
56- // store_hi.merge(store_hi);
57- //
58- // CollapsingLowestDenseStore<std::allocator<uint64_t>> store_lo(1024);
59- // store_lo.merge(store_lo);
60- //
61- // store_hi.merge(store_lo);
62- // store_lo.merge(store_hi);
63- //
64- // store_lo.add(1, 1);
65- // store_lo.add(12, 2);
66- // store_lo.add(23, 3);
67- //
68- // // std::cout << "ciao" << std::endl;
69- // // store_hi.merge(store_lo);
70- // // for (const Bin& bin : store_hi) {
71- // // std::cout << bin.toString() << std::endl;
72- // // }
73- //
74- // // UnboundedSizeDenseStore<std::allocator<uint64_t>> unbounded_store;
75- // // unbounded_store.add(34, 4);
76- // // unbounded_store.merge(unbounded_store);
77- // //
78- // // store_lo.merge(unbounded_store);
79- // // unbounded_store.merge(store_lo);
80- // //
81- // // store_hi.merge(unbounded_store);
82- // // unbounded_store.merge(store_hi);
83- // // SparseStore<std::allocator<double>> ss;
84- // }
85- //
86- // template<store_concept Store, class Mapping>
87- // void test_adding(DDSketch<Store, Mapping>& sketch, const double& values...) {
88- //
89- // }
90- //
91- // TEST_CASE("test empty", "[ddsketch]") {
92- // LogarithmicMapping mapping(0.01);
93- // DDSketch<UnboundedSizeDenseStore<A>, decltype(mapping)> sketch(mapping);
94- //
95- // sketch.update(20.0, 2);
96- // sketch.update(10.0);
97- // LinearlyInterpolatedMapping linear(0.01);
98- // DDSketch<UnboundedSizeDenseStore<A>, decltype(mapping)> sketch2(mapping);
99- // sketch2.update(10.0);
100- //
101- // sketch2.update(20.0, 2);
102- //
103- // }
104-
105- /*
106- * Licensed to the Apache Software Foundation (ASF) under one
107- * or more contributor license agreements. See the NOTICE file
108- * distributed with this work for additional information
109- * regarding copyright ownership. The ASF licenses this file
110- * to you under the Apache License, Version 2.0 (the
111- * "License"); you may not use this file except in compliance
112- * with the License. You may obtain a copy of the License at
113- *
114- * http://www.apache.org/licenses/LICENSE-2.0
115- *
116- * Unless required by applicable law or agreed to in writing,
117- * software distributed under the License is distributed on an
118- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
119- * KIND, either express or implied. See the License for the
120- * specific language governing permissions and limitations
121- * under the License.
122- */
12319
12420#include < catch2/catch.hpp>
12521#include < vector>
@@ -239,13 +135,20 @@ void test_merging(SketchType& sketch, const std::vector<std::vector<double>>& va
239135 assert_encodes (sketch, all_values, relative_accuracy);
240136}
241137
242- // Test Cases
138+ using DDSketchUnboundedStoreTestCase = std::pair<store_factory<UnboundedSizeDenseStore<A>>, LogarithmicMapping>;
243139
140+ template <int N>
141+ using DDSketchCollapsingHighestStoreTestCase = std::pair<store_factory<CollapsingHighestDenseStore<A>, N>, LogarithmicMapping>;
142+
143+ template <int N>
144+ using DDSketchCollapsingLowestStoreTestCase = std::pair<store_factory<CollapsingLowestDenseStore<A>, N>, LogarithmicMapping>;
145+
146+ using DDSketchSparseStoreTestCase = std::pair<store_factory<SparseStore<A>>, LogarithmicMapping>;
244147TEMPLATE_TEST_CASE (" DDSketch empty test" , " [ddsketch]" ,
245- (std::pair<store_factory<UnboundedSizeDenseStore<A>>, LogarithmicMapping>) ,
246- (std::pair<store_factory<CollapsingHighestDenseStore<A>, 128 >, LogarithmicMapping>) ,
247- (std::pair<store_factory<CollapsingLowestDenseStore<A>, 128 >, LogarithmicMapping>) ,
248- (std::pair<store_factory<SparseStore<A>>, LogarithmicMapping>)
148+ DDSketchUnboundedStoreTestCase ,
149+ DDSketchCollapsingHighestStoreTestCase< 128 >,
150+ DDSketchCollapsingLowestStoreTestCase< 128 >,
151+ DDSketchSparseStoreTestCase
249152) {
250153 auto positive_store = *TestType::first_type::new_store ();
251154 auto negative_store = *TestType::first_type::new_store ();
@@ -263,10 +166,10 @@ TEMPLATE_TEST_CASE("DDSketch empty test", "[ddsketch]",
263166}
264167
265168TEMPLATE_TEST_CASE (" DDSketch exception test" , " [ddsketch]" ,
266- (std::pair<store_factory<UnboundedSizeDenseStore<A>>, LogarithmicMapping>) ,
267- (std::pair<store_factory<CollapsingHighestDenseStore<A>, 128 >, LogarithmicMapping>) ,
268- (std::pair<store_factory<CollapsingLowestDenseStore<A>, 128 >, LogarithmicMapping>) ,
269- (std::pair<store_factory<SparseStore<A>>, LogarithmicMapping>)
169+ DDSketchUnboundedStoreTestCase ,
170+ DDSketchCollapsingHighestStoreTestCase< 128 >,
171+ DDSketchCollapsingLowestStoreTestCase< 128 >,
172+ DDSketchSparseStoreTestCase
270173) {
271174 auto positive_store = *TestType::first_type::new_store ();
272175 auto negative_store = *TestType::first_type::new_store ();
@@ -285,10 +188,10 @@ TEMPLATE_TEST_CASE("DDSketch exception test", "[ddsketch]",
285188}
286189
287190TEMPLATE_TEST_CASE (" DDSketch clear test" , " [ddsketch]" ,
288- (std::pair<store_factory<UnboundedSizeDenseStore<A>>, LogarithmicMapping>) ,
289- (std::pair<store_factory<CollapsingHighestDenseStore<A>, 128 >, LogarithmicMapping>) ,
290- (std::pair<store_factory<CollapsingLowestDenseStore<A>, 128 >, LogarithmicMapping>) ,
291- (std::pair<store_factory<SparseStore<A>>, LogarithmicMapping>)
191+ DDSketchUnboundedStoreTestCase ,
192+ DDSketchCollapsingHighestStoreTestCase< 128 >,
193+ DDSketchCollapsingLowestStoreTestCase< 128 >,
194+ DDSketchSparseStoreTestCase
292195) {
293196 auto positive_store = *TestType::first_type::new_store ();
294197 auto negative_store = *TestType::first_type::new_store ();
@@ -306,10 +209,10 @@ TEMPLATE_TEST_CASE("DDSketch clear test", "[ddsketch]",
306209}
307210
308211TEMPLATE_TEST_CASE (" DDSketch constant test" , " [ddsketch]" ,
309- (std::pair<store_factory<UnboundedSizeDenseStore<A>>, LogarithmicMapping>) ,
310- (std::pair<store_factory<CollapsingHighestDenseStore<A>, 128 >, LogarithmicMapping>) ,
311- (std::pair<store_factory<CollapsingLowestDenseStore<A>, 128 >, LogarithmicMapping>) ,
312- (std::pair<store_factory<SparseStore<A>>, LogarithmicMapping>)
212+ DDSketchUnboundedStoreTestCase ,
213+ DDSketchCollapsingHighestStoreTestCase< 128 >,
214+ DDSketchCollapsingLowestStoreTestCase< 128 >,
215+ DDSketchSparseStoreTestCase
313216){
314217 auto positive_store = *TestType::first_type::new_store ();
315218 auto negative_store = *TestType::first_type::new_store ();
@@ -329,10 +232,10 @@ TEMPLATE_TEST_CASE("DDSketch constant test", "[ddsketch]",
329232}
330233
331234TEMPLATE_TEST_CASE (" DDSketch negative constants test" , " [ddsketch]" ,
332- (std::pair<store_factory<UnboundedSizeDenseStore<A>>, LogarithmicMapping>) ,
333- (std::pair<store_factory<CollapsingHighestDenseStore<A>, 128 >, LogarithmicMapping>) ,
334- (std::pair<store_factory<CollapsingLowestDenseStore<A>, 128 >, LogarithmicMapping>) ,
335- (std::pair<store_factory<SparseStore<A>>, LogarithmicMapping>)
235+ DDSketchUnboundedStoreTestCase ,
236+ DDSketchCollapsingHighestStoreTestCase< 128 >,
237+ DDSketchCollapsingLowestStoreTestCase< 128 >,
238+ DDSketchSparseStoreTestCase
336239) {
337240 auto positive_store = *TestType::first_type::new_store ();
338241 auto negative_store = *TestType::first_type::new_store ();
@@ -352,10 +255,10 @@ TEMPLATE_TEST_CASE("DDSketch negative constants test", "[ddsketch]",
352255 }
353256}
354257TEMPLATE_TEST_CASE (" DDSketch mixed positive negative test" , " [ddsketch]" ,
355- (std::pair<store_factory<UnboundedSizeDenseStore<A>>, LogarithmicMapping>) ,
356- (std::pair<store_factory<CollapsingHighestDenseStore<A>, 128 >, LogarithmicMapping>) ,
357- (std::pair<store_factory<CollapsingLowestDenseStore<A>, 128 >, LogarithmicMapping>) ,
358- (std::pair<store_factory<SparseStore<A>>, LogarithmicMapping>)
258+ DDSketchUnboundedStoreTestCase ,
259+ DDSketchCollapsingHighestStoreTestCase< 128 >,
260+ DDSketchCollapsingLowestStoreTestCase< 128 >,
261+ DDSketchSparseStoreTestCase
359262) {
360263 auto positive_store = *TestType::first_type::new_store ();
361264 auto negative_store = *TestType::first_type::new_store ();
@@ -380,10 +283,10 @@ TEMPLATE_TEST_CASE("DDSketch mixed positive negative test", "[ddsketch]",
380283 }
381284}
382285TEMPLATE_TEST_CASE (" DDSketch with zeros test" , " [ddsketch]" ,
383- (std::pair<store_factory<UnboundedSizeDenseStore<A>>, LogarithmicMapping>) ,
384- (std::pair<store_factory<CollapsingHighestDenseStore<A>, 4096 >, LogarithmicMapping>) ,
286+ DDSketchUnboundedStoreTestCase ,
287+ DDSketchCollapsingHighestStoreTestCase< 4096 >,
385288 (std::pair<store_factory<CollapsingLowestDenseStore<A>, 4096 >, LogarithmicMapping>),
386- (std::pair<store_factory<SparseStore<A>>, LogarithmicMapping>)
289+ DDSketchSparseStoreTestCase
387290) {
388291 auto positive_store = *TestType::first_type::new_store ();
389292 auto negative_store = *TestType::first_type::new_store ();
@@ -414,8 +317,8 @@ TEMPLATE_TEST_CASE("DDSketch with zeros test", "[ddsketch]",
414317}
415318
416319TEMPLATE_TEST_CASE (" DDSketch linear sequences test" , " [ddsketch]" ,
417- (std::pair<store_factory<UnboundedSizeDenseStore<A>>, LogarithmicMapping>) ,
418- (std::pair<store_factory<SparseStore<A>>, LogarithmicMapping>)
320+ DDSketchUnboundedStoreTestCase ,
321+ DDSketchSparseStoreTestCase
419322) {
420323 auto positive_store = *TestType::first_type::new_store ();
421324 auto negative_store = *TestType::first_type::new_store ();
@@ -458,8 +361,8 @@ TEMPLATE_TEST_CASE("DDSketch linear sequences test", "[ddsketch]",
458361}
459362
460363TEMPLATE_TEST_CASE (" DDSketch exponential sequence test" , " [ddsketch]" ,
461- (std::pair<store_factory<UnboundedSizeDenseStore<A>>, LogarithmicMapping>) ,
462- (std::pair<store_factory<SparseStore<A>>, LogarithmicMapping>)
364+ DDSketchUnboundedStoreTestCase ,
365+ DDSketchSparseStoreTestCase
463366) {
464367 auto positive_store = *TestType::first_type::new_store ();
465368 auto negative_store = *TestType::first_type::new_store ();
@@ -495,10 +398,10 @@ TEMPLATE_TEST_CASE("DDSketch exponential sequence test", "[ddsketch]",
495398}
496399
497400TEMPLATE_TEST_CASE (" DDSketch merging test" , " [ddsketch]" ,
498- (std::pair<store_factory<UnboundedSizeDenseStore<A>>, LogarithmicMapping>) ,
499- (std::pair<store_factory<CollapsingHighestDenseStore<A>, 4096 >, LogarithmicMapping>) ,
500- (std::pair<store_factory<CollapsingLowestDenseStore<A>, 4096 >, LogarithmicMapping>) ,
501- (std::pair<store_factory<SparseStore<A>>, LogarithmicMapping>)
401+ DDSketchUnboundedStoreTestCase ,
402+ DDSketchCollapsingHighestStoreTestCase< 4096 >,
403+ DDSketchCollapsingLowestStoreTestCase< 4096 >,
404+ DDSketchSparseStoreTestCase
502405) {
503406 auto positive_store = *TestType::first_type::new_store ();
504407 auto negative_store = *TestType::first_type::new_store ();
@@ -523,10 +426,10 @@ TEMPLATE_TEST_CASE("DDSketch merging test", "[ddsketch]",
523426}
524427
525428TEMPLATE_TEST_CASE (" DDSketch different mappings" , " [ddsketch]" ,
526- (std::pair<store_factory<UnboundedSizeDenseStore<A>>, LogarithmicMapping>) ,
527- (std::pair<store_factory<CollapsingHighestDenseStore<A>, 4096 >, LogarithmicMapping>) ,
528- (std::pair<store_factory<CollapsingLowestDenseStore<A>, 4096 >, LogarithmicMapping>) ,
529- (std::pair<store_factory<SparseStore<A>>, LogarithmicMapping>)
429+ DDSketchUnboundedStoreTestCase ,
430+ DDSketchCollapsingHighestStoreTestCase< 4096 >,
431+ DDSketchCollapsingLowestStoreTestCase< 4096 >,
432+ DDSketchSparseStoreTestCase
530433) {
531434 auto positive_store = *TestType::first_type::new_store ();
532435 auto negative_store = *TestType::first_type::new_store ();
@@ -539,10 +442,10 @@ TEMPLATE_TEST_CASE("DDSketch different mappings", "[ddsketch]",
539442}
540443
541444TEMPLATE_TEST_CASE (" DDSketch add random test" , " [ddsketch][random]" ,
542- (std::pair<store_factory<UnboundedSizeDenseStore<A>>, LogarithmicMapping>) ,
543- (std::pair<store_factory<CollapsingHighestDenseStore<A>, 4096 >, LogarithmicMapping>) ,
544- (std::pair<store_factory<CollapsingLowestDenseStore<A>, 4096 >, LogarithmicMapping>) ,
545- (std::pair<store_factory<SparseStore<A>>, LogarithmicMapping>)
445+ DDSketchUnboundedStoreTestCase ,
446+ DDSketchCollapsingHighestStoreTestCase< 4096 >,
447+ DDSketchCollapsingLowestStoreTestCase< 4096 >,
448+ DDSketchSparseStoreTestCase
546449) {
547450 auto positive_store = *TestType::first_type::new_store ();
548451 auto negative_store = *TestType::first_type::new_store ();
@@ -572,10 +475,10 @@ TEMPLATE_TEST_CASE("DDSketch add random test", "[ddsketch][random]",
572475}
573476
574477TEMPLATE_TEST_CASE (" DDSketch merging random test" , " [ddsketch][random]" ,
575- (std::pair<store_factory<UnboundedSizeDenseStore<A>>, LogarithmicMapping>) ,
576- (std::pair<store_factory<CollapsingHighestDenseStore<A>, 4096 >, LogarithmicMapping>) ,
577- (std::pair<store_factory<CollapsingLowestDenseStore<A>, 4096 >, LogarithmicMapping>) ,
578- (std::pair<store_factory<SparseStore<A>>, LogarithmicMapping>)
478+ DDSketchUnboundedStoreTestCase ,
479+ DDSketchCollapsingHighestStoreTestCase< 4096 >,
480+ DDSketchCollapsingLowestStoreTestCase< 4096 >,
481+ DDSketchSparseStoreTestCase
579482) {
580483 auto positive_store = *TestType::first_type::new_store ();
581484 auto negative_store = *TestType::first_type::new_store ();
0 commit comments