1
- #include < iostream>
2
1
#include < limits>
3
2
#include < memory>
4
3
#include < string>
12
11
13
12
namespace bustub {
14
13
15
- TEST (HyperLogLogTestHyperLogLogTest , DISABLED_BasicTest1) {
14
+ TEST (HyperLogLogTest , DISABLED_BasicTest1) {
16
15
auto obj = HyperLogLog<std::string>(static_cast <uint64_t >(1 ));
17
16
18
17
ASSERT_EQ (obj.GetCardinality (), 0 );
@@ -22,7 +21,7 @@ TEST(HyperLogLogTestHyperLogLogTest, DISABLED_BasicTest1) {
22
21
obj.ComputeCardinality ();
23
22
auto ans = obj.GetCardinality ();
24
23
25
- ASSERT_EQ (ans, 0 );
24
+ ASSERT_EQ (ans, 2 );
26
25
27
26
for (uint64_t i = 0 ; i < 10 ; i++) {
28
27
obj.AddElem (" Andy" );
@@ -46,7 +45,7 @@ TEST(HyperLogLogTestHyperLogLogTest, DISABLED_BasicTest1) {
46
45
ASSERT_EQ (ans, 12 );
47
46
}
48
47
49
- TEST (HyperLogLogTestHyperLogLogTest , DISABLED_BasicTest2) {
48
+ TEST (HyperLogLogTest , DISABLED_BasicTest2) {
50
49
auto obj = HyperLogLog<int64_t >(static_cast <uint64_t >(3 ));
51
50
52
51
ASSERT_EQ (obj.GetCardinality (), 0 );
@@ -56,7 +55,7 @@ TEST(HyperLogLogTestHyperLogLogTest, DISABLED_BasicTest2) {
56
55
obj.ComputeCardinality ();
57
56
auto ans = obj.GetCardinality ();
58
57
59
- ASSERT_EQ (ans, 0 );
58
+ ASSERT_EQ (ans, 6 );
60
59
61
60
for (uint64_t i = 0 ; i < 10 ; i++) {
62
61
obj.AddElem (1 );
@@ -71,7 +70,7 @@ TEST(HyperLogLogTestHyperLogLogTest, DISABLED_BasicTest2) {
71
70
if (i == 0 ) {
72
71
obj.ComputeCardinality ();
73
72
ans = obj.GetCardinality ();
74
- ASSERT_EQ (ans, 0 );
73
+ ASSERT_EQ (ans, 13 );
75
74
}
76
75
}
77
76
@@ -88,21 +87,21 @@ TEST(HyperLogLogTestHyperLogLogTest, DISABLED_BasicTest2) {
88
87
if (i == 0 ) {
89
88
obj.ComputeCardinality ();
90
89
ans = obj.GetCardinality ();
91
- ASSERT_EQ (ans, 0 );
90
+ ASSERT_EQ (ans, 15 );
92
91
}
93
92
}
94
93
obj.ComputeCardinality ();
95
94
ans = obj.GetCardinality ();
96
- ASSERT_EQ (ans, 0 );
95
+ ASSERT_EQ (ans, 15 );
97
96
}
98
97
99
- TEST (HyperLogLogTestHyperLogLogTest , DISABLED_EdgeTest1) {
98
+ TEST (HyperLogLogTest , DISABLED_EdgeTest1) {
100
99
auto obj1 = HyperLogLog<int64_t >(-2 );
101
100
obj1.ComputeCardinality ();
102
101
ASSERT_EQ (obj1.GetCardinality (), 0 );
103
102
}
104
103
105
- TEST (HyperLogLogTestHyperLogLogTest , DISABLED_Edgetest2) {
104
+ TEST (HyperLogLogTest , DISABLED_Edgetest2) {
106
105
auto obj1 = HyperLogLog<int64_t >(0 );
107
106
obj1.ComputeCardinality ();
108
107
ASSERT_EQ (obj1.GetCardinality (), 0 );
@@ -116,7 +115,7 @@ TEST(HyperLogLogTestHyperLogLogTest, DISABLED_Edgetest2) {
116
115
ASSERT_EQ (obj1.GetCardinality (), 3 );
117
116
}
118
117
119
- TEST (HyperLogLogTestHyperLogLogTest , DISABLED_BasicParallelTest) {
118
+ TEST (HyperLogLogTest , DISABLED_BasicParallelTest) {
120
119
auto obj = HyperLogLog<std::string>(static_cast <uint64_t >(1 ));
121
120
122
121
std::vector<std::thread> threads1;
@@ -130,7 +129,7 @@ TEST(HyperLogLogTestHyperLogLogTest, DISABLED_BasicParallelTest) {
130
129
}
131
130
obj.ComputeCardinality ();
132
131
auto ans = obj.GetCardinality ();
133
- ASSERT_EQ (ans, 0 );
132
+ ASSERT_EQ (ans, 2 );
134
133
135
134
std::vector<std::thread> threads2;
136
135
for (uint16_t k = 0 ; k < 10 ; k++) {
@@ -154,7 +153,7 @@ TEST(HyperLogLogTestHyperLogLogTest, DISABLED_BasicParallelTest) {
154
153
ASSERT_EQ (ans, 12 );
155
154
}
156
155
157
- TEST (HyperLogLogTestHyperLogLogTest , DISABLED_ParallelTest1) {
156
+ TEST (HyperLogLogTest , DISABLED_ParallelTest1) {
158
157
auto obj = HyperLogLog<std::string>(static_cast <uint64_t >(17 ));
159
158
160
159
std::vector<std::thread> threads1;
@@ -168,7 +167,7 @@ TEST(HyperLogLogTestHyperLogLogTest, DISABLED_ParallelTest1) {
168
167
}
169
168
obj.ComputeCardinality ();
170
169
auto ans = obj.GetCardinality ();
171
- ASSERT_EQ (ans, 0 );
170
+ ASSERT_EQ (ans, 104074 );
172
171
173
172
std::vector<std::thread> threads2;
174
173
for (uint64_t k = 0 ; k < 3000 ; k++) {
@@ -184,10 +183,10 @@ TEST(HyperLogLogTestHyperLogLogTest, DISABLED_ParallelTest1) {
184
183
185
184
obj.ComputeCardinality ();
186
185
ans = obj.GetCardinality ();
187
- ASSERT_EQ (ans, 0 );
186
+ ASSERT_EQ (ans, 104076 );
188
187
}
189
188
190
- TEST (HyperLogLogTestHyperLogLogTest , DISABLED_PrestoBasicTest1) {
189
+ TEST (HyperLogLogTest , DISABLED_PrestoBasicTest1) {
191
190
auto obj = HyperLogLogPresto<std::string>(2 );
192
191
ASSERT_EQ (obj.GetCardinality (), 0 );
193
192
@@ -220,7 +219,7 @@ TEST(HyperLogLogTestHyperLogLogTest, DISABLED_PrestoBasicTest1) {
220
219
ASSERT_EQ (ans, 8 );
221
220
}
222
221
223
- TEST (HyperLogLogTestHyperLogLogTest , DISABLED_PrestoCase1) {
222
+ TEST (HyperLogLogTest , DISABLED_PrestoCase1) {
224
223
auto obj = HyperLogLogPresto<int64_t >(static_cast <uint64_t >(1 ));
225
224
auto ans = obj.GetCardinality ();
226
225
@@ -276,7 +275,7 @@ TEST(HyperLogLogTestHyperLogLogTest, DISABLED_PrestoCase1) {
276
275
ASSERT_EQ (15UL , expected5[1 ].to_ulong ());
277
276
}
278
277
279
- TEST (HyperLogLogTestHyperLogLogTest , DISABLED_PrestoCase2) {
278
+ TEST (HyperLogLogTest , DISABLED_PrestoCase2) {
280
279
auto obj = HyperLogLogPresto<int64_t >(static_cast <uint64_t >(0 ));
281
280
auto ans = obj.GetCardinality ();
282
281
@@ -289,15 +288,15 @@ TEST(HyperLogLogTestHyperLogLogTest, DISABLED_PrestoCase2) {
289
288
ASSERT_EQ (obj.GetOverflowBucketofIndex (0 ).to_ullong (), 4 );
290
289
}
291
290
292
- TEST (HyperLogLogTestHyperLogLogTest , DISABLED_PrestoEdgeCase) {
291
+ TEST (HyperLogLogTest , DISABLED_PrestoEdgeCase) {
293
292
auto obj = HyperLogLogPresto<int64_t >(-2 );
294
293
obj.ComputeCardinality ();
295
294
auto ans = obj.GetCardinality ();
296
295
297
296
ASSERT_EQ (ans, 0 );
298
297
}
299
298
300
- TEST (HyperLogLogTestHyperLogLogTest , DISABLED_PrestoEdgeCase2) {
299
+ TEST (HyperLogLogTest , DISABLED_PrestoEdgeCase2) {
301
300
auto obj = HyperLogLogPresto<int64_t >(0 );
302
301
obj.ComputeCardinality ();
303
302
auto ans = obj.GetCardinality ();
0 commit comments