@Test public void twoContainerOR() { RoaringBitmap one = testCase().withRunAt(0).withArrayAt(1).build(); RoaringBitmap two = testCase().withBitmapAt(1).build(); RoaringBitmap three = testCase().withArrayAt(1).build(); assertEquals(FastAggregation.or(one, two, three), ParallelAggregation.or(one, two, three)); }
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);  }