• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ImmutableRoaringBitmap类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: or

import org.roaringbitmap.buffer.ImmutableRoaringBitmap; //导入依赖的package包/类
private static ImmutableRoaringBitmap or(List<ImmutableRoaringBitmap> bitMaps) {
  if (bitMaps.size() == 1) {
    return bitMaps.get(0);
  }
  MutableRoaringBitmap answer = ImmutableRoaringBitmap.or(bitMaps.get(0), bitMaps.get(1));
  long start = System.currentTimeMillis();
  for (int i = 2; i < bitMaps.size(); i++) {
    answer.or(bitMaps.get(i));
  }

  long end = System.currentTimeMillis();

  bitMaps.get(0).getCardinality();
  System.out.println("OR operation Took " + (end - start));
  System.out.println("\toutput cardinality:" + answer.getCardinality());
  System.out.println("\toutout sizes:" + answer.getSizeInBytes());
  return answer;

}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:20,代码来源:BitmapPerformanceBenchmark.java


示例2: and

import org.roaringbitmap.buffer.ImmutableRoaringBitmap; //导入依赖的package包/类
private static ImmutableRoaringBitmap and(List<ImmutableRoaringBitmap> bitMaps) {
  if (bitMaps.size() == 1) {
    return bitMaps.get(0);
  }
  MutableRoaringBitmap answer = ImmutableRoaringBitmap.and(bitMaps.get(0), bitMaps.get(1));
  long start = System.currentTimeMillis();
  for (int i = 2; i < bitMaps.size(); i++) {
    answer.and(bitMaps.get(i));
  }

  long end = System.currentTimeMillis();
  int[] cardinality = new int[bitMaps.size()];
  int[] sizes = new int[bitMaps.size()];
  for (int i = 0; i < bitMaps.size(); i++) {
    ImmutableRoaringBitmap immutableRoaringBitmap = bitMaps.get(i);
    cardinality[i] = immutableRoaringBitmap.getCardinality();
    sizes[i] = immutableRoaringBitmap.getSizeInBytes();
  }
  bitMaps.get(0).getCardinality();
  System.out.println("AND operation Took " + (end - start));
  System.out.println("\toutput cardinality:" + answer.getCardinality());
  System.out.println("\toutout sizes:" + answer.getSizeInBytes());
  return answer;

}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:26,代码来源:BitmapPerformanceBenchmark.java


示例3: getOrBitmap

import org.roaringbitmap.buffer.ImmutableRoaringBitmap; //导入依赖的package包/类
public static ImmutableRoaringBitmap getOrBitmap(InvertedIndexReader invertedIndex, List<Integer> idsToOr) {
  if (idsToOr.size() == 0) {
    return new MutableRoaringBitmap();
  }

  if (idsToOr.size() == 1) {
    return invertedIndex.getImmutable(idsToOr.get(0));
  }

  MutableRoaringBitmap b = new MutableRoaringBitmap();
  for (int i = 0; i < idsToOr.size(); i++) {
    b.or(invertedIndex.getImmutable(idsToOr.get(i)));
  }

  return b;
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:17,代码来源:BitmapUtils.java


示例4: buildIndexMask

import org.roaringbitmap.buffer.ImmutableRoaringBitmap; //导入依赖的package包/类
@Override
public ImmutableRoaringBitmap buildIndexMask(int largestIndex,
    MiruInvertedIndex<MutableRoaringBitmap, ImmutableRoaringBitmap> removalIndex,
    BitmapAndLastId<MutableRoaringBitmap> container,
    StackBuffer stackBuffer) throws Exception {

    MutableRoaringBitmap mask = new MutableRoaringBitmap();
    if (largestIndex < 0) {
        return mask;
    }

    mask.flip(0, largestIndex + 1);
    if (removalIndex != null) {
        if (container == null) {
            container = new BitmapAndLastId<>();
        }
        removalIndex.getIndex(container, stackBuffer);
        if (container.isSet()) {
            mask.andNot(container.getBitmap());
        }
    }
    return mask;
}
 
开发者ID:jivesoftware,项目名称:miru,代码行数:24,代码来源:MiruBitmapsRoaringBuffer.java


示例5: descendingIntIterator

import org.roaringbitmap.buffer.ImmutableRoaringBitmap; //导入依赖的package包/类
@Override
public MiruIntIterator descendingIntIterator(ImmutableRoaringBitmap bitmap) {
    final IntIterator intIterator = bitmap.getReverseIntIterator();
    return new MiruIntIterator() {

        @Override
        public boolean hasNext() {
            return intIterator.hasNext();
        }

        @Override
        public int next() {
            return intIterator.next();
        }
    };
}
 
开发者ID:jivesoftware,项目名称:miru,代码行数:17,代码来源:MiruBitmapsRoaringBuffer.java


示例6: getRoaring

import org.roaringbitmap.buffer.ImmutableRoaringBitmap; //导入依赖的package包/类
static ImmutableRoaringBitmap[] getRoaring() {
    ImmutableRoaringBitmap[] answer = new ImmutableRoaringBitmap[roaringoffsets
            .size()];
    int i_rb = 0;
    for (int k = 0; k < roaringoffsets.size() - 1; k++) {
        roaringmbb.position((int) roaringoffsets.get(k).longValue());
        final ByteBuffer bb = roaringmbb.slice();
        bb.limit((int) (roaringoffsets.get(k + 1) - roaringoffsets.get(k)));
        ImmutableRoaringBitmap irb = new ImmutableRoaringBitmap(bb);
        answer[i_rb] = irb;
        i_rb++;
    }
    answer = Arrays.copyOfRange(answer, 0, i_rb);

    return answer;
}
 
开发者ID:lemire,项目名称:RoaringVSConciseBenchmark,代码行数:17,代码来源:TestMemoryMappedBitmaps.java


示例7: intersectionTest

import org.roaringbitmap.buffer.ImmutableRoaringBitmap; //导入依赖的package包/类
@Test
public void intersectionTest() {
    System.out
            .println("Testing that intersections give the same results...");

    ArrayList<ImmutableConciseSet> x = getConcise();
    ImmutableRoaringBitmap[] y = getRoaring();

    for (int k = 1; k < y.length; k += 50) {
        ImmutableRoaringBitmap[] yk = Arrays.copyOf(y, k);
        List<ImmutableConciseSet> xk = x.subList(0, k);
        ImmutableConciseSet ax = ImmutableConciseSet.intersection(xk
                .iterator());
        ImmutableRoaringBitmap ay = BufferFastAggregation.and(yk);
        Assert.assertArrayEquals(ay.toArray(), toArray(ax));
    }
}
 
开发者ID:lemire,项目名称:RoaringVSConciseBenchmark,代码行数:18,代码来源:TestMemoryMappedBitmaps.java


示例8: BitmapDocIdSet

import org.roaringbitmap.buffer.ImmutableRoaringBitmap; //导入依赖的package包/类
public BitmapDocIdSet(BlockMetadata blockMetadata, ImmutableRoaringBitmap... bitmaps) {
  this.blockMetadata = blockMetadata;
  raw = bitmaps;
  IntIterator[] iterators = new IntIterator[bitmaps.length];
  for (int i = 0; i < bitmaps.length; i++) {
    iterators[i] = bitmaps[i].getIntIterator();
  }
  bitmapBasedBlockIdSetIterator = new BitmapBasedBlockIdSetIterator(iterators);
  bitmapBasedBlockIdSetIterator.setStartDocId(blockMetadata.getStartDocId());
  bitmapBasedBlockIdSetIterator.setEndDocId(blockMetadata.getEndDocId());
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:12,代码来源:BitmapDocIdSet.java


示例9: nextFilterBlock

import org.roaringbitmap.buffer.ImmutableRoaringBitmap; //导入依赖的package包/类
@Override
public BaseFilterBlock nextFilterBlock(BlockId BlockId) {
  Predicate predicate = getPredicate();
  InvertedIndexReader invertedIndex = dataSource.getInvertedIndex();
  Block dataSourceBlock = dataSource.nextBlock();
  Dictionary dictionary = dataSource.getDictionary();
  PredicateEvaluator evaluator = PredicateEvaluatorProvider.getPredicateFunctionFor(predicate, dictionary);
  int[] dictionaryIds = evaluator.getDictionaryIds();
  ImmutableRoaringBitmap[] bitmaps = new ImmutableRoaringBitmap[dictionaryIds.length];
  for (int i = 0; i < dictionaryIds.length; i++) {
    bitmaps[i] = invertedIndex.getImmutable(dictionaryIds[i]);
  }
  bitmapBlock = new BitmapBlock(dataSourceBlock.getMetadata(), bitmaps);
  return bitmapBlock;
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:16,代码来源:BitmapBasedFilterOperator.java


示例10: buildRoaringBitmapForIndex

import org.roaringbitmap.buffer.ImmutableRoaringBitmap; //导入依赖的package包/类
private ImmutableRoaringBitmap buildRoaringBitmapForIndex(final int index) {
  final int currentOffset = getOffset(index);
  final int nextOffset = getOffset(index + 1);
  final int bufferLength = nextOffset - currentOffset;

  // Slice the buffer appropriately for Roaring Bitmap
  buffer.position(currentOffset);
  final ByteBuffer bb = buffer.slice();
  bb.limit(bufferLength);

  return new ImmutableRoaringBitmap(bb);
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:13,代码来源:BitmapInvertedIndexReader.java


示例11: getImmutable

import org.roaringbitmap.buffer.ImmutableRoaringBitmap; //导入依赖的package包/类
@Override
public ImmutableRoaringBitmap getImmutable(int idx) {
  if (idx >= cardinality) {
    return new MutableRoaringBitmap();
  }
  MutableRoaringBitmap rr = new MutableRoaringBitmap();
  int min = indexReader.getInt(idx, 0);
  int max = indexReader.getInt(idx, 1);
  for (int i = min; i <= max; i++) {
    rr.add(i);
  }
  return rr;
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:14,代码来源:SortedInvertedIndexReader.java


示例12: readFields

import org.roaringbitmap.buffer.ImmutableRoaringBitmap; //导入依赖的package包/类
@Override
public void readFields(ByteBuffer in) throws IOException {
    int size = peekLength(in);
    // make a copy of the content to be safe
    byte[] dst = new byte[size];
    in.get(dst);

    // ImmutableRoaringBitmap only maps the buffer, thus faster than constructing a MutableRoaringBitmap.
    // we'll convert to MutableRoaringBitmap later when mutate is needed
    bitmap = new ImmutableRoaringBitmap(ByteBuffer.wrap(dst));
}
 
开发者ID:apache,项目名称:kylin,代码行数:12,代码来源:RoaringBitmapCounter.java


示例13: set

import org.roaringbitmap.buffer.ImmutableRoaringBitmap; //导入依赖的package包/类
@Override
public MutableRoaringBitmap set(ImmutableRoaringBitmap bitmap, int... indexes) {
    MutableRoaringBitmap container = copy(bitmap);
    for (int index : indexes) {
        container.add(index);
    }
    return container;
}
 
开发者ID:jivesoftware,项目名称:miru,代码行数:9,代码来源:MiruBitmapsRoaringBuffer.java


示例14: remove

import org.roaringbitmap.buffer.ImmutableRoaringBitmap; //导入依赖的package包/类
@Override
public MutableRoaringBitmap remove(ImmutableRoaringBitmap bitmap, int... indexes) {
    MutableRoaringBitmap container = copy(bitmap);
    for (int index : indexes) {
        container.remove(index);
    }
    return container;
}
 
开发者ID:jivesoftware,项目名称:miru,代码行数:9,代码来源:MiruBitmapsRoaringBuffer.java


示例15: orTx

import org.roaringbitmap.buffer.ImmutableRoaringBitmap; //导入依赖的package包/类
@Override
public MutableRoaringBitmap orTx(List<MiruTxIndex<ImmutableRoaringBitmap>> indexes, StackBuffer stackBuffer) throws Exception {
    if (indexes.isEmpty()) {
        return new MutableRoaringBitmap();
    }

    MutableRoaringBitmap container = indexes.get(0).txIndex((bitmap, filer, offset, stackBuffer1) -> {
        if (bitmap != null) {
            MutableRoaringBitmap mutable = new MutableRoaringBitmap();
            mutable.or(bitmap);
            return mutable;
        } else if (filer != null) {
            return bitmapFromFiler(filer, offset, stackBuffer1);
        } else {
            return new MutableRoaringBitmap();
        }
    }, stackBuffer);

    for (MiruTxIndex<ImmutableRoaringBitmap> index : indexes.subList(1, indexes.size())) {
        index.txIndex((bitmap, filer, offset, stackBuffer1) -> {
            if (bitmap != null) {
                container.or(bitmap);
            } else if (filer != null) {
                container.or(bitmapFromFiler(filer, offset, stackBuffer1));
            }
            return null;
        }, stackBuffer);
    }

    return container;
}
 
开发者ID:jivesoftware,项目名称:miru,代码行数:32,代码来源:MiruBitmapsRoaringBuffer.java


示例16: orMultiTx

import org.roaringbitmap.buffer.ImmutableRoaringBitmap; //导入依赖的package包/类
@Override
public MutableRoaringBitmap orMultiTx(MiruMultiTxIndex<ImmutableRoaringBitmap> multiTermTxIndex, StackBuffer stackBuffer) throws Exception {
    MutableRoaringBitmap container = new MutableRoaringBitmap();
    multiTermTxIndex.txIndex((index, lastId, bitmap, filer, offset, stackBuffer1) -> {
        if (bitmap != null) {
            container.or(bitmap);
        } else if (filer != null) {
            container.or(bitmapFromFiler(filer, offset, stackBuffer1));
        }
    }, stackBuffer);
    return container;
}
 
开发者ID:jivesoftware,项目名称:miru,代码行数:13,代码来源:MiruBitmapsRoaringBuffer.java


示例17: inPlaceAndNot

import org.roaringbitmap.buffer.ImmutableRoaringBitmap; //导入依赖的package包/类
@Override
public void inPlaceAndNot(MutableRoaringBitmap original,
    MiruInvertedIndex<MutableRoaringBitmap, ImmutableRoaringBitmap> not,
    StackBuffer stackBuffer) throws Exception {

    not.txIndex((bitmap, filer, offset, stackBuffer1) -> {
        if (bitmap != null) {
            original.andNot(bitmap);
        } else if (filer != null) {
            original.andNot(bitmapFromFiler(filer, offset, stackBuffer1));
        }
        return null;
    }, stackBuffer);
}
 
开发者ID:jivesoftware,项目名称:miru,代码行数:15,代码来源:MiruBitmapsRoaringBuffer.java


示例18: andNotMultiTx

import org.roaringbitmap.buffer.ImmutableRoaringBitmap; //导入依赖的package包/类
@Override
public MutableRoaringBitmap andNotMultiTx(MutableRoaringBitmap original,
    MiruMultiTxIndex<ImmutableRoaringBitmap> multiTermTxIndex,
    long[] counts,
    Optional<MutableRoaringBitmap> counter,
    StackBuffer stackBuffer) throws Exception {

    MutableRoaringBitmap container = copy(original);
    inPlaceAndNotMultiTx(container, multiTermTxIndex, counts, counter, stackBuffer);
    return container;
}
 
开发者ID:jivesoftware,项目名称:miru,代码行数:12,代码来源:MiruBitmapsRoaringBuffer.java


示例19: inPlaceAndNotMultiTx

import org.roaringbitmap.buffer.ImmutableRoaringBitmap; //导入依赖的package包/类
@Override
public void inPlaceAndNotMultiTx(MutableRoaringBitmap original,
    MiruMultiTxIndex<ImmutableRoaringBitmap> multiTermTxIndex,
    long[] counts,
    Optional<MutableRoaringBitmap> counter,
    StackBuffer stackBuffer) throws Exception {
    long[] originalCardinality = (counts == null) ? null : new long[] { cardinality(counter.or(original)) };
    multiTermTxIndex.txIndex((index, lastId, bitmap, filer, offset, stackBuffer1) -> {
        if (bitmap != null) {
            original.andNot(bitmap);
            if (counter.isPresent()) {
                counter.get().andNot(bitmap);
            }
        } else if (filer != null) {
            MutableRoaringBitmap bitmapFromFiler = bitmapFromFiler(filer, offset, stackBuffer1);
            original.andNot(bitmapFromFiler);
            if (counter.isPresent()) {
                counter.get().andNot(bitmapFromFiler);
            }
        }
        if (counts != null) {
            long nextCardinality = cardinality(counter.or(original));
            counts[index] = originalCardinality[0] - nextCardinality;
            originalCardinality[0] = nextCardinality;
        }
    }, stackBuffer);
}
 
开发者ID:jivesoftware,项目名称:miru,代码行数:28,代码来源:MiruBitmapsRoaringBuffer.java


示例20: multiTx

import org.roaringbitmap.buffer.ImmutableRoaringBitmap; //导入依赖的package包/类
@Override
public void multiTx(MiruMultiTxIndex<ImmutableRoaringBitmap> multiTermTxIndex,
    IndexAlignedBitmapStream<MutableRoaringBitmap> stream,
    StackBuffer stackBuffer) throws Exception {

    multiTermTxIndex.txIndex((index, lastId, bitmap, filer, offset, stackBuffer1) -> {
        if (bitmap != null) {
            stream.stream(index, lastId, copy(bitmap));
        } else if (filer != null) {
            stream.stream(index, lastId, bitmapFromFiler(filer, offset, stackBuffer1));
        }
    }, stackBuffer);
}
 
开发者ID:jivesoftware,项目名称:miru,代码行数:14,代码来源:MiruBitmapsRoaringBuffer.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MemoryPersistenceAdapter类代码示例发布时间:2022-05-22
下一篇:
Java Controller类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap