Merge pull request #203 from apache/gcc_4_8_5_compat
compatibility with gcc 4.8.5
diff --git a/cpc/test/cpc_sketch_allocation_test.cpp b/cpc/test/cpc_sketch_allocation_test.cpp
index e52b09c..92e1a05 100644
--- a/cpc/test/cpc_sketch_allocation_test.cpp
+++ b/cpc/test/cpc_sketch_allocation_test.cpp
@@ -30,6 +30,7 @@
namespace datasketches {
using cpc_sketch_test_alloc = cpc_sketch_alloc<test_allocator<uint8_t>>;
+using alloc = test_allocator<uint8_t>;
TEST_CASE("cpc sketch allocation: serialize deserialize empty", "[cpc_sketch]") {
test_allocator_total_bytes = 0;
@@ -38,7 +39,7 @@
cpc_sketch_test_alloc sketch(11, DEFAULT_SEED, 0);
std::stringstream s(std::ios::in | std::ios::out | std::ios::binary);
sketch.serialize(s);
- auto deserialized = cpc_sketch_test_alloc::deserialize(s, DEFAULT_SEED, 0);
+ auto deserialized = cpc_sketch_test_alloc::deserialize(s, DEFAULT_SEED, alloc(0));
REQUIRE(deserialized.is_empty() == sketch.is_empty());
REQUIRE(deserialized.get_estimate() == sketch.get_estimate());
REQUIRE(deserialized.validate());
@@ -56,7 +57,7 @@
for (int i = 0; i < n; i++) sketch.update(i);
std::stringstream s(std::ios::in | std::ios::out | std::ios::binary);
sketch.serialize(s);
- auto deserialized = cpc_sketch_test_alloc::deserialize(s, DEFAULT_SEED, 0);
+ auto deserialized = cpc_sketch_test_alloc::deserialize(s, DEFAULT_SEED, alloc(0));
REQUIRE(deserialized.is_empty() == sketch.is_empty());
REQUIRE(deserialized.get_estimate() == sketch.get_estimate());
REQUIRE(deserialized.validate());
@@ -74,7 +75,7 @@
for (int i = 0; i < n; i++) sketch.update(i);
std::stringstream s(std::ios::in | std::ios::out | std::ios::binary);
sketch.serialize(s);
- auto deserialized = cpc_sketch_test_alloc::deserialize(s, DEFAULT_SEED, 0);
+ auto deserialized = cpc_sketch_test_alloc::deserialize(s, DEFAULT_SEED, alloc(0));
REQUIRE(deserialized.is_empty() == sketch.is_empty());
REQUIRE(deserialized.get_estimate() == sketch.get_estimate());
REQUIRE(deserialized.validate());
@@ -92,7 +93,7 @@
for (int i = 0; i < n; i++) sketch.update(i);
std::stringstream s(std::ios::in | std::ios::out | std::ios::binary);
sketch.serialize(s);
- auto deserialized = cpc_sketch_test_alloc::deserialize(s, DEFAULT_SEED, 0);
+ auto deserialized = cpc_sketch_test_alloc::deserialize(s, DEFAULT_SEED, alloc(0));
REQUIRE(deserialized.is_empty() == sketch.is_empty());
REQUIRE(deserialized.get_estimate() == sketch.get_estimate());
REQUIRE(deserialized.validate());
@@ -110,7 +111,7 @@
for (int i = 0; i < n; i++) sketch.update(i);
std::stringstream s(std::ios::in | std::ios::out | std::ios::binary);
sketch.serialize(s);
- auto deserialized = cpc_sketch_test_alloc::deserialize(s, DEFAULT_SEED, 0);
+ auto deserialized = cpc_sketch_test_alloc::deserialize(s, DEFAULT_SEED, alloc(0));
REQUIRE(deserialized.is_empty() == sketch.is_empty());
REQUIRE(deserialized.get_estimate() == sketch.get_estimate());
REQUIRE(deserialized.validate());
@@ -128,7 +129,7 @@
for (int i = 0; i < n; i++) sketch.update(i);
std::stringstream s(std::ios::in | std::ios::out | std::ios::binary);
sketch.serialize(s);
- auto deserialized = cpc_sketch_test_alloc::deserialize(s, DEFAULT_SEED, 0);
+ auto deserialized = cpc_sketch_test_alloc::deserialize(s, DEFAULT_SEED, alloc(0));
REQUIRE(deserialized.is_empty() == sketch.is_empty());
REQUIRE(deserialized.get_estimate() == sketch.get_estimate());
REQUIRE(deserialized.validate());
diff --git a/fi/test/frequent_items_sketch_custom_type_test.cpp b/fi/test/frequent_items_sketch_custom_type_test.cpp
index 06d4467..612abba 100644
--- a/fi/test/frequent_items_sketch_custom_type_test.cpp
+++ b/fi/test/frequent_items_sketch_custom_type_test.cpp
@@ -27,6 +27,7 @@
namespace datasketches {
using frequent_test_type_sketch = frequent_items_sketch<test_type, float, test_type_hash, test_type_equal, test_type_serde, test_allocator<test_type>>;
+using alloc = test_allocator<test_type>;
TEST_CASE("frequent items: custom type", "[frequent_items_sketch]") {
frequent_test_type_sketch sketch(3, frequent_test_type_sketch::LG_MIN_MAP_SIZE, 0);
@@ -50,7 +51,7 @@
std::stringstream s(std::ios::in | std::ios::out | std::ios::binary);
sketch.serialize(s);
- auto sketch2 = frequent_test_type_sketch::deserialize(s, 0);
+ auto sketch2 = frequent_test_type_sketch::deserialize(s, alloc(0));
REQUIRE_FALSE(sketch2.is_empty());
REQUIRE(sketch2.get_total_weight() == 17);
REQUIRE(sketch2.get_estimate(1) == 10);
diff --git a/hll/test/HllSketchTest.cpp b/hll/test/HllSketchTest.cpp
index be86321..541a70a 100644
--- a/hll/test/HllSketchTest.cpp
+++ b/hll/test/HllSketchTest.cpp
@@ -25,6 +25,7 @@
namespace datasketches {
using hll_sketch_test_alloc = hll_sketch_alloc<test_allocator<uint8_t>>;
+using alloc = test_allocator<uint8_t>;
static void runCheckCopy(int lgConfigK, target_hll_type tgtHllType) {
hll_sketch_test_alloc sk(lgConfigK, tgtHllType, false, 0);
@@ -190,7 +191,7 @@
REQUIRE(ss.tellp() == sk.get_updatable_serialization_bytes());
}
- hll_sketch_test_alloc sk2 = hll_sketch_test_alloc::deserialize(ss, 0);
+ hll_sketch_test_alloc sk2 = hll_sketch_test_alloc::deserialize(ss, alloc(0));
REQUIRE(sk2.get_estimate() == Approx(n).margin(0.01));
bool isCompact = sk2.is_compact();
@@ -300,13 +301,13 @@
std::stringstream ss;
ss.exceptions(std::ios::failbit | std::ios::badbit);
ss.str(std::string((char*)bytes.data(), 7));
- REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss, 0), std::ios_base::failure);
+ REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss, alloc(0)), std::ios_base::failure);
}
{
std::stringstream ss;
ss.exceptions(std::ios::failbit | std::ios::badbit);
ss.str(std::string((char*)bytes.data(), bytes.size() - 1));
- REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss, 0), std::ios_base::failure);
+ REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss, alloc(0)), std::ios_base::failure);
}
}
REQUIRE(test_allocator_total_bytes == 0);
@@ -327,13 +328,13 @@
std::stringstream ss;
ss.exceptions(std::ios::failbit | std::ios::badbit);
ss.str(std::string((char*)bytes.data(), 7));
- REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss, 0), std::ios_base::failure);
+ REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss, alloc(0)), std::ios_base::failure);
}
{
std::stringstream ss;
ss.exceptions(std::ios::failbit | std::ios::badbit);
ss.str(std::string((char*)bytes.data(), bytes.size() - 1));
- REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss, 0), std::ios_base::failure);
+ REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss, alloc(0)), std::ios_base::failure);
}
}
REQUIRE(test_allocator_total_bytes == 0);
@@ -357,25 +358,25 @@
std::stringstream ss;
ss.exceptions(std::ios::failbit | std::ios::badbit);
ss.str(std::string((char*)bytes.data(), 7));
- REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss, 0), std::ios_base::failure);
+ REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss, alloc(0)), std::ios_base::failure);
}
{
std::stringstream ss;
ss.exceptions(std::ios::failbit | std::ios::badbit);
ss.str(std::string((char*)bytes.data(), 15));
- REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss, 0), std::ios_base::failure);
+ REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss, alloc(0)), std::ios_base::failure);
}
{
std::stringstream ss;
ss.exceptions(std::ios::failbit | std::ios::badbit);
ss.str(std::string((char*)bytes.data(), 16420)); // before aux table
- REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss, 0), std::ios_base::failure);
+ REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss, alloc(0)), std::ios_base::failure);
}
{
std::stringstream ss;
ss.exceptions(std::ios::failbit | std::ios::badbit);
ss.str(std::string((char*)bytes.data(), bytes.size() - 1));
- REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss, 0), std::ios_base::failure);
+ REQUIRE_THROWS_AS(hll_sketch_test_alloc::deserialize(ss, alloc(0)), std::ios_base::failure);
}
}
REQUIRE(test_allocator_total_bytes == 0);
diff --git a/kll/test/kll_sketch_custom_type_test.cpp b/kll/test/kll_sketch_custom_type_test.cpp
index 12c491a..bfcf86e 100644
--- a/kll/test/kll_sketch_custom_type_test.cpp
+++ b/kll/test/kll_sketch_custom_type_test.cpp
@@ -26,7 +26,8 @@
namespace datasketches {
-typedef kll_sketch<test_type, test_type_less, test_type_serde, test_allocator<test_type>> kll_test_type_sketch;
+using kll_test_type_sketch = kll_sketch<test_type, test_type_less, test_type_serde, test_allocator<test_type>>;
+using alloc = test_allocator<test_type>;
TEST_CASE("kll sketch custom type", "[kll_sketch]") {
@@ -117,7 +118,7 @@
std::stringstream s(std::ios::in | std::ios::out | std::ios::binary);
sketch1.serialize(s);
REQUIRE((size_t) s.tellp() == sketch1.get_serialized_size_bytes());
- auto sketch2 = kll_test_type_sketch::deserialize(s, 0);
+ auto sketch2 = kll_test_type_sketch::deserialize(s, alloc(0));
REQUIRE((size_t) s.tellg() == sketch2.get_serialized_size_bytes());
REQUIRE(s.tellg() == s.tellp());
REQUIRE(sketch2.is_empty() == sketch1.is_empty());
diff --git a/kll/test/kll_sketch_test.cpp b/kll/test/kll_sketch_test.cpp
index 26ee7dd..def96f6 100644
--- a/kll/test/kll_sketch_test.cpp
+++ b/kll/test/kll_sketch_test.cpp
@@ -256,7 +256,7 @@
std::ifstream is;
is.exceptions(std::ios::failbit | std::ios::badbit);
is.open(testBinaryInputPath + "kll_sketch_from_java.sk", std::ios::binary);
- auto sketch = kll_float_sketch::deserialize(is, 0);
+ auto sketch = kll_float_sketch::deserialize(is, test_allocator<float>(0));
REQUIRE_FALSE(sketch.is_empty());
REQUIRE(sketch.is_estimation_mode());
REQUIRE(sketch.get_n() == 1000000);
@@ -270,7 +270,7 @@
std::stringstream s(std::ios::in | std::ios::out | std::ios::binary);
sketch.serialize(s);
REQUIRE(static_cast<size_t>(s.tellp()) == sketch.get_serialized_size_bytes());
- auto sketch2 = kll_float_sketch::deserialize(s, 0);
+ auto sketch2 = kll_float_sketch::deserialize(s, test_allocator<float>(0));
REQUIRE(static_cast<size_t>(s.tellp()) == sketch2.get_serialized_size_bytes());
REQUIRE(sketch2.is_empty() == sketch.is_empty());
REQUIRE(sketch2.is_estimation_mode() == sketch.is_estimation_mode());
@@ -303,7 +303,7 @@
std::stringstream s(std::ios::in | std::ios::out | std::ios::binary);
sketch.serialize(s);
REQUIRE(static_cast<size_t>(s.tellp()) == sketch.get_serialized_size_bytes());
- auto sketch2 = kll_float_sketch::deserialize(s, 0);
+ auto sketch2 = kll_float_sketch::deserialize(s, test_allocator<float>(0));
REQUIRE(static_cast<size_t>(s.tellp()) == sketch2.get_serialized_size_bytes());
REQUIRE(s.tellg() == s.tellp());
REQUIRE_FALSE(sketch2.is_empty());
@@ -321,7 +321,7 @@
std::ifstream is;
is.exceptions(std::ios::failbit | std::ios::badbit);
is.open(testBinaryInputPath + "kll_sketch_float_one_item_v1.sk", std::ios::binary);
- auto sketch = kll_float_sketch::deserialize(is, 0);
+ auto sketch = kll_float_sketch::deserialize(is, test_allocator<float>(0));
REQUIRE_FALSE(sketch.is_empty());
REQUIRE_FALSE(sketch.is_estimation_mode());
REQUIRE(sketch.get_n() == 1);
@@ -337,7 +337,7 @@
std::stringstream s(std::ios::in | std::ios::out | std::ios::binary);
sketch.serialize(s);
REQUIRE(static_cast<size_t>(s.tellp()) == sketch.get_serialized_size_bytes());
- auto sketch2 = kll_float_sketch::deserialize(s, 0);
+ auto sketch2 = kll_float_sketch::deserialize(s, test_allocator<float>(0));
REQUIRE(static_cast<size_t>(s.tellp()) == sketch2.get_serialized_size_bytes());
REQUIRE(s.tellg() == s.tellp());
REQUIRE(sketch2.is_empty() == sketch.is_empty());
@@ -578,7 +578,7 @@
std::stringstream s(std::ios::in | std::ios::out | std::ios::binary);
sketch1.serialize(s);
REQUIRE(static_cast<size_t>(s.tellp()) == sketch1.get_serialized_size_bytes());
- auto sketch2 = kll_string_sketch::deserialize(s, 0);
+ auto sketch2 = kll_string_sketch::deserialize(s, test_allocator<std::string>(0));
REQUIRE(static_cast<size_t>(s.tellp()) == sketch2.get_serialized_size_bytes());
REQUIRE(s.tellg() == s.tellp());
REQUIRE(sketch2.is_empty() == sketch1.is_empty());
diff --git a/req/test/req_sketch_custom_type_test.cpp b/req/test/req_sketch_custom_type_test.cpp
index 05acfff..38b0829 100644
--- a/req/test/req_sketch_custom_type_test.cpp
+++ b/req/test/req_sketch_custom_type_test.cpp
@@ -27,6 +27,7 @@
namespace datasketches {
using req_test_type_sketch = req_sketch<test_type, test_type_less, test_type_serde, test_allocator<test_type>>;
+using alloc = test_allocator<test_type>;
TEST_CASE("req sketch custom type", "[req_sketch]") {
@@ -92,7 +93,7 @@
std::stringstream s(std::ios::in | std::ios::out | std::ios::binary);
sketch1.serialize(s);
REQUIRE((size_t) s.tellp() == sketch1.get_serialized_size_bytes());
- auto sketch2 = req_test_type_sketch::deserialize(s, 0);
+ auto sketch2 = req_test_type_sketch::deserialize(s, alloc(0));
REQUIRE((size_t) s.tellg() == sketch2.get_serialized_size_bytes());
REQUIRE(s.tellg() == s.tellp());
REQUIRE(sketch2.is_empty() == sketch1.is_empty());
diff --git a/sampling/test/var_opt_allocation_test.cpp b/sampling/test/var_opt_allocation_test.cpp
index ca607b5..665edcb 100644
--- a/sampling/test/var_opt_allocation_test.cpp
+++ b/sampling/test/var_opt_allocation_test.cpp
@@ -30,6 +30,7 @@
using var_opt_test_sketch = var_opt_sketch<test_type, test_type_serde, test_allocator<test_type>>;
using var_opt_test_union = var_opt_union<test_type, test_type_serde, test_allocator<test_type>>;
+using alloc = test_allocator<test_type>;
TEST_CASE("varopt allocation test", "[var_opt_sketch]") {
test_allocator_total_bytes = 0;
@@ -42,7 +43,7 @@
std::stringstream ss;
sk1.serialize(ss);
- auto sk3 = var_opt_test_sketch::deserialize(ss, 0);
+ auto sk3 = var_opt_test_sketch::deserialize(ss, alloc(0));
var_opt_test_union u1(10, 0);
u1.update(sk1);