Computes the cardinality of the HLL. @return the cardinality of HLL. This will never be negative.
()
| 509 | * @return the cardinality of HLL. This will never be negative. |
| 510 | */ |
| 511 | public long cardinality() { |
| 512 | switch(type) { |
| 513 | case EMPTY: |
| 514 | return 0/*by definition*/; |
| 515 | case EXPLICIT: |
| 516 | return explicitStorage.size(); |
| 517 | case SPARSE: |
| 518 | return (long)Math.ceil(sparseProbabilisticAlgorithmCardinality()); |
| 519 | case FULL: |
| 520 | return (long)Math.ceil(fullProbabilisticAlgorithmCardinality()); |
| 521 | default: |
| 522 | throw new RuntimeException("Unsupported HLL type " + type); |
| 523 | } |
| 524 | } |
| 525 | |
| 526 | // ------------------------------------------------------------------------ |
| 527 | // Cardinality helpers |