/** * Create a bitmap container with all bits set to false */ public MappeableBitmapContainer() { this.cardinality = 0; this.bitmap = LongBuffer.allocate(MAX_CAPACITY / 64); }
@Generates private LongBuffer generateLongBuffer() { return LongBuffer.allocate(generateInt()); }
/** * Return the content of this container as a LongBuffer. This creates a copy and might be * relatively slow. * * @return the LongBuffer */ public LongBuffer toLongBuffer() { LongBuffer lb = LongBuffer.allocate(bitmap.length); lb.put(bitmap); return lb; }
@Override public Supplier<MappeableContainer> supplier() { return () -> new MappeableBitmapContainer(LongBuffer.allocate(1 << 10), -1); }
@Override public long glGetQueryObjectui64(int query, int target) { LongBuffer buff = LongBuffer.allocate(1); GLContext.getCurrentGL().getGL2ES2().glGetQueryObjectui64v(query, target, buff); return buff.get(0); }
/** * Create a bitmap container with a run of ones from firstOfRun to lastOfRun, inclusive caller * must ensure that the range isn't so small that an ArrayContainer should have been created * instead * * @param firstOfRun first index * @param lastOfRun last index (range is exclusive) */ public MappeableBitmapContainer(final int firstOfRun, final int lastOfRun) { // TODO: this can be optimized for performance this.cardinality = lastOfRun - firstOfRun; this.bitmap = LongBuffer.allocate(MAX_CAPACITY / 64); Util.setBitmapRange(bitmap.array(), firstOfRun, lastOfRun); }
@Override @SuppressWarnings("WeakerAccess") public long[] getCompressedCounts() { LongBuffer buf = LongBuffer.allocate(counts.length); Simple64.compress(buf, counts, 0, counts.length); long[] r = new long[buf.position()]; buf.flip(); buf.get(r); return r; }
private static MappeableContainer or(List<MappeableContainer> containers) { int parallelism; // if there are few enough containers it's possible no bitmaps will be materialised if (containers.size() < 16) { MappeableContainer result = containers.get(0).clone(); for (int i = 1; i < containers.size(); ++i) { result = result.lazyIOR(containers.get(i)); } return result.repairAfterLazy(); } // heuristic to save memory if the union is large and likely to end up as a bitmap if (containers.size() < 512 || (parallelism = availableParallelism()) == 1) { MappeableContainer result = new MappeableBitmapContainer(LongBuffer.allocate(1 << 10), -1); for (MappeableContainer container : containers) { result = result.lazyIOR(container); } return result.repairAfterLazy(); } // we have an enormous slice (probably skewed), parallelise it int partitionSize = (containers.size() + parallelism - 1) / parallelism; return IntStream.range(0, parallelism) .parallel() .mapToObj(i -> containers.subList(i * partitionSize, Math.min((i + 1) * partitionSize, containers.size()))) .collect(OR); }
MappeableBitmapContainer(int newCardinality, LongBuffer newBitmap) { this.cardinality = newCardinality; LongBuffer tmp = newBitmap.duplicate(); // for thread safety this.bitmap = LongBuffer.allocate(tmp.limit()); tmp.rewind(); this.bitmap.put(tmp); }
@Test(expected = RuntimeException.class) public void throwsExceptionCopyPixelsToLongBuffer() { Bitmap bitmapOriginal = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888); LongBuffer buffer = LongBuffer.allocate(bitmapOriginal.getByteCount()); bitmapOriginal.copyPixelsToBuffer(buffer); }
@Test(expected = RuntimeException.class) public void throwsExceptionCopyPixelsFromLongBuffer() { Bitmap bitmapOriginal = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888); LongBuffer buffer = LongBuffer.allocate(bitmapOriginal.getByteCount()); bitmapOriginal.copyPixelsFromBuffer(buffer); }
if (isBitmap[k]) { final LongBuffer bitmapArray = LongBuffer.allocate(MappeableBitmapContainer.MAX_CAPACITY / 64);
/** * Create a bitmap container with all bits set to false */ public MappeableBitmapContainer() { this.cardinality = 0; this.bitmap = LongBuffer.allocate(MAX_CAPACITY / 64); }
@Override public Supplier<MappeableContainer> supplier() { return () -> new MappeableBitmapContainer(LongBuffer.allocate(1 << 10), -1); }
/** * Return the content of this container as a LongBuffer. This creates a copy and might be * relatively slow. * * @return the LongBuffer */ public LongBuffer toLongBuffer() { LongBuffer lb = LongBuffer.allocate(bitmap.length); lb.put(bitmap); return lb; }
public CompressedLongsSupplierSerializer( int sizePer, GenericIndexedWriter<ResourceHolder<LongBuffer>> flattener ) { this.sizePer = sizePer; this.flattener = flattener; endBuffer = LongBuffer.allocate(sizePer); endBuffer.mark(); }
public InMemoryCompressedLongs( int sizePer, ByteOrder order ) { this.sizePer = sizePer; strategy = CompressedLongBufferObjectStrategy.getBufferForOrder(order); endBuffer = LongBuffer.allocate(sizePer); endBuffer.mark(); }
@Override protected LongBuffer deserialize(final ArrayNode input) throws JsonProcessingException { final LongBuffer result = LongBuffer.allocate(input.size()); for(final JsonNode node: input) result.put(node.asLong()); return result; } }
MappeableBitmapContainer(int newCardinality, LongBuffer newBitmap) { this.cardinality = newCardinality; LongBuffer tmp = newBitmap.duplicate(); // for thread safety this.bitmap = LongBuffer.allocate(tmp.limit()); tmp.rewind(); this.bitmap.put(tmp); }
public void add(long value) throws IOException { if (! endBuffer.hasRemaining()) { endBuffer.rewind(); flattener.write(StupidResourceHolder.create(endBuffer)); endBuffer = LongBuffer.allocate(sizePer); endBuffer.mark(); } endBuffer.put(value); ++numInserted; }