@Test public void hugeOrInFJP3() { RoaringBitmap[] input = IntStream.range(0, 4096) .mapToObj(i -> testCase().withBitmapAt(0).withArrayAt(1).withRunAt(2).build()) .toArray(RoaringBitmap[]::new); assertEquals(FastAggregation.or(input), POOL.submit(() -> ParallelAggregation.or(input)).join()); }
public static RoaringBitmap or(RoaringBitmap... bitmaps) { SortedMap<Character, List<Container>> grouped = groupByKey(bitmaps); char[] keys = new char[grouped.size()]; Container[] values = new Container[grouped.size()]; List<List<Container>> slices = new ArrayList<>(grouped.size()); int i = 0; for (Map.Entry<Character, List<Container>> slice : grouped.entrySet()) { keys[i++] = slice.getKey(); slices.add(slice.getValue()); } IntStream.range(0, i) .parallel() .forEach(position -> values[position] = or(slices.get(position))); return new RoaringBitmap(new RoaringArray(keys, values, i)); }
ParallelAggregation { public static RoaringBitmap or(RoaringBitmap... bitmaps) { SortedMap<Character, List<Container>> grouped = groupByKey(bitmaps); char[] keys = new char[grouped.size()]; Container[] values = new Container[grouped.size()]; List<List<Container>> slices = new ArrayList<>(grouped.size()); int i = 0; for (Map.Entry<Character, List<Container>> slice : grouped.entrySet()) { keys[i++] = slice.getKey(); slices.add(slice.getValue()); } IntStream.range(0, i) .parallel() .forEach(position -> values[position] = or(slices.get(position))); return new RoaringBitmap(new RoaringArray(keys, values, i)); } }
ParallelAggregation { public static RoaringBitmap or(RoaringBitmap... bitmaps) { SortedMap<Character, List<Container>> grouped = groupByKey(bitmaps); char[] keys = new char[grouped.size()]; Container[] values = new Container[grouped.size()]; List<List<Container>> slices = new ArrayList<>(grouped.size()); int i = 0; for (Map.Entry<Character, List<Container>> slice : grouped.entrySet()) { keys[i++] = slice.getKey(); slices.add(slice.getValue()); } IntStream.range(0, i) .parallel() .forEach(position -> values[position] = or(slices.get(position))); return new RoaringBitmap(new RoaringArray(keys, values, i)); }  }
ParallelAggregation { public static RoaringBitmap or(RoaringBitmap... bitmaps) { SortedMap<Character, List<Container>> grouped = groupByKey(bitmaps); char[] keys = new char[grouped.size()]; Container[] values = new Container[grouped.size()]; List<List<Container>> slices = new ArrayList<>(grouped.size()); int i = 0; for (Map.Entry<Character, List<Container>> slice : grouped.entrySet()) { keys[i++] = slice.getKey(); slices.add(slice.getValue()); } IntStream.range(0, i) .parallel() .forEach(position -> values[position] = or(slices.get(position))); return new RoaringBitmap(new RoaringArray(keys, values, i)); }  static SortedMap<Character, List<Container>> groupByKey(RoaringBitmap... bitmaps); static RoaringBitmap or(RoaringBitmap... bitmaps); static RoaringBitmap xor(RoaringBitmap... bitmaps); }
ParallelAggregation { public static RoaringBitmap or(RoaringBitmap... bitmaps) { SortedMap<Character, List<Container>> grouped = groupByKey(bitmaps); char[] keys = new char[grouped.size()]; Container[] values = new Container[grouped.size()]; List<List<Container>> slices = new ArrayList<>(grouped.size()); int i = 0; for (Map.Entry<Character, List<Container>> slice : grouped.entrySet()) { keys[i++] = slice.getKey(); slices.add(slice.getValue()); } IntStream.range(0, i) .parallel() .forEach(position -> values[position] = or(slices.get(position))); return new RoaringBitmap(new RoaringArray(keys, values, i)); }  static SortedMap<Character, List<Container>> groupByKey(RoaringBitmap... bitmaps); static RoaringBitmap or(RoaringBitmap... bitmaps); static RoaringBitmap xor(RoaringBitmap... bitmaps);  }