### Question:
RoaringInspection { public static void optimize(RoaringBitmap bitmap, int[] ukeys) { RoaringArray array = bitmap.highLowContainer; short[] keys = intToShortKeys(ukeys); for (int i = 0; i < keys.length; i++) { int index = array.getIndex(keys[i]); if (index >= 0) { Container container = array.getContainerAtIndex(index); array.setContainerAtIndex(index, container.runOptimize()); } } } private  RoaringInspection(); static RoaringBitmap[] split(RoaringBitmap bitmap); static RoaringBitmap join(RoaringBitmap[] split); static RoaringBitmap[] extract(RoaringBitmap bitmap, int[] ukeys); static long sizeInBits(RoaringBitmap bitmap); static void cardinalityInBuckets(RoaringBitmap bitmap, int[][] indexes, long[][] buckets); static int key(int position); static int[] keys(RoaringBitmap bitmap); static int[] keysNotEqual(RoaringBitmap x1, RoaringBitmap x2); static int[] userialize(RoaringBitmap bitmap, DataOutput[] outContainers); static boolean[] userializeAtomized(RoaringBitmap index, int[] ukeys, DataOutput[] dataOutputs); static short[] serialize(RoaringBitmap bitmap, DataOutput[] outContainers); static long[] serializeSizeInBytes(RoaringBitmap bitmap, int[] ukeys); static boolean udeserialize(BitmapAndLastId<RoaringBitmap> result, StreamAtoms streamAtoms); static int lastSetBit(int ukey, DataInput inContainer); static void optimize(RoaringBitmap bitmap, int[] ukeys); static short intToShortKey(int ukey); static short[] intToShortKeys(int[] ukeys); static int shortToIntKey(short key); static int[] shortToIntKeys(short[] keys); static int containerCount(RoaringBitmap bitmap); static int naiveFirstIntersectingBit(RoaringBitmap x1, RoaringBitmap x2); static int firstIntersectingBit(RoaringBitmap x1, RoaringBitmap x2);  }### Answer:
@Test public void testOptimize() throws Exception { RoaringBitmap bitmap = new RoaringBitmap(); Random r = new Random(123); for (int i = 0; i < 3_000_000; i += 65_536) { if (r.nextBoolean()) { for (int j = 0; j < 65_536; j++) { bitmap.add(i + j); } } } int initialSize = bitmap.serializedSizeInBytes(); int[] keys = RoaringInspection.keys(bitmap); RoaringInspection.optimize(bitmap, keys); Assert.assertTrue(bitmap.serializedSizeInBytes() < initialSize); }