@Test public void or() { MutableBitMap bitmap = RoaringMutableBitMap.of(); bitmap.add(0); bitmap.add(4); BitmapAssert.equals( bitmap, FasterAggregation.or(new RangeBitmap(0, 1), new RangeBitmap(4, 5))); BitmapAssert.equals( RangeBitmap.of(0, 10), FasterAggregation.or(new RangeBitmap(0, 5), new RangeBitmap(2, 10))); BitmapAssert.equals( RangeBitmap.of(0, 10), FasterAggregation.or(new RangeBitmap(0, 2), new RangeBitmap(2, 10))); BitmapAssert.equals( RangeBitmap.of(0, 100), FasterAggregation.or(new RangeBitmap(0, 100), new RangeBitmap(4, 6))); BitmapAssert.equals( RangeBitmap.of(0, 100), FasterAggregation.or(new RangeBitmap(0, 100), new RangeBitmap(0, 100))); BitmapAssert.equals( RangeBitmap.of(-100, 6), FasterAggregation.or(new RangeBitmap(0, 2), new RangeBitmap(-100, 6))); BitmapAssert.equals( RangeBitmap.of(0, 20), FasterAggregation.or(new RangeBitmap(5, 20), new RangeBitmap(0, 9))); bitmap = RoaringMutableBitMap.of(); bitmap.add(100); bitmap.add(0); BitmapAssert.equals( bitmap, FasterAggregation.or(new RangeBitmap(100, 101), new RangeBitmap(0, 1))); }
public static ImmutableBitMap or(List<ImmutableBitMap> bitmaps) { if (bitmaps == null || bitmaps.isEmpty()) { return BitMaps.EMPTY_IMMUTABLE; } if (bitmaps.size() == 1) { return bitmaps.get(0); } MutableRoaringBitmap r = new MutableRoaringBitmap(); final IntList list = IntListFactory.createIntList(); for (ImmutableBitMap bitmap : bitmaps) { if (bitmap.isEmpty()) { continue; } if (bitmap.getType() == BitMapType.ID) { list.add(((IdBitMap) bitmap).getId()); } else if (bitmap instanceof BaseRoaringBitMap) { r.naivelazyor(((BaseRoaringBitMap) bitmap).bitmap); } } r.repairAfterLazy(); ImmutableBitMap bitMap = RoaringImmutableBitMap.of(r); if (list.size() > 0) { bitMap = bitMap.getOr(BitMaps.newImmutableBitMap(list)); } return bitMap; }
FasterAggregation { public static ImmutableBitMap or(List<ImmutableBitMap> bitmaps) { if (bitmaps == null || bitmaps.isEmpty()) { return BitMaps.EMPTY_IMMUTABLE; } if (bitmaps.size() == 1) { return bitmaps.get(0); } MutableRoaringBitmap r = new MutableRoaringBitmap(); final IntList list = IntListFactory.createIntList(); for (ImmutableBitMap bitmap : bitmaps) { if (bitmap.isEmpty()) { continue; } if (bitmap.getType() == BitMapType.ID) { list.add(((IdBitMap) bitmap).getId()); } else if (bitmap instanceof BaseRoaringBitMap) { r.naivelazyor(((BaseRoaringBitMap) bitmap).bitmap); } } r.repairAfterLazy(); ImmutableBitMap bitMap = RoaringImmutableBitMap.of(r); if (list.size() > 0) { bitMap = bitMap.getOr(BitMaps.newImmutableBitMap(list)); } return bitMap; } }
FasterAggregation { public static ImmutableBitMap or(List<ImmutableBitMap> bitmaps) { if (bitmaps == null || bitmaps.isEmpty()) { return BitMaps.EMPTY_IMMUTABLE; } if (bitmaps.size() == 1) { return bitmaps.get(0); } MutableRoaringBitmap r = new MutableRoaringBitmap(); final IntList list = IntListFactory.createIntList(); for (ImmutableBitMap bitmap : bitmaps) { if (bitmap.isEmpty()) { continue; } if (bitmap.getType() == BitMapType.ID) { list.add(((IdBitMap) bitmap).getId()); } else if (bitmap instanceof BaseRoaringBitMap) { r.naivelazyor(((BaseRoaringBitMap) bitmap).bitmap); } } r.repairAfterLazy(); ImmutableBitMap bitMap = RoaringImmutableBitMap.of(r); if (list.size() > 0) { bitMap = bitMap.getOr(BitMaps.newImmutableBitMap(list)); } return bitMap; }  }
FasterAggregation { public static ImmutableBitMap or(List<ImmutableBitMap> bitmaps) { if (bitmaps == null || bitmaps.isEmpty()) { return BitMaps.EMPTY_IMMUTABLE; } if (bitmaps.size() == 1) { return bitmaps.get(0); } MutableRoaringBitmap r = new MutableRoaringBitmap(); final IntList list = IntListFactory.createIntList(); for (ImmutableBitMap bitmap : bitmaps) { if (bitmap.isEmpty()) { continue; } if (bitmap.getType() == BitMapType.ID) { list.add(((IdBitMap) bitmap).getId()); } else if (bitmap instanceof BaseRoaringBitMap) { r.naivelazyor(((BaseRoaringBitMap) bitmap).bitmap); } } r.repairAfterLazy(); ImmutableBitMap bitMap = RoaringImmutableBitMap.of(r); if (list.size() > 0) { bitMap = bitMap.getOr(BitMaps.newImmutableBitMap(list)); } return bitMap; }  static ImmutableBitMap or(List<ImmutableBitMap> bitmaps); static ImmutableBitMap compose(List<ImmutableBitMap> bitmaps, final int[] offsets); static ImmutableBitMap or(RangeBitmap b1, RangeBitmap b2); static ImmutableBitMap and(RangeBitmap b1, RangeBitmap b2); static ImmutableBitMap andNot(RangeBitmap b1, RangeBitmap b2); }
FasterAggregation { public static ImmutableBitMap or(List<ImmutableBitMap> bitmaps) { if (bitmaps == null || bitmaps.isEmpty()) { return BitMaps.EMPTY_IMMUTABLE; } if (bitmaps.size() == 1) { return bitmaps.get(0); } MutableRoaringBitmap r = new MutableRoaringBitmap(); final IntList list = IntListFactory.createIntList(); for (ImmutableBitMap bitmap : bitmaps) { if (bitmap.isEmpty()) { continue; } if (bitmap.getType() == BitMapType.ID) { list.add(((IdBitMap) bitmap).getId()); } else if (bitmap instanceof BaseRoaringBitMap) { r.naivelazyor(((BaseRoaringBitMap) bitmap).bitmap); } } r.repairAfterLazy(); ImmutableBitMap bitMap = RoaringImmutableBitMap.of(r); if (list.size() > 0) { bitMap = bitMap.getOr(BitMaps.newImmutableBitMap(list)); } return bitMap; }  static ImmutableBitMap or(List<ImmutableBitMap> bitmaps); static ImmutableBitMap compose(List<ImmutableBitMap> bitmaps, final int[] offsets); static ImmutableBitMap or(RangeBitmap b1, RangeBitmap b2); static ImmutableBitMap and(RangeBitmap b1, RangeBitmap b2); static ImmutableBitMap andNot(RangeBitmap b1, RangeBitmap b2);  }