@Override public void serialize(DataOutputStream dos) throws IOException { bitmap.serialize(dos); }
@Override public boolean contains(int i) { return bitmap.get(i); }
@Override public int cardinality() { return bitmap.cardinality(); }
@Override public Bitmap flip(int rangeStart, int rangeEnd) { // synthesized with 2-upper-bounded NOTs int savedSize = bitmap.sizeInBits(); EWAHCompressedBitmap32 temp = null; try { temp = (EWAHCompressedBitmap32) bitmap.clone(); } catch (CloneNotSupportedException e) { } ; temp.setSizeInBits(rangeEnd, false); temp.not(); if (rangeStart != 0) { temp.setSizeInBits(rangeStart - 1, false); temp.not(); } temp.setSizeInBits(savedSize, false); return new Ewah32BitmapWrapper(temp); }
@Override public EWAHCompressedBitmap32 clone() throws CloneNotSupportedException { EWAHCompressedBitmap32 clone = new EWAHCompressedBitmap32(this.buffer.clone()); clone.sizeInBits = this.sizeInBits; clone.rlw = new RunningLengthWord32(clone.buffer, this.rlw.position); return clone; }
@Benchmark public int horizontalOr_EWAH32(BenchmarkState benchmarkState) { EWAHCompressedBitmap32[] a = new EWAHCompressedBitmap32[benchmarkState.ewah32.size()]; EWAHCompressedBitmap32 bitmapor = EWAHCompressedBitmap32.or(benchmarkState.ewah32.toArray(a)); int answer = bitmapor.cardinality(); return answer; }
public static Bitmap newImmutableEwah32Bitmap(int[] data) throws Exception { ByteBuffer bb = toByteBuffer(newEwah32Bitmap(data)); EWAHCompressedBitmap32 ewah = new EWAHCompressedBitmap32(bb); return new Ewah32BitmapWrapper(ewah); }
@Override public Bitmap or(Bitmap other) { return new Ewah32BitmapWrapper(bitmap.or(((Ewah32BitmapWrapper) other).bitmap)); }
@Override public Bitmap and(Bitmap other) { return new Ewah32BitmapWrapper(bitmap.and(((Ewah32BitmapWrapper) other).bitmap)); }
@Override public BitmapIterator iterator() { return new EwahIteratorWrapper(bitmap.intIterator()); }
@Override public Bitmap xor(Bitmap other) { return new Ewah32BitmapWrapper(bitmap.xor(((Ewah32BitmapWrapper) other).bitmap)); }
@Override public Bitmap clone() { try { return new Ewah32BitmapWrapper(bitmap.clone()); } catch (CloneNotSupportedException e) { throw new RuntimeException(e); } }
@Override public Bitmap aggregate(final Iterable<Bitmap> bitmaps) { Iterator<EWAHCompressedBitmap32> iterator = new Iterator<EWAHCompressedBitmap32>() { final Iterator<Bitmap> i = bitmaps.iterator(); @Override public boolean hasNext() { return i.hasNext(); } @Override public EWAHCompressedBitmap32 next() { return ((Ewah32BitmapWrapper) i.next()).bitmap; } @Override public void remove() { throw new UnsupportedOperationException(); } }; return new Ewah32BitmapWrapper(FastAggregation32.or(iterator)); } };
public static Bitmap newEwah32Bitmap(int[] data) { EWAHCompressedBitmap32 ewah32 = EWAHCompressedBitmap32.bitmapOf(data); return new Ewah32BitmapWrapper(ewah32); }
@Override public BitmapIterator reverseIterator() { return new EwahIteratorWrapper(bitmap.reverseIntIterator()); }
@Override public Bitmap andNot(Bitmap other) { return new Ewah32BitmapWrapper(bitmap.andNot(((Ewah32BitmapWrapper) other).bitmap)); }
@Override public Bitmap aggregate(Iterable<Bitmap> bitmaps) { final Iterator<Bitmap> i = bitmaps.iterator(); EWAHCompressedBitmap32 bitmap = ((Ewah32BitmapWrapper) i.next()).bitmap; while (i.hasNext()) { bitmap = bitmap.or(((Ewah32BitmapWrapper) i.next()).bitmap); } return new Ewah32BitmapWrapper(bitmap); } };
@Override public Bitmap aggregate(Iterable<Bitmap> bitmaps) { final Iterator<Bitmap> i = bitmaps.iterator(); EWAHCompressedBitmap32 bitmap = ((Ewah32BitmapWrapper) i.next()).bitmap; while (i.hasNext()) { bitmap = bitmap.and(((Ewah32BitmapWrapper) i.next()).bitmap); } return new Ewah32BitmapWrapper(bitmap); } };
public BenchmarkState() { int N = 30; Random rand = new Random(1234); for (int k = 0; k < N; ++k) { RoaringBitmap rb = new RoaringBitmap(); int start = rand.nextInt(10000); for (int z = 0; z < 50; ++z) { int end = start + rand.nextInt(10000); rb.add(start, end); start = end + rand.nextInt(1000); } ConciseSet ccs = toConcise(rb.toArray()); cc.add(ccs); wah.add(toWAH(rb.toArray())); icc.add(ImmutableConciseSet.newImmutableFromMutable(ccs)); ac.add(rb); rb = rb.clone(); rb.runOptimize(); rc.add(rb); ewah.add(EWAHCompressedBitmap.bitmapOf(rb.toArray())); ewah32.add(EWAHCompressedBitmap32.bitmapOf(rb.toArray())); } } }
@Override public int last() { return bitmap.reverseIntIterator().next(); }