Java Code Examples for org.roaringbitmap.RoaringBitmap#getLongCardinality()
The following examples show how to use
org.roaringbitmap.RoaringBitmap#getLongCardinality() .
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 |
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: VeryLargeBitmap.java From RoaringBitmap with Apache License 2.0 | 5 votes |
public static void main(String[] args) { RoaringBitmap rb = new RoaringBitmap(); rb.add(0L, 1L << 32);// the biggest bitmap we can create System.out.println("memory usage: "+ rb.getSizeInBytes()*1.0/(1L << 32)+" byte per value"); if(rb.getLongCardinality() != ( 1L << 32)) throw new RuntimeException("bug!"); }
Example 3
Source File: RoutingTable.java From spring-cloud-rsocket with Apache License 2.0 | 4 votes |
public boolean deregister(TagsMetadata metadata) { Assert.notNull(metadata, "metadata may not be null"); String routeId = metadata.getRouteId(); if (!StringUtils.hasText(routeId)) { if (log.isDebugEnabled()) { log.debug("Unable to deregister, no RouteId: " + metadata); } return false; } if (log.isInfoEnabled()) { log.info("Deregistering RSocket: " + metadata); } TagsMetadata findByRouteId = TagsMetadata.builder() .with(WellKnownKey.ROUTE_ID, routeId).build(); RoaringBitmap found = find(findByRouteId); if (found.isEmpty() || found.getLongCardinality() > 1) { if (log.isWarnEnabled()) { log.warn("Unable to deregister " + metadata + ", found: " + found.getLongCardinality()); } return false; } int internalId = found.first(); internalRouteIdToRouteId.remove(internalId); routeEntries.remove(routeId); metadata.getTags().forEach((key, value) -> { // TODO: deal with string keys? TagKey tagKey = new TagKey(key, value); if (tagsToBitmaps.containsKey(tagKey)) { RoaringBitmap bitmap = tagsToBitmaps.get(tagKey); bitmap.remove(internalId); } }); // TODO: deregistered event return true; }
Example 4
Source File: ContainsRange.java From RoaringBitmap with Apache License 2.0 | 4 votes |
@Override long getSup(RoaringBitmap bitmap) { return Util.toUnsignedLong(bitmap.first()) + bitmap.getLongCardinality() / 10; }
Example 5
Source File: ContainsRange.java From RoaringBitmap with Apache License 2.0 | 4 votes |
@Override long getMin(RoaringBitmap bitmap) { return Util.toUnsignedLong(bitmap.last()) - bitmap.getLongCardinality() / 10; }