@Test public void hugeOrInFJP1() { ImmutableRoaringBitmap[] input = IntStream.range(0, 513) .mapToObj(i -> testCase().withBitmapAt(0).withArrayAt(1).withRunAt(2).build().toMutableRoaringBitmap()) .toArray(ImmutableRoaringBitmap[]::new); assertEquals(BufferFastAggregation.or(input), POOL.submit(() -> BufferParallelAggregation.or(input)).join()); }
public static MutableRoaringBitmap or(ImmutableRoaringBitmap... bitmaps) { SortedMap<Character, List<MappeableContainer>> grouped = groupByKey(bitmaps); char[] keys = new char[grouped.size()]; MappeableContainer[] values = new MappeableContainer[grouped.size()]; List<List<MappeableContainer>> slices = new ArrayList<>(grouped.size()); int i = 0; for (Map.Entry<Character, List<MappeableContainer>> 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 MutableRoaringBitmap(new MutableRoaringArray(keys, values, i)); }
BufferParallelAggregation { public static MutableRoaringBitmap or(ImmutableRoaringBitmap... bitmaps) { SortedMap<Character, List<MappeableContainer>> grouped = groupByKey(bitmaps); char[] keys = new char[grouped.size()]; MappeableContainer[] values = new MappeableContainer[grouped.size()]; List<List<MappeableContainer>> slices = new ArrayList<>(grouped.size()); int i = 0; for (Map.Entry<Character, List<MappeableContainer>> 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 MutableRoaringBitmap(new MutableRoaringArray(keys, values, i)); } }
BufferParallelAggregation { public static MutableRoaringBitmap or(ImmutableRoaringBitmap... bitmaps) { SortedMap<Character, List<MappeableContainer>> grouped = groupByKey(bitmaps); char[] keys = new char[grouped.size()]; MappeableContainer[] values = new MappeableContainer[grouped.size()]; List<List<MappeableContainer>> slices = new ArrayList<>(grouped.size()); int i = 0; for (Map.Entry<Character, List<MappeableContainer>> 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 MutableRoaringBitmap(new MutableRoaringArray(keys, values, i)); }  }
BufferParallelAggregation { public static MutableRoaringBitmap or(ImmutableRoaringBitmap... bitmaps) { SortedMap<Character, List<MappeableContainer>> grouped = groupByKey(bitmaps); char[] keys = new char[grouped.size()]; MappeableContainer[] values = new MappeableContainer[grouped.size()]; List<List<MappeableContainer>> slices = new ArrayList<>(grouped.size()); int i = 0; for (Map.Entry<Character, List<MappeableContainer>> 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 MutableRoaringBitmap(new MutableRoaringArray(keys, values, i)); }  static SortedMap<Character, List<MappeableContainer>> groupByKey(
          ImmutableRoaringBitmap... bitmaps); static MutableRoaringBitmap or(ImmutableRoaringBitmap... bitmaps); static MutableRoaringBitmap xor(ImmutableRoaringBitmap... bitmaps); }
BufferParallelAggregation { public static MutableRoaringBitmap or(ImmutableRoaringBitmap... bitmaps) { SortedMap<Character, List<MappeableContainer>> grouped = groupByKey(bitmaps); char[] keys = new char[grouped.size()]; MappeableContainer[] values = new MappeableContainer[grouped.size()]; List<List<MappeableContainer>> slices = new ArrayList<>(grouped.size()); int i = 0; for (Map.Entry<Character, List<MappeableContainer>> 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 MutableRoaringBitmap(new MutableRoaringArray(keys, values, i)); }  static SortedMap<Character, List<MappeableContainer>> groupByKey(
          ImmutableRoaringBitmap... bitmaps); static MutableRoaringBitmap or(ImmutableRoaringBitmap... bitmaps); static MutableRoaringBitmap xor(ImmutableRoaringBitmap... bitmaps);  }