2626namespace datasketches {
2727
2828using aos_sketch = update_array_of_strings_tuple_sketch<>;
29- using types = array_of_strings_types<std::allocator<char >>;
30- using array_of_strings = types::array_of_strings;
31- using string_allocator = types::string_allocator;
32- using string_type = types::string_type;
33- using array_allocator = types::array_allocator;
29+ using array_of_strings = array<std::string>;
3430
3531static array_of_strings make_array (std::initializer_list<std::string> items) {
36- const string_type empty{string_allocator ()};
37- array_of_strings array (static_cast <uint8_t >(items.size ()), empty, array_allocator ());
32+ array_of_strings array (static_cast <uint8_t >(items.size ()), " " );
3833 size_t i = 0 ;
3934 for (const auto & item: items) {
40- array[static_cast <uint8_t >(i)] = string_type ( item. data (), item. size (), string_allocator ()) ;
35+ array[static_cast <uint8_t >(i)] = item;
4136 ++i;
4237 }
4338 return array;
@@ -48,13 +43,10 @@ TEST_CASE("aos sketch generate one value", "[serialize_for_java]") {
4843 for (const unsigned n: n_arr) {
4944 auto sketch = aos_sketch::builder ().build ();
5045 for (unsigned i = 0 ; i < n; ++i) {
51- const string_type empty{string_allocator ()};
52- array_of_strings key (1 , empty, array_allocator ());
53- const std::string key_value = std::to_string (i);
54- key[0 ] = string_type (key_value.data (), key_value.size (), string_allocator ());
55- array_of_strings value (1 , empty, array_allocator ());
56- const std::string value_str = " value" + std::to_string (i);
57- value[0 ] = string_type (value_str.data (), value_str.size (), string_allocator ());
46+ array_of_strings key (1 , " " );
47+ key[0 ] = std::to_string (i);
48+ array_of_strings value (1 , " " );
49+ value[0 ] = " value" + std::to_string (i);
5850 sketch.update (hash_array_of_strings_key (key), value);
5951 }
6052 REQUIRE (sketch.is_empty () == (n == 0 ));
@@ -69,17 +61,12 @@ TEST_CASE("aos sketch generate three values", "[serialize_for_java]") {
6961 for (const unsigned n: n_arr) {
7062 auto sketch = aos_sketch::builder ().build ();
7163 for (unsigned i = 0 ; i < n; ++i) {
72- const string_type empty{string_allocator ()};
73- array_of_strings key (1 , empty, array_allocator ());
74- const std::string key_value = std::to_string (i);
75- key[0 ] = string_type (key_value.data (), key_value.size (), string_allocator ());
76- array_of_strings value (3 , empty, array_allocator ());
77- const std::string value_a = " a" + std::to_string (i);
78- const std::string value_b = " b" + std::to_string (i);
79- const std::string value_c = " c" + std::to_string (i);
80- value[0 ] = string_type (value_a.data (), value_a.size (), string_allocator ());
81- value[1 ] = string_type (value_b.data (), value_b.size (), string_allocator ());
82- value[2 ] = string_type (value_c.data (), value_c.size (), string_allocator ());
64+ array_of_strings key (1 , " " );
65+ key[0 ] = std::to_string (i);
66+ array_of_strings value (3 , " " );
67+ value[0 ] = " a" + std::to_string (i);
68+ value[1 ] = " b" + std::to_string (i);
69+ value[2 ] = " c" + std::to_string (i);
8370 sketch.update (hash_array_of_strings_key (key), value);
8471 }
8572 REQUIRE (sketch.is_empty () == (n == 0 ));
@@ -95,10 +82,9 @@ TEST_CASE("aos sketch generate non-empty no entries", "[serialize_for_java]") {
9582 .set_resize_factor (resize_factor::X8 )
9683 .set_p (0 .01f )
9784 .build ();
98- const string_type empty{string_allocator ()};
99- array_of_strings key (1 , empty, array_allocator ());
85+ array_of_strings key (1 , " " );
10086 key[0 ] = " key1" ;
101- array_of_strings value (1 , empty, array_allocator () );
87+ array_of_strings value (1 , " " );
10288 value[0 ] = " value1" ;
10389 sketch.update (hash_array_of_strings_key (key), value);
10490 REQUIRE_FALSE (sketch.is_empty ());
@@ -112,15 +98,11 @@ TEST_CASE("aos sketch generate multi key strings", "[serialize_for_java]") {
11298 for (const unsigned n: n_arr) {
11399 auto sketch = aos_sketch::builder ().build ();
114100 for (unsigned i = 0 ; i < n; ++i) {
115- const string_type empty{string_allocator ()};
116- array_of_strings key (2 , empty, array_allocator ());
117- const std::string key0 = " key" + std::to_string (i);
118- const std::string key1 = " subkey" + std::to_string (i % 10 );
119- key[0 ] = string_type (key0.data (), key0.size (), string_allocator ());
120- key[1 ] = string_type (key1.data (), key1.size (), string_allocator ());
121- array_of_strings value (1 , empty, array_allocator ());
122- const std::string value_str = " value" + std::to_string (i);
123- value[0 ] = string_type (value_str.data (), value_str.size (), string_allocator ());
101+ array_of_strings key (2 , " " );
102+ key[0 ] = " key" + std::to_string (i);
103+ key[1 ] = " subkey" + std::to_string (i % 10 );
104+ array_of_strings value (1 , " " );
105+ value[0 ] = " value" + std::to_string (i);
124106 sketch.update (hash_array_of_strings_key (key), value);
125107 }
126108 REQUIRE (sketch.is_empty () == (n == 0 ));
0 commit comments