@Test public void disjointOR() { ImmutableRoaringBitmap one = testCase().withRunAt(0).withArrayAt(2).build().toMutableRoaringBitmap(); ImmutableRoaringBitmap two = testCase().withBitmapAt(1).build().toMutableRoaringBitmap(); ImmutableRoaringBitmap three = testCase().withArrayAt(3).build().toMutableRoaringBitmap(); assertEquals(BufferFastAggregation.or(one, two, three), BufferParallelAggregation.or(one, two, three)); }
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);  }