Search in sources :

Example 1 with ConciseSet

use of it.uniroma3.mat.extendedset.intset.ConciseSet in project RoaringBitmap by RoaringBitmap.

the class RealDataMemoryBenchmark method benchmark.

@Test
public void benchmark() throws Exception {
    ZipRealDataRetriever dataRetriever = new ZipRealDataRetriever(dataset);
    long optiSize = 0;
    long conciseSize = 0;
    long wahSize = 0;
    long sparseSize = 0;
    long bitsetSize = 0;
    for (int[] data : dataRetriever.fetchBitPositions()) {
        RoaringBitmap basic = RoaringBitmap.bitmapOf(data);
        basic.runOptimize();
        ConciseSet concise = toConcise(data);
        ConciseSet w = toWAH(data);
        SparseBitSet ss = toSparseBitSet(data);
        optiSize += sizeOf.deepSizeOf(basic);
        conciseSize += sizeOf.deepSizeOf(concise);
        wahSize += sizeOf.deepSizeOf(w);
        sparseSize += sizeOf.deepSizeOf(ss);
        bitsetSize += sizeOf.deepSizeOf(toBitSet(data));
    }
    System.out.println();
    System.out.println("==============");
    System.out.println(dataset + " / bitset size = " + RealDataDetailedBenchmark.humanReadable(bitsetSize) + " / Roaring size = " + RealDataDetailedBenchmark.humanReadable(optiSize) + " / concise size = " + RealDataDetailedBenchmark.humanReadable(conciseSize) + " / WAH size = " + RealDataDetailedBenchmark.humanReadable(wahSize) + " / SparseBitSet size = " + RealDataDetailedBenchmark.humanReadable(sparseSize));
    System.out.println("==============");
}
Also used : ConciseSet(it.uniroma3.mat.extendedset.intset.ConciseSet) SparseBitSet(com.zaxxer.sparsebits.SparseBitSet) Test(org.junit.Test)

Example 2 with ConciseSet

use of it.uniroma3.mat.extendedset.intset.ConciseSet in project RoaringBitmap by RoaringBitmap.

the class ConciseSetWrapper method naiveOrAggregator.

@Override
public BitmapAggregator naiveOrAggregator() {
    return new BitmapAggregator() {

        @Override
        public Bitmap aggregate(Iterable<Bitmap> bitmaps) {
            final Iterator<Bitmap> i = bitmaps.iterator();
            ConciseSet bitmap = ((ConciseSetWrapper) i.next()).bitmap;
            while (i.hasNext()) {
                bitmap = bitmap.union(((ConciseSetWrapper) i.next()).bitmap);
            }
            return new ConciseSetWrapper(bitmap);
        }
    };
}
Also used : ConciseSet(it.uniroma3.mat.extendedset.intset.ConciseSet)

Example 3 with ConciseSet

use of it.uniroma3.mat.extendedset.intset.ConciseSet in project RoaringBitmap by RoaringBitmap.

the class ConciseSetWrapper method naiveAndAggregator.

@Override
public BitmapAggregator naiveAndAggregator() {
    return new BitmapAggregator() {

        @Override
        public Bitmap aggregate(Iterable<Bitmap> bitmaps) {
            final Iterator<Bitmap> i = bitmaps.iterator();
            ConciseSet bitmap = ((ConciseSetWrapper) i.next()).bitmap;
            while (i.hasNext()) {
                bitmap = bitmap.intersection(((ConciseSetWrapper) i.next()).bitmap);
            }
            return new ConciseSetWrapper(bitmap);
        }
    };
}
Also used : ConciseSet(it.uniroma3.mat.extendedset.intset.ConciseSet)

Example 4 with ConciseSet

use of it.uniroma3.mat.extendedset.intset.ConciseSet in project RoaringBitmap by RoaringBitmap.

the class ConciseSetWrapper method priorityQueueOrAggregator.

@Override
public BitmapAggregator priorityQueueOrAggregator() {
    return new BitmapAggregator() {

        @Override
        public Bitmap aggregate(Iterable<Bitmap> bitmaps) {
            PriorityQueue<ConciseSet> pq = new PriorityQueue<ConciseSet>(128, new Comparator<ConciseSet>() {

                @Override
                public int compare(ConciseSet a, ConciseSet b) {
                    return (int) (a.size() * a.collectionCompressionRatio()) - (int) (b.size() * b.collectionCompressionRatio());
                }
            });
            for (Bitmap bitmap1 : bitmaps) {
                pq.add(((ConciseSetWrapper) bitmap1).bitmap);
            }
            ConciseSet bitmap;
            if (pq.isEmpty()) {
                bitmap = new ConciseSet();
            } else {
                while (pq.size() > 1) {
                    ConciseSet x1 = pq.poll();
                    ConciseSet x2 = pq.poll();
                    pq.add(x1.union(x2));
                }
                bitmap = pq.poll();
            }
            return new ConciseSetWrapper(bitmap);
        }
    };
}
Also used : ConciseSet(it.uniroma3.mat.extendedset.intset.ConciseSet) PriorityQueue(java.util.PriorityQueue)

Aggregations

ConciseSet (it.uniroma3.mat.extendedset.intset.ConciseSet)4 SparseBitSet (com.zaxxer.sparsebits.SparseBitSet)1 PriorityQueue (java.util.PriorityQueue)1 Test (org.junit.Test)1