You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by jm...@apache.org on 2020/04/29 18:17:38 UTC
[incubator-datasketches-cpp] branch hll_exceptions created (now
7e7f598)
This is an automated email from the ASF dual-hosted git repository.
jmalkin pushed a change to branch hll_exceptions
in repository https://gitbox.apache.org/repos/asf/incubator-datasketches-cpp.git.
at 7e7f598 use std::out_of_range exceptions when checking memory capacity
This branch includes the following new commits:
new 7e7f598 use std::out_of_range exceptions when checking memory capacity
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org
[incubator-datasketches-cpp] 01/01: use std::out_of_range
exceptions when checking memory capacity
Posted by jm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jmalkin pushed a commit to branch hll_exceptions
in repository https://gitbox.apache.org/repos/asf/incubator-datasketches-cpp.git
commit 7e7f598bb4a7b8f01703b4412f3f2364b56b3596
Author: Jon Malkin <jm...@users.noreply.github.com>
AuthorDate: Wed Apr 29 11:17:17 2020 -0700
use std::out_of_range exceptions when checking memory capacity
---
hll/include/AuxHashMap-internal.hpp | 4 ++--
hll/include/CouponHashSet-internal.hpp | 4 ++--
hll/include/CouponList-internal.hpp | 4 ++--
hll/include/HllArray-internal.hpp | 4 ++--
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/hll/include/AuxHashMap-internal.hpp b/hll/include/AuxHashMap-internal.hpp
index 0d7db7a..6fc570f 100644
--- a/hll/include/AuxHashMap-internal.hpp
+++ b/hll/include/AuxHashMap-internal.hpp
@@ -75,7 +75,7 @@ AuxHashMap<A>* AuxHashMap<A>::deserialize(const void* bytes, size_t len,
const int* auxPtr = static_cast<const int*>(bytes);
if (srcCompact) {
if (len < auxCount * sizeof(int)) {
- throw std::invalid_argument("Input array too small to hold AuxHashMap image");
+ throw std::out_of_range("Input array too small to hold AuxHashMap image");
}
auxHashMap = new (ahmAlloc().allocate(1)) AuxHashMap<A>(lgArrInts, lgConfigK);
for (int i = 0; i < auxCount; ++i) {
@@ -87,7 +87,7 @@ AuxHashMap<A>* AuxHashMap<A>::deserialize(const void* bytes, size_t len,
} else { // updatable
int itemsToRead = 1 << lgAuxArrInts;
if (len < itemsToRead * sizeof(int)) {
- throw std::invalid_argument("Input array too small to hold AuxHashMap image");
+ throw std::out_of_range("Input array too small to hold AuxHashMap image");
}
auxHashMap = new (ahmAlloc().allocate(1)) AuxHashMap<A>(lgArrInts, lgConfigK);
for (int i = 0; i < itemsToRead; ++i) {
diff --git a/hll/include/CouponHashSet-internal.hpp b/hll/include/CouponHashSet-internal.hpp
index 159f90a..83a5adc 100644
--- a/hll/include/CouponHashSet-internal.hpp
+++ b/hll/include/CouponHashSet-internal.hpp
@@ -63,7 +63,7 @@ std::function<void(HllSketchImpl<A>*)> CouponHashSet<A>::get_deleter() const {
template<typename A>
CouponHashSet<A>* CouponHashSet<A>::newSet(const void* bytes, size_t len) {
if (len < HllUtil<A>::HASH_SET_INT_ARR_START) { // hard-coded
- throw std::invalid_argument("Input data length insufficient to hold CouponHashSet");
+ throw std::out_of_range("Input data length insufficient to hold CouponHashSet");
}
const uint8_t* data = static_cast<const uint8_t*>(bytes);
@@ -102,7 +102,7 @@ CouponHashSet<A>* CouponHashSet<A>::newSet(const void* bytes, size_t len) {
const int couponsInArray = (compactFlag ? couponCount : (1 << lgArrInts));
const size_t expectedLength = HllUtil<A>::HASH_SET_INT_ARR_START + (couponsInArray * sizeof(int));
if (len < expectedLength) {
- throw std::invalid_argument("Byte array too short for sketch. Expected " + std::to_string(expectedLength)
+ throw std::out_of_range("Byte array too short for sketch. Expected " + std::to_string(expectedLength)
+ ", found: " + std::to_string(len));
}
diff --git a/hll/include/CouponList-internal.hpp b/hll/include/CouponList-internal.hpp
index 448a95d..83c9ee4 100644
--- a/hll/include/CouponList-internal.hpp
+++ b/hll/include/CouponList-internal.hpp
@@ -99,7 +99,7 @@ CouponList<A>* CouponList<A>::copyAs(target_hll_type tgtHllType) const {
template<typename A>
CouponList<A>* CouponList<A>::newList(const void* bytes, size_t len) {
if (len < HllUtil<A>::LIST_INT_ARR_START) {
- throw std::invalid_argument("Input data length insufficient to hold CouponHashSet");
+ throw std::out_of_range("Input data length insufficient to hold CouponHashSet");
}
const uint8_t* data = static_cast<const uint8_t*>(bytes);
@@ -129,7 +129,7 @@ CouponList<A>* CouponList<A>::newList(const void* bytes, size_t len) {
const int couponsInArray = (compact ? couponCount : (1 << HllUtil<A>::computeLgArrInts(LIST, couponCount, lgK)));
const size_t expectedLength = HllUtil<A>::LIST_INT_ARR_START + (couponsInArray * sizeof(int));
if (len < expectedLength) {
- throw std::invalid_argument("Byte array too short for sketch. Expected " + std::to_string(expectedLength)
+ throw std::out_of_range("Byte array too short for sketch. Expected " + std::to_string(expectedLength)
+ ", found: " + std::to_string(len));
}
diff --git a/hll/include/HllArray-internal.hpp b/hll/include/HllArray-internal.hpp
index f538f49..88f0386 100644
--- a/hll/include/HllArray-internal.hpp
+++ b/hll/include/HllArray-internal.hpp
@@ -95,7 +95,7 @@ HllArray<A>* HllArray<A>::copyAs(const target_hll_type tgtHllType) const {
template<typename A>
HllArray<A>* HllArray<A>::newHll(const void* bytes, size_t len) {
if (len < HllUtil<A>::HLL_BYTE_ARR_START) {
- throw std::invalid_argument("Input data length insufficient to hold HLL array");
+ throw std::out_of_range("Input data length insufficient to hold HLL array");
}
const uint8_t* data = static_cast<const uint8_t*>(bytes);
@@ -124,7 +124,7 @@ HllArray<A>* HllArray<A>::newHll(const void* bytes, size_t len) {
const int arrayBytes = hllArrBytes(tgtHllType, lgK);
if (len < static_cast<size_t>(HllUtil<A>::HLL_BYTE_ARR_START + arrayBytes)) {
- throw std::invalid_argument("Input array too small to hold sketch image");
+ throw std::out_of_range("Input array too small to hold sketch image");
}
double hip, kxq0, kxq1;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org