Java Code Examples for org.roaringbitmap.RoaringBitmap#or()

The following examples show how to use org.roaringbitmap.RoaringBitmap#or() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Basic.java    From RoaringBitmap with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
      RoaringBitmap rr = RoaringBitmap.bitmapOf(1,2,3,1000);
      RoaringBitmap rr2 = new RoaringBitmap();
      rr2.add(4000L,4255L);

      RoaringBitmap rror = RoaringBitmap.or(rr, rr2);// new bitmap
      rr.or(rr2); //in-place computation
      boolean equals = rror.equals(rr);// true
      if(!equals) throw new RuntimeException("bug");
      // number of values stored?
      long cardinality = rr.getLongCardinality();
      System.out.println(cardinality);
      // a "forEach" is faster than this loop, but a loop is possible:
      for(int i : rr) {
        System.out.println(i);
      }
}
 
Example 2
Source File: Basic.java    From RoaringBitmap with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
      RoaringBitmap rr = RoaringBitmap.bitmapOf(1,2,3,1000);
      RoaringBitmap rr2 = new RoaringBitmap();
      rr2.add(4000L,4255L);

      RoaringBitmap rror = RoaringBitmap.or(rr, rr2);// new bitmap
      rr.or(rr2); //in-place computation
      boolean equals = rror.equals(rr);// true
      if(!equals) throw new RuntimeException("bug");
      // number of values stored?
      long cardinality = rr.getLongCardinality();
      System.out.println(cardinality);
      // a "forEach" is faster than this loop, but a loop is possible:
      for(int i : rr) {
        System.out.println(i);
      }
}
 
Example 3
Source File: LSH.java    From ache with Apache License 2.0 5 votes vote down vote up
public Iterator<Integer> query(int[] minhashes) {
    RoaringBitmap candidates = new RoaringBitmap();
    for (int band = 0; band < nBands; band++) {
        int[] hashes = computeHash(minhashes, band, nRows);
        RoaringBitmap idsBitmap = bandsStorage.getValues(band, hashes);
        if (idsBitmap != null) {
            candidates.or(idsBitmap);
        }
    }
    return candidates.iterator();
}
 
Example 4
Source File: RealDataBenchmarkOrNot.java    From RoaringBitmap with Apache License 2.0 5 votes vote down vote up
@Benchmark
public void pairwiseOrNotExternal(RealDataRoaringBitmaps state, Blackhole bh) {
  RoaringBitmap[] bitmaps = state.getBitmaps();
  for (int k = 0; k + 1 < bitmaps.length; ++k) {
    long limit = toUnsignedLong(bitmaps[k].last());
    RoaringBitmap range = new RoaringBitmap();
    range.add(0, limit);
    RoaringBitmap bitmap = RoaringBitmap.and(range, bitmaps[k+1]);
    bitmap.flip(0L, limit);
    bitmap.or(RoaringBitmap.and(range, bitmaps[k]));
    bh.consume(bitmap);
  }
}
 
Example 5
Source File: SlowORaggregate1.java    From RoaringBitmap with Apache License 2.0 4 votes vote down vote up
@Benchmark
public RoaringBitmap RoaringWithRun(BenchmarkState benchmarkState) {
  RoaringBitmap answer = RoaringBitmap.or(benchmarkState.rc.iterator());
  return answer;
}
 
Example 6
Source File: SlowORaggregate2.java    From RoaringBitmap with Apache License 2.0 4 votes vote down vote up
@Benchmark
public RoaringBitmap RoaringWithRun(BenchmarkState benchmarkState) {
  RoaringBitmap answer = RoaringBitmap.or(benchmarkState.rc.iterator());
  return answer;
}
 
Example 7
Source File: RoaringBitmapWrapper.java    From RoaringBitmap with Apache License 2.0 4 votes vote down vote up
@Override
public Bitmap or(Bitmap other) {
  return new RoaringBitmapWrapper(
      RoaringBitmap.or(bitmap, ((RoaringBitmapWrapper) other).bitmap));
}