Skip to content

Commit 0393cf2

Browse files
removed deprecated methods
1 parent c5a8067 commit 0393cf2

9 files changed

Lines changed: 0 additions & 241 deletions

File tree

kll/include/kll_sketch.hpp

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -275,41 +275,6 @@ class kll_sketch {
275275
*/
276276
quantile_return_type get_quantile(double rank, bool inclusive = true) const;
277277

278-
/**
279-
* This returns an array that could have been generated by using get_quantile() for each
280-
* rank separately.
281-
*
282-
* <p>If the sketch is empty this throws std::runtime_error.
283-
*
284-
* @param ranks given array of ranks in the hypothetical sorted stream.
285-
* These ranks must be in the interval [0.0, 1.0].
286-
* @param size the number of ranks in the array
287-
* @param inclusive if true, the given ranks are considered inclusive (include weights of items)
288-
*
289-
* @return array of approximate quantiles corresponding to the given ranks in the same order.
290-
*
291-
* Deprecated. Will be removed in the next major version. Use get_quantile() instead.
292-
*/
293-
std::vector<T, A> get_quantiles(const double* ranks, uint32_t size, bool inclusive = true) const;
294-
295-
/**
296-
* This is a multiple-query version of get_quantile() that allows the caller to
297-
* specify the number of evenly-spaced ranks.
298-
*
299-
* <p>If the sketch is empty this throws std::runtime_error.
300-
*
301-
* @param num an integer that specifies the number of evenly-spaced ranks.
302-
* This must be an integer greater than 0. A value of 1 will return the quantile of rank 0.
303-
* A value of 2 will return quantiles of ranks 0 and 1. A value of 3 will return quantiles of ranks 0,
304-
* 0.5 (median) and 1, etc.
305-
* @param inclusive if true, the ranks are considered inclusive (include weights of items)
306-
*
307-
* @return array of approximate quantiles corresponding to the given number of evenly-spaced ranks.
308-
*
309-
* Deprecated. Will be removed in the next major version. Use get_quantile() instead.
310-
*/
311-
std::vector<T, A> get_quantiles(uint32_t num, bool inclusive = true) const;
312-
313278
/**
314279
* Returns an approximation to the normalized rank of the given item from 0 to 1, inclusive.
315280
*

kll/include/kll_sketch_impl.hpp

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -309,42 +309,6 @@ auto kll_sketch<T, C, A>::get_quantile(double rank, bool inclusive) const -> qua
309309
return sorted_view_->get_quantile(rank, inclusive);
310310
}
311311

312-
template<typename T, typename C, typename A>
313-
std::vector<T, A> kll_sketch<T, C, A>::get_quantiles(const double* ranks, uint32_t size, bool inclusive) const {
314-
if (is_empty()) throw std::runtime_error("operation is undefined for an empty sketch");
315-
std::vector<T, A> quantiles(allocator_);
316-
quantiles.reserve(size);
317-
318-
// may have a side effect of sorting level zero if needed
319-
setup_sorted_view();
320-
321-
for (uint32_t i = 0; i < size; i++) {
322-
const double rank = ranks[i];
323-
if ((rank < 0.0) || (rank > 1.0)) {
324-
throw std::invalid_argument("normalized rank cannot be less than 0 or greater than 1");
325-
}
326-
quantiles.push_back(sorted_view_->get_quantile(rank, inclusive));
327-
}
328-
return quantiles;
329-
}
330-
331-
template<typename T, typename C, typename A>
332-
std::vector<T, A> kll_sketch<T, C, A>::get_quantiles(uint32_t num, bool inclusive) const {
333-
if (is_empty()) throw std::runtime_error("operation is undefined for an empty sketch");
334-
if (num == 0) {
335-
throw std::invalid_argument("num must be > 0");
336-
}
337-
vector_double ranks(num, 0, allocator_);
338-
ranks[0] = 0.0;
339-
for (size_t i = 1; i < num; i++) {
340-
ranks[i] = static_cast<double>(i) / (num - 1);
341-
}
342-
if (num > 1) {
343-
ranks[num - 1] = 1.0;
344-
}
345-
return get_quantiles(ranks.data(), num, inclusive);
346-
}
347-
348312
template<typename T, typename C, typename A>
349313
double kll_sketch<T, C, A>::get_normalized_rank_error(bool pmf) const {
350314
return get_normalized_rank_error(min_k_, pmf);

kll/test/kll_sketch_test.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ TEST_CASE("kll sketch", "[kll_sketch]") {
6767
REQUIRE_THROWS_AS(sketch.get_max_item(), std::runtime_error);
6868
REQUIRE_THROWS_AS(sketch.get_rank(0), std::runtime_error);
6969
REQUIRE_THROWS_AS(sketch.get_quantile(0.5), std::runtime_error);
70-
const double ranks[3] {0, 0.5, 1};
71-
REQUIRE_THROWS_AS(sketch.get_quantiles(ranks, 3), std::runtime_error);
7270
const float split_points[1] {0};
7371
REQUIRE_THROWS_AS(sketch.get_PMF(split_points, 1), std::runtime_error);
7472
REQUIRE_THROWS_AS(sketch.get_CDF(split_points, 1), std::runtime_error);
@@ -99,12 +97,6 @@ TEST_CASE("kll sketch", "[kll_sketch]") {
9997
REQUIRE(sketch.get_min_item() == 1.0);
10098
REQUIRE(sketch.get_max_item() == 1.0);
10199
REQUIRE(sketch.get_quantile(0.5) == 1.0);
102-
const double ranks[3] {0, 0.5, 1};
103-
auto quantiles = sketch.get_quantiles(ranks, 3);
104-
REQUIRE(quantiles.size() == 3);
105-
REQUIRE(quantiles[0] == 1.0);
106-
REQUIRE(quantiles[1] == 1.0);
107-
REQUIRE(quantiles[2] == 1.0);
108100

109101
int count = 0;
110102
for (auto pair: sketch) {
@@ -144,20 +136,6 @@ TEST_CASE("kll sketch", "[kll_sketch]") {
144136
REQUIRE(sketch.get_max_item() == n);
145137
REQUIRE(sketch.get_quantile(1) == n);
146138

147-
const double ranks[3] {0, 0.5, 1};
148-
auto quantiles = sketch.get_quantiles(ranks, 3);
149-
REQUIRE(quantiles.size() == 3);
150-
REQUIRE(quantiles[0] == 1);
151-
REQUIRE(quantiles[1] == n / 2);
152-
REQUIRE(quantiles[2] == n);
153-
154-
// alternative method must produce the same result
155-
auto quantiles2 = sketch.get_quantiles(3);
156-
REQUIRE(quantiles2.size() == 3);
157-
REQUIRE(quantiles[0] == quantiles2[0]);
158-
REQUIRE(quantiles[1] == quantiles2[1]);
159-
REQUIRE(quantiles[2] == quantiles2[2]);
160-
161139
for (uint32_t i = 1; i <= n; i++) {
162140
const double true_rank_inclusive = static_cast<double>(i) / n;
163141
REQUIRE(sketch.get_rank(static_cast<float>(i)) == true_rank_inclusive);

quantiles/include/quantiles_sketch.hpp

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -288,46 +288,6 @@ class quantiles_sketch {
288288
*/
289289
quantile_return_type get_quantile(double rank, bool inclusive = true) const;
290290

291-
/**
292-
* This is a multiple-query version of get_quantile().
293-
* <p>
294-
* This returns an array that could have been generated by using get_quantile() for each
295-
* normalized rank separately.
296-
*
297-
* <p>If the sketch is empty this throws std::runtime_error.
298-
*
299-
* @param ranks given array of normalized ranks in the hypothetical sorted stream.
300-
* These ranks must be in the interval [0.0, 1.0], inclusive.
301-
* @param size the number of ranks in the array
302-
* @param inclusive if true the weight of the given item is included into the rank.
303-
* Otherwise the rank equals the sum of the weights of all items that are less than the given item
304-
* according to the Comparator.
305-
* @return array of approximations to items associated with given ranks in the same order as given ranks
306-
* in the input array.
307-
*
308-
* Deprecated. Will be removed in the next major version. Use get_quantile() instead.
309-
*/
310-
std::vector<T, Allocator> get_quantiles(const double* ranks, uint32_t size, bool inclusive = true) const;
311-
312-
/**
313-
* This is a multiple-query version of get_quantile() that allows the caller to
314-
* specify the number of evenly-spaced normalized ranks.
315-
*
316-
* <p>If the sketch is empty this throws std::runtime_error.
317-
*
318-
* @param num an integer that specifies the number of evenly-spaced ranks.
319-
* This must be an integer greater than 0. A value of 1 is equivalent to get_quantiles([0]).
320-
* A value of 2 is equivalent to get_quantiles([0, 1]). A value of 3 is equivalent to
321-
* get_quantiles([0, 0.5, 1]), etc.
322-
* @param inclusive if true the weight of the given item is included into the rank.
323-
* Otherwise the rank equals the sum of the weights of all items that are less than the given item
324-
* according to the Comparator.
325-
* @return array of approximations to items associated with the given number of evenly-spaced normalized ranks.
326-
*
327-
* Deprecated. Will be removed in the next major version. Use get_quantile() instead.
328-
*/
329-
std::vector<T, Allocator> get_quantiles(uint32_t num, bool inclusive = true) const;
330-
331291
/**
332292
* Returns an approximation to the normalized rank of the given item from 0 to 1, inclusive.
333293
*

quantiles/include/quantiles_sketch_impl.hpp

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -751,42 +751,6 @@ auto quantiles_sketch<T, C, A>::get_quantile(double rank, bool inclusive) const
751751
return sorted_view_->get_quantile(rank, inclusive);
752752
}
753753

754-
template<typename T, typename C, typename A>
755-
std::vector<T, A> quantiles_sketch<T, C, A>::get_quantiles(const double* ranks, uint32_t size, bool inclusive) const {
756-
if (is_empty()) throw std::runtime_error("operation is undefined for an empty sketch");
757-
std::vector<T, A> quantiles(allocator_);
758-
quantiles.reserve(size);
759-
760-
// possible side-effect: sorting base buffer
761-
setup_sorted_view();
762-
763-
for (uint32_t i = 0; i < size; ++i) {
764-
const double rank = ranks[i];
765-
if ((rank < 0.0) || (rank > 1.0)) {
766-
throw std::invalid_argument("Normalized rank cannot be less than 0 or greater than 1");
767-
}
768-
quantiles.push_back(sorted_view_->get_quantile(rank, inclusive));
769-
}
770-
return quantiles;
771-
}
772-
773-
template<typename T, typename C, typename A>
774-
std::vector<T, A> quantiles_sketch<T, C, A>::get_quantiles(uint32_t num, bool inclusive) const {
775-
if (is_empty()) throw std::runtime_error("operation is undefined for an empty sketch");
776-
if (num == 0) {
777-
throw std::invalid_argument("num must be > 0");
778-
}
779-
vector_double ranks(num, 0, allocator_);
780-
ranks[0] = 0.0;
781-
for (size_t i = 1; i < num; i++) {
782-
ranks[i] = static_cast<double>(i) / (num - 1);
783-
}
784-
if (num > 1) {
785-
ranks[num - 1] = 1.0;
786-
}
787-
return get_quantiles(ranks.data(), num, inclusive);
788-
}
789-
790754
template<typename T, typename C, typename A>
791755
double quantiles_sketch<T, C, A>::get_rank(const T& item, bool inclusive) const {
792756
if (is_empty()) throw std::runtime_error("operation is undefined for an empty sketch");

quantiles/test/quantiles_sketch_test.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ TEST_CASE("quantiles sketch", "[quantiles_sketch]") {
6565
REQUIRE_THROWS_AS(sketch.get_max_item(), std::runtime_error);
6666
REQUIRE_THROWS_AS(sketch.get_rank(0), std::runtime_error);
6767
REQUIRE_THROWS_AS(sketch.get_quantile(0.5), std::runtime_error);
68-
const double fractions[3] {0, 0.5, 1};
69-
REQUIRE_THROWS_AS(sketch.get_quantiles(fractions, 3).empty(), std::runtime_error);
7068
const float split_points[1] {0};
7169
REQUIRE_THROWS_AS(sketch.get_PMF(split_points, 1), std::runtime_error);
7270
REQUIRE_THROWS_AS(sketch.get_CDF(split_points, 1), std::runtime_error);
@@ -98,13 +96,6 @@ TEST_CASE("quantiles sketch", "[quantiles_sketch]") {
9896
REQUIRE(sketch.get_max_item() == 1.0);
9997
REQUIRE(sketch.get_quantile(0.5) == 1.0);
10098

101-
const double fractions[3] {0, 0.5, 1};
102-
auto quantiles = sketch.get_quantiles(fractions, 3);
103-
REQUIRE(quantiles.size() == 3);
104-
REQUIRE(quantiles[0] == 1.0);
105-
REQUIRE(quantiles[1] == 1.0);
106-
REQUIRE(quantiles[2] == 1.0);
107-
10899
int count = 0;
109100
for (auto pair: sketch) {
110101
REQUIRE(pair.second == 1);
@@ -153,20 +144,6 @@ TEST_CASE("quantiles sketch", "[quantiles_sketch]") {
153144
REQUIRE(sketch.get_max_item() == n);
154145
REQUIRE(sketch.get_quantile(1) == n);
155146

156-
const double ranks[3] {0, 0.5, 1};
157-
auto quantiles = sketch.get_quantiles(ranks, 3);
158-
REQUIRE(quantiles.size() == 3);
159-
REQUIRE(quantiles[0] == 1);
160-
REQUIRE(quantiles[1] == static_cast<float>(n / 2));
161-
REQUIRE(quantiles[2] == n);
162-
163-
// the alternative method must produce the same result
164-
auto quantiles2 = sketch.get_quantiles(3);
165-
REQUIRE(quantiles2.size() == 3);
166-
REQUIRE(quantiles[0] == quantiles2[0]);
167-
REQUIRE(quantiles[1] == quantiles2[1]);
168-
REQUIRE(quantiles[2] == quantiles2[2]);
169-
170147
int count = 0;
171148
for (auto pair: sketch) {
172149
REQUIRE(pair.second == 1);

req/include/req_sketch.hpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -287,20 +287,6 @@ class req_sketch {
287287
*/
288288
quantile_return_type get_quantile(double rank, bool inclusive = true) const;
289289

290-
/**
291-
* Returns an array of quantiles that correspond to the given array of normalized ranks.
292-
* <p>If the sketch is empty this throws std::runtime_error.
293-
*
294-
* @param ranks given array of normalized ranks.
295-
* @param size the number of ranks in the array.
296-
* @param inclusive if true, the given rank is considered inclusive (includes weight of an item)
297-
*
298-
* @return array of quantiles that correspond to the given array of normalized ranks
299-
*
300-
* Deprecated. Will be removed in the next major version. Use get_quantile() instead.
301-
*/
302-
std::vector<T, Allocator> get_quantiles(const double* ranks, uint32_t size, bool inclusive = true) const;
303-
304290
/**
305291
* Returns an approximate lower bound of the given normalized rank.
306292
* @param rank the given rank, a value between 0 and 1.0.

req/include/req_sketch_impl.hpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -265,25 +265,6 @@ auto req_sketch<T, C, A>::get_quantile(double rank, bool inclusive) const -> qua
265265
return sorted_view_->get_quantile(rank, inclusive);
266266
}
267267

268-
template<typename T, typename C, typename A>
269-
std::vector<T, A> req_sketch<T, C, A>::get_quantiles(const double* ranks, uint32_t size, bool inclusive) const {
270-
if (is_empty()) throw std::runtime_error("operation is undefined for an empty sketch");
271-
std::vector<T, A> quantiles(allocator_);
272-
quantiles.reserve(size);
273-
274-
// possible side-effect of sorting level zero
275-
setup_sorted_view();
276-
277-
for (uint32_t i = 0; i < size; ++i) {
278-
const double rank = ranks[i];
279-
if ((rank < 0.0) || (rank > 1.0)) {
280-
throw std::invalid_argument("Normalized rank cannot be less than 0 or greater than 1");
281-
}
282-
quantiles.push_back(sorted_view_->get_quantile(rank, inclusive));
283-
}
284-
return quantiles;
285-
}
286-
287268
template<typename T, typename C, typename A>
288269
quantiles_sorted_view<T, C, A> req_sketch<T, C, A>::get_sorted_view() const {
289270
if (!compactors_[0].is_sorted()) {

req/test/req_sketch_test.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ TEST_CASE("req sketch: empty", "[req_sketch]") {
4747
REQUIRE_THROWS_AS(sketch.get_max_item(), std::runtime_error);
4848
REQUIRE_THROWS_AS(sketch.get_rank(0), std::runtime_error);
4949
REQUIRE_THROWS_AS(sketch.get_quantile(0), std::runtime_error);
50-
const double ranks[3] {0, 0.5, 1};
51-
REQUIRE_THROWS_AS(sketch.get_quantiles(ranks, 3), std::runtime_error);
5250

5351
const float split_points[1] {0};
5452
REQUIRE_THROWS_AS(sketch.get_CDF(split_points, 1), std::runtime_error);
@@ -71,13 +69,6 @@ TEST_CASE("req sketch: single value, lra", "[req_sketch]") {
7169
REQUIRE(sketch.get_quantile(0.5, false) == 1);
7270
REQUIRE(sketch.get_quantile(1, false) == 1);
7371

74-
const double ranks[3] {0, 0.5, 1};
75-
auto quantiles = sketch.get_quantiles(ranks, 3);
76-
REQUIRE(quantiles.size() == 3);
77-
REQUIRE(quantiles[0] == 1);
78-
REQUIRE(quantiles[1] == 1);
79-
REQUIRE(quantiles[2] == 1);
80-
8172
unsigned count = 0;
8273
for (auto pair: sketch) {
8374
REQUIRE(pair.second == 1);
@@ -145,13 +136,6 @@ TEST_CASE("req sketch: exact mode", "[req_sketch]") {
145136
REQUIRE(sketch.get_quantile(0.9) == 9);
146137
REQUIRE(sketch.get_quantile(1) == 10);
147138

148-
const double ranks[3] {0, 0.5, 1};
149-
auto quantiles = sketch.get_quantiles(ranks, 3);
150-
REQUIRE(quantiles.size() == 3);
151-
REQUIRE(quantiles[0] == 1);
152-
REQUIRE(quantiles[1] == 5);
153-
REQUIRE(quantiles[2] == 10);
154-
155139
const float splits[3] {2, 6, 9};
156140
auto cdf = sketch.get_CDF(splits, 3, false);
157141
REQUIRE(cdf[0] == 0.1);

0 commit comments

Comments
 (0)