private static void sparseFullRepresentationTest(final ISchemaVersion schemaVersion) throws IOException {
  final Writer output=openOutput(schemaVersion,"sparse_full_representation",TestType.UNION);
  final HLL emptyHLL1=newHLL(HLLType.EMPTY);
  final HLL emptyHLL2=newHLL(HLLType.EMPTY);
  cumulativeUnionLine(output,emptyHLL1,emptyHLL2,schemaVersion);
  final HLL fullHLL=newHLL(HLLType.FULL);
  fullHLL.addRaw(constructHLLValue(LOG2M,0,1));
  final HLL sparseHLL=newHLL(HLLType.SPARSE);
  sparseHLL.addRaw(constructHLLValue(LOG2M,0,1));
  output.write(stringCardinality(fullHLL) + "," + toByteA(fullHLL,schemaVersion)+ ","+ stringCardinality(sparseHLL)+ ","+ toByteA(sparseHLL,schemaVersion)+ "\n");
  output.flush();
  final HLL fullHLL2=newHLL(HLLType.FULL);
  fullHLL2.addRaw(constructHLLValue(LOG2M,1,1));
  sparseHLL.addRaw(constructHLLValue(LOG2M,1,1));
  output.write(stringCardinality(fullHLL2) + "," + toByteA(fullHLL2,schemaVersion)+ ","+ stringCardinality(sparseHLL)+ ","+ toByteA(sparseHLL,schemaVersion)+ "\n");
  output.flush();
  final HLL fullHLL3=newHLL(HLLType.FULL);
  for (int i=2; i < (SPARSE_THRESHOLD + 1); i++) {
    fullHLL3.addRaw(constructHLLValue(LOG2M,i,1));
    sparseHLL.addRaw(constructHLLValue(LOG2M,i,1));
  }
  output.write(stringCardinality(fullHLL3) + "," + toByteA(fullHLL3,schemaVersion)+ ","+ stringCardinality(sparseHLL)+ ","+ toByteA(sparseHLL,schemaVersion)+ "\n");
  output.flush();
}

private static void sparseFullRepresentationTest ( final ISchemaVersion schemaVersion ) throws IOException { final Writer output = openOutput ( schemaVersion , "sparse_full_representation" , TestType . UNION ) ; final HLL emptyHLL1 = newHLL ( HLLType . EMPTY ) ; final HLL emptyHLL2 = newHLL ( HLLType . EMPTY ) ; cumulativeUnionLine ( output , emptyHLL1 , emptyHLL2 , schemaVersion ) ; final HLL fullHLL = newHLL ( HLLType . FULL ) ; fullHLL . addRaw ( constructHLLValue ( LOG2M , 0 , 1 ) ) ; final HLL sparseHLL = newHLL ( HLLType . SPARSE ) ; sparseHLL . addRaw ( constructHLLValue ( LOG2M , 0 , 1 ) ) ; output . write ( stringCardinality ( fullHLL ) + "," + toByteA ( fullHLL , schemaVersion ) + "," + stringCardinality ( sparseHLL ) + "," + toByteA ( sparseHLL , schemaVersion ) + "\n" ) ; output . flush ( ) ; final HLL fullHLL2 = newHLL ( HLLType . FULL ) ; fullHLL2 . addRaw ( constructHLLValue ( LOG2M , 1 , 1 ) ) ; sparseHLL . addRaw ( constructHLLValue ( LOG2M , 1 , 1 ) ) ; output . write ( stringCardinality ( fullHLL2 ) + "," + toByteA ( fullHLL2 , schemaVersion ) + "," + stringCardinality ( sparseHLL ) + "," + toByteA ( sparseHLL , schemaVersion ) + "\n" ) ; output . flush ( ) ; final HLL fullHLL3 = newHLL ( HLLType . FULL ) ; for ( int i = 2 ; i < ( SPARSE_THRESHOLD + 1 ) ; i ++ ) { fullHLL3 . addRaw ( constructHLLValue ( LOG2M , i , 1 ) ) ; sparseHLL . addRaw ( constructHLLValue ( LOG2M , i , 1 ) ) ; } output . write ( stringCardinality ( fullHLL3 ) + "," + toByteA ( fullHLL3 , schemaVersion ) + "," + stringCardinality ( sparseHLL ) + "," + toByteA ( sparseHLL , schemaVersion ) + "\n" ) ; output . flush ( ) ; }
cumulatively unions " underpopulated " full hlls into the accumulator to verify the correct behavior from the postgresql implementation . the postgresql implementation ' s representations of probabilistic hlls should depend exclusively on the chosen sparse - to - full cutoff . format : cumulative union tests : - empty u " underpopulated " full = > sparse - sparse u " underpopulated " full = > sparse - sparse u " barely underpopulated " full = > full
