Add HLLC tests for empty strings that don't pass. (#14085)

I believe the test case illustrates the cause of the problem in #13950.
This commit is contained in:
Gian Merlino 2023-04-17 03:16:42 -07:00 committed by GitHub
parent 1bd63948a1
commit facd82b493
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 0 deletions

View File

@ -857,6 +857,33 @@ public class HyperLogLogCollectorTest
}
}
@Test
@Ignore("Doesn't pass; see https://github.com/apache/druid/issues/13950")
public void testAddEmptyString()
{
final HyperLogLogCollector collector = HyperLogLogCollector.makeLatestCollector();
collector.add(HyperLogLogHash.getDefault().hash(""));
Assert.assertEquals(1, collector.estimateCardinality(), 0.01);
final byte[] collectorByteArray = collector.toByteArray();
final HyperLogLogCollector collector2 = HyperLogLogCollector.makeCollector(ByteBuffer.wrap(collectorByteArray));
Assert.assertEquals(1, collector2.estimateCardinality(), 0.01);
}
@Test
@Ignore("Doesn't pass; see https://github.com/apache/druid/issues/13950")
public void testAddEmptyStringAndOneOtherValue()
{
final HyperLogLogCollector collector = HyperLogLogCollector.makeLatestCollector();
collector.add(HyperLogLogHash.getDefault().hash("abc"));
collector.add(HyperLogLogHash.getDefault().hash(""));
Assert.assertEquals(2, collector.estimateCardinality(), 0.01);
final byte[] collectorByteArray = collector.toByteArray();
final HyperLogLogCollector collector2 = HyperLogLogCollector.makeCollector(ByteBuffer.wrap(collectorByteArray));
Assert.assertEquals(2, collector2.estimateCardinality(), 0.01);
}
// Provides a nice printout of error rates as a function of cardinality
@Ignore
@Test