当前位置: 首页>>代码示例>>Java>>正文


Java RoaringBitmap.bitmapOf方法代码示例

本文整理汇总了Java中org.roaringbitmap.RoaringBitmap.bitmapOf方法的典型用法代码示例。如果您正苦于以下问题:Java RoaringBitmap.bitmapOf方法的具体用法?Java RoaringBitmap.bitmapOf怎么用?Java RoaringBitmap.bitmapOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.roaringbitmap.RoaringBitmap的用法示例。

在下文中一共展示了RoaringBitmap.bitmapOf方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: newRoaringBitmap

import org.roaringbitmap.RoaringBitmap; //导入方法依赖的package包/类
private static Bitmap newRoaringBitmap(int[] data, boolean optimize) {
  RoaringBitmap roaring = RoaringBitmap.bitmapOf(data);
  if (optimize) {
    roaring.runOptimize();
  }
  return new RoaringBitmapWrapper(roaring);
}
 
开发者ID:lemire,项目名称:java_vs_c_bitmap_benchmark,代码行数:8,代码来源:BitmapFactory.java


示例2: testMultiAndNotWithCounts

import org.roaringbitmap.RoaringBitmap; //导入方法依赖的package包/类
@Test
public void testMultiAndNotWithCounts() throws Exception {
    MiruBitmapsRoaring bitmaps = new MiruBitmapsRoaring();

    RoaringBitmap original = RoaringBitmap.bitmapOf(0, 1, 2, 3, 4, 5, 6, 7);
    long[] counts = new long[4];
    bitmaps.inPlaceAndNotMultiTx(original, (tx, stackBuffer) -> {
        tx.tx(0, 1, RoaringBitmap.bitmapOf(0, 1), null, -1, stackBuffer);
        tx.tx(1, 3, RoaringBitmap.bitmapOf(2, 3), null, -1, stackBuffer);
        tx.tx(2, 5, RoaringBitmap.bitmapOf(4, 5), null, -1, stackBuffer);
        tx.tx(3, 7, RoaringBitmap.bitmapOf(6, 7), null, -1, stackBuffer);
    }, counts, Optional.absent(), new StackBuffer());

    assertEquals(original.getCardinality(), 0);
    for (int i = 0; i < counts.length; i++) {
        assertEquals(counts[i], 2);
    }

    original = RoaringBitmap.bitmapOf(0, 1, 2, 3, 4, 5, 6, 7);
    RoaringBitmap counter = RoaringBitmap.bitmapOf(1, 3, 5, 7);
    counts = new long[4];
    bitmaps.inPlaceAndNotMultiTx(original, (tx, stackBuffer) -> {
        tx.tx(0, 1, RoaringBitmap.bitmapOf(0, 1), null, -1, stackBuffer);
        tx.tx(1, 3, RoaringBitmap.bitmapOf(2, 3), null, -1, stackBuffer);
        tx.tx(2, 5, RoaringBitmap.bitmapOf(4, 5), null, -1, stackBuffer);
        tx.tx(3, 7, RoaringBitmap.bitmapOf(6, 7), null, -1, stackBuffer);
    }, counts, Optional.of(counter), new StackBuffer());

    assertEquals(original.getCardinality(), 0);
    assertEquals(counter.getCardinality(), 0);
    for (int i = 0; i < counts.length; i++) {
        assertEquals(counts[i], 1);
    }
}
 
开发者ID:jivesoftware,项目名称:miru,代码行数:35,代码来源:MiruBitmapsAggregationTest.java


示例3: setup

import org.roaringbitmap.RoaringBitmap; //导入方法依赖的package包/类
@Setup
public void setup() throws Exception {
    ZipRealDataRetriever dataRetriever = new ZipRealDataRetriever(dataset);
    System.out.println();
    System.out.println("Loading files from " + dataRetriever.getName());

    int normalsize = 0;
    int runsize = 0;
    int concisesize = 0;
    int wahsize = 0;
    int ewahsize = 0;
    int ewahsize32 = 0;
    long stupidarraysize = 0;
    long stupidbitmapsize = 0;
    int totalcount = 0;
    int numberofbitmaps = 0;
    int universesize = 0;
    for (int[] data : dataRetriever.fetchBitPositions()) {
        numberofbitmaps++;
        if(universesize < data[data.length - 1 ])
            universesize = data[data.length - 1 ];
        stupidarraysize += 8 + data.length * 4L;
        stupidbitmapsize += 8 + (data[data.length - 1] + 63L) / 64 * 8;
        totalcount += data.length;
        EWAHCompressedBitmap32 ewahBitmap32 = EWAHCompressedBitmap32.bitmapOf(data);
        ewahsize32 += ewahBitmap32.serializedSizeInBytes();
        ewah32.add(ewahBitmap32);

        RoaringBitmap basic = RoaringBitmap.bitmapOf(data);
        RoaringBitmap opti = basic.clone();
        opti.runOptimize();
        rc.add(opti);
        ac.add(basic);
        normalsize += basic.serializedSizeInBytes();
        runsize += opti.serializedSizeInBytes();
    }
    count = rc.size();
    System.out.println("# aggregating the first "+count+" bitmaps out of "+ac.size());

    /***
     * This is a hack. JMH does not allow us to report
     * anything directly ourselves, so we do it forcefully.
     */
    DecimalFormat df = new DecimalFormat("0.0");
    System.out.println();
    System.out.println("==============");
    System.out.println("= data set "+dataset);
    System.out.println("Number of bitmaps = " + numberofbitmaps
                       + " total count = " + totalcount
                       + " universe size = "+universesize);
    System.out.println("Average bits per bitmap = "
                       + df.format(totalcount * 1.0 / numberofbitmaps));
    System.out.println("Run-roaring total     = "
            + String.format("%1$10s", "" + runsize)
            + "B, average per bitmap = "
            + String.format("%1$10s",df.format(runsize * 1.0 / numberofbitmaps))
            + "B, average bits per entry =  "
            + String.format("%1$10s",df.format(runsize * 8.0 / totalcount)));
    System.out.println("EWAH 32-bit total = "
            + String.format("%1$10s", "" + ewahsize32)
            + "B, average per bitmap = "
            + String.format("%1$10s",df.format(ewahsize32 * 1.0 / numberofbitmaps))
            + "B, average bits per entry =  "
            + String.format("%1$10s",df.format(ewahsize32 * 8.0 / totalcount)));
    System.out.println("Naive array total     = "
            + String.format("%1$10s", "" + stupidarraysize)
            + "B, average per bitmap = "
            + String.format("%1$10s",df.format(stupidarraysize * 1.0 / numberofbitmaps))
            + "B, average bits per entry =  "
            + String.format("%1$10s",df.format(stupidarraysize * 8.0 / totalcount)));
    System.out.println("Naive bitmap total    = "
            + String.format("%1$10s", "" + stupidbitmapsize)
            + "B, average per bitmap = "
            + String.format("%1$10s",df.format(stupidbitmapsize * 1.0 / numberofbitmaps))
            + "B, average bits per entry =  "
            + String.format("%1$10s",df.format(stupidbitmapsize * 8.0 / totalcount)));
    System.out.println("==============");
    System.out.println();
    horizontalor = FastAggregation.naive_or(limit(count,rc.iterator()))
            .getCardinality();
}
 
开发者ID:lemire,项目名称:java_vs_c_bitmap_benchmark,代码行数:82,代码来源:RunContainerRealDataBenchmarkWideOrNaive.java


示例4: createWithBits

import org.roaringbitmap.RoaringBitmap; //导入方法依赖的package包/类
@Override
public RoaringBitmap createWithBits(int... indexes) {
    return RoaringBitmap.bitmapOf(indexes);
}
 
开发者ID:jivesoftware,项目名称:miru,代码行数:5,代码来源:MiruBitmapsRoaring.java



注:本文中的org.roaringbitmap.RoaringBitmap.bitmapOf方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。