Computes the cardinality of the HLL. @return the cardinality of HLL. This will never be negative.
()
| 543 | * @return the cardinality of HLL. This will never be negative. |
| 544 | */ |
| 545 | public long cardinality() { |
| 546 | switch (type) { |
| 547 | case EMPTY: |
| 548 | return 0 /*by definition*/; |
| 549 | case EXPLICIT: |
| 550 | return explicitStorage.size(); |
| 551 | case SPARSE: |
| 552 | return (long) Math.ceil(sparseProbabilisticAlgorithmCardinality()); |
| 553 | case FULL: |
| 554 | return (long) Math.ceil(fullProbabilisticAlgorithmCardinality()); |
| 555 | default: |
| 556 | throw new RuntimeException("Unsupported HLL type " + type); |
| 557 | } |
| 558 | } |
| 559 | |
| 560 | // ------------------------------------------------------------------------ |
| 561 | // Cardinality helpers |