public long cardinality() throws IOException {
switch (format) {
case NORMAL:
    double E=0.0D;
  int V=0;
for (int i=0; i < this.m; i++) {
  byte rho=getRho(i);
  E=E + 1.0D / (1L << (int)rho);
  if (0 == (int)rho) {
    V++;
  }
}
E=1.0D / E;
E=alpha[this.p - 4] * this.m * this.m* E;
double Eprime=(E <= 5 * this.m) ? E - estimateBias(E,this.p) : E;
double H;
if (0 != V) {
H=linearCounting(this.m,V);
}
 else {
H=Eprime;
}
if ((p <= 18 && H <= THRESHOLDS[this.p - 4]) || (p > 18 && E <= 5 * this.m)) {
return Math.round(H);
}
 else {
return Math.round(Eprime);
}
case SPARSE:
merge();
return Math.round(linearCounting(mprime,mprime - sparse_list_len));
default :
return -1;
}
}

public long cardinality ( ) throws IOException { switch ( format ) { case NORMAL : double E = 0.0D ; int V = 0 ; for ( int i = 0 ; i < this . m ; i ++ ) { byte rho = getRho ( i ) ; E = E + 1.0D / ( 1L << ( int ) rho ) ; if ( 0 == ( int ) rho ) { V ++ ; } } E = 1.0D / E ; E = alpha [ this . p - 4 ] * this . m * this . m * E ; double Eprime = ( E <= 5 * this . m ) ? E - estimateBias ( E , this . p ) : E ; double H ; if ( 0 != V ) { H = linearCounting ( this . m , V ) ; } else { H = Eprime ; } if ( ( p <= 18 && H <= THRESHOLDS [ this . p - 4 ] ) || ( p > 18 && E <= 5 * this . m ) ) { return Math . round ( H ) ; } else { return Math . round ( Eprime ) ; } case SPARSE : merge ( ) ; return Math . round ( linearCounting ( mprime , mprime - sparse_list_len ) ) ; default : return - 1 ; } }
compute the estimated cardinality
