@Test public void analyseRandomBitmap() { double delta = 0.1; double runFraction = 0.1; double bitmapFraction = 0.2; double denseLimit = runFraction + bitmapFraction; double arrayFraction = 1 - denseLimit; RoaringBitmap rb = SeededTestData.randomBitmap(1000, runFraction, denseLimit); BitmapStatistics result = BitmapAnalyser.analyse(rb); assertEquals(runFraction, result.containerFraction(result.getRunContainerCount()), delta); assertEquals(bitmapFraction, result.containerFraction(result.getBitmapContainerCount()), delta); assertEquals(arrayFraction, result.containerFraction(result.getArrayContainersStats().getContainersCount()), delta); }
public static BitmapStatistics analyse(RoaringBitmap r) { int acCount = 0; int acCardinalitySum = 0; int bcCount = 0; int rcCount = 0; ContainerPointer cp = r.getContainerPointer(); while (cp.getContainer() != null) { if (cp.isBitmapContainer()) { bcCount += 1; } else if (cp.isRunContainer()) { rcCount += 1; } else { acCount += 1; acCardinalitySum += cp.getCardinality(); } cp.advance(); } BitmapStatistics.ArrayContainersStats acStats = new BitmapStatistics.ArrayContainersStats(acCount, acCardinalitySum); return new BitmapStatistics(acStats, bcCount, rcCount); }
BitmapAnalyser { public static BitmapStatistics analyse(RoaringBitmap r) { int acCount = 0; int acCardinalitySum = 0; int bcCount = 0; int rcCount = 0; ContainerPointer cp = r.getContainerPointer(); while (cp.getContainer() != null) { if (cp.isBitmapContainer()) { bcCount += 1; } else if (cp.isRunContainer()) { rcCount += 1; } else { acCount += 1; acCardinalitySum += cp.getCardinality(); } cp.advance(); } BitmapStatistics.ArrayContainersStats acStats = new BitmapStatistics.ArrayContainersStats(acCount, acCardinalitySum); return new BitmapStatistics(acStats, bcCount, rcCount); } }
BitmapAnalyser { public static BitmapStatistics analyse(RoaringBitmap r) { int acCount = 0; int acCardinalitySum = 0; int bcCount = 0; int rcCount = 0; ContainerPointer cp = r.getContainerPointer(); while (cp.getContainer() != null) { if (cp.isBitmapContainer()) { bcCount += 1; } else if (cp.isRunContainer()) { rcCount += 1; } else { acCount += 1; acCardinalitySum += cp.getCardinality(); } cp.advance(); } BitmapStatistics.ArrayContainersStats acStats = new BitmapStatistics.ArrayContainersStats(acCount, acCardinalitySum); return new BitmapStatistics(acStats, bcCount, rcCount); }  }
BitmapAnalyser { public static BitmapStatistics analyse(RoaringBitmap r) { int acCount = 0; int acCardinalitySum = 0; int bcCount = 0; int rcCount = 0; ContainerPointer cp = r.getContainerPointer(); while (cp.getContainer() != null) { if (cp.isBitmapContainer()) { bcCount += 1; } else if (cp.isRunContainer()) { rcCount += 1; } else { acCount += 1; acCardinalitySum += cp.getCardinality(); } cp.advance(); } BitmapStatistics.ArrayContainersStats acStats = new BitmapStatistics.ArrayContainersStats(acCount, acCardinalitySum); return new BitmapStatistics(acStats, bcCount, rcCount); }  static BitmapStatistics analyse(RoaringBitmap r); static BitmapStatistics analyse(Collection<? extends RoaringBitmap> bitmaps); }
BitmapAnalyser { public static BitmapStatistics analyse(RoaringBitmap r) { int acCount = 0; int acCardinalitySum = 0; int bcCount = 0; int rcCount = 0; ContainerPointer cp = r.getContainerPointer(); while (cp.getContainer() != null) { if (cp.isBitmapContainer()) { bcCount += 1; } else if (cp.isRunContainer()) { rcCount += 1; } else { acCount += 1; acCardinalitySum += cp.getCardinality(); } cp.advance(); } BitmapStatistics.ArrayContainersStats acStats = new BitmapStatistics.ArrayContainersStats(acCount, acCardinalitySum); return new BitmapStatistics(acStats, bcCount, rcCount); }  static BitmapStatistics analyse(RoaringBitmap r); static BitmapStatistics analyse(Collection<? extends RoaringBitmap> bitmaps);  }