public void setInitialCapacity(int valueCount) { long size = 1L * (long)valueCount * typeWidth; if(size > (long)MAX_ALLOCATION_SIZE) { throw new OversizedAllocationException("Requested amount of memory is more than max allowed allocation size"); } else { this.allocationSizeInBytes = (int)size; } }
private void checkDataBufferSize(long size) { if (size > MAX_ALLOCATION_SIZE) { throw new OversizedAllocationException("Memory required for vector " + " is (" + size + "), which is more than max allowed (" + MAX_ALLOCATION_SIZE + ")"); } }
private long computeAndCheckBufferSize(int valueCount) { final long size = computeCombinedBufferSize(valueCount, typeWidth); if (size > MAX_ALLOCATION_SIZE) { throw new OversizedAllocationException("Memory required for vector capacity " + valueCount + " is (" + size + "), which is more than max allowed (" + MAX_ALLOCATION_SIZE + ")"); } return size; }
private long computeAndCheckOffsetsBufferSize(int valueCount) { /* to track the end offset of last data element in vector, we need * an additional slot in offset buffer. */ final long size = computeCombinedBufferSize(valueCount + 1, OFFSET_WIDTH); if (size > MAX_ALLOCATION_SIZE) { throw new OversizedAllocationException("Memory required for vector capacity " + valueCount + " is (" + size + "), which is more than max allowed (" + MAX_ALLOCATION_SIZE + ")"); } return size; }
/** * Sets the desired value capacity for the vector. This function doesn't * allocate any memory for the vector. * * @param valueCount desired number of elements in the vector */ @Override public void setInitialCapacity(int valueCount) { final int size = getValidityBufferSizeFromCount(valueCount); if (size * 2 > MAX_ALLOCATION_SIZE) { throw new OversizedAllocationException("Requested amount of memory is more than max allowed"); } initialValueAllocation = valueCount; }
private void reallocTypeBuffer() { final int currentBufferCapacity = typeBuffer.capacity(); long baseSize = typeBufferAllocationSizeInBytes; if (baseSize < (long)currentBufferCapacity) { baseSize = (long)currentBufferCapacity; } long newAllocationSize = baseSize * 2L; newAllocationSize = BaseAllocator.nextPowerOfTwo(newAllocationSize); assert newAllocationSize >= 1; if (newAllocationSize > BaseValueVector.MAX_ALLOCATION_SIZE) { throw new OversizedAllocationException("Unable to expand the buffer"); } final ArrowBuf newBuf = allocator.buffer((int)newAllocationSize); newBuf.setBytes(0, typeBuffer, 0, currentBufferCapacity); newBuf.setZero(currentBufferCapacity, newBuf.capacity() - currentBufferCapacity); typeBuffer.release(1); typeBuffer = newBuf; typeBufferAllocationSizeInBytes = (int)newAllocationSize; }
private void allocateBytes(long size) { if(size > (long)MAX_ALLOCATION_SIZE) { throw new OversizedAllocationException("Requested amount of memory is more than max allowed allocation size"); } else { int curSize = (int)size; clear(); dataBuffer = this.allocator.buffer(curSize); dataBuffer.readerIndex(0); allocationSizeInBytes = (curSize > 0) ? curSize : allocationSizeInBytes; } }
public void setInitialCapacity(int numRecords, double density) { if ((numRecords * density) >= Integer.MAX_VALUE) { throw new OversizedAllocationException("Requested amount of memory is more than max allowed");
private void reallocValidityBuffer() { final int currentBufferCapacity = validityBuffer.capacity(); long baseSize = validityAllocationSizeInBytes; if (baseSize < (long) currentBufferCapacity) { baseSize = (long) currentBufferCapacity; } long newAllocationSize = baseSize * 2L; newAllocationSize = BaseAllocator.nextPowerOfTwo(newAllocationSize); assert newAllocationSize >= 1; if (newAllocationSize > BaseValueVector.MAX_ALLOCATION_SIZE) { throw new OversizedAllocationException("Unable to expand the buffer"); } final ArrowBuf newBuf = allocator.buffer((int) newAllocationSize); newBuf.setBytes(0, validityBuffer, 0, currentBufferCapacity); newBuf.setZero(currentBufferCapacity, newBuf.capacity() - currentBufferCapacity); validityBuffer.release(1); validityBuffer = newBuf; validityAllocationSizeInBytes = (int) newAllocationSize; }
private void reallocValidityBuffer() { final int currentBufferCapacity = validityBuffer.capacity(); long baseSize = validityAllocationSizeInBytes; if (baseSize < (long) currentBufferCapacity) { baseSize = (long) currentBufferCapacity; } long newAllocationSize = baseSize * 2L; newAllocationSize = BaseAllocator.nextPowerOfTwo(newAllocationSize); assert newAllocationSize >= 1; if (newAllocationSize > MAX_ALLOCATION_SIZE) { throw new OversizedAllocationException("Unable to expand the buffer"); } final ArrowBuf newBuf = allocator.buffer((int) newAllocationSize); newBuf.setBytes(0, validityBuffer, 0, currentBufferCapacity); newBuf.setZero(currentBufferCapacity, newBuf.capacity() - currentBufferCapacity); validityBuffer.release(1); validityBuffer = newBuf; validityAllocationSizeInBytes = (int) newAllocationSize; }
protected void reallocOffsetBuffer() { final int currentBufferCapacity = offsetBuffer.capacity(); long baseSize = offsetAllocationSizeInBytes; if (baseSize < (long) currentBufferCapacity) { baseSize = (long) currentBufferCapacity; } long newAllocationSize = baseSize * 2L; newAllocationSize = BaseAllocator.nextPowerOfTwo(newAllocationSize); assert newAllocationSize >= 1; if (newAllocationSize > MAX_ALLOCATION_SIZE) { throw new OversizedAllocationException("Unable to expand the buffer"); } final ArrowBuf newBuf = allocator.buffer((int) newAllocationSize); newBuf.setBytes(0, offsetBuffer, 0, currentBufferCapacity); newBuf.setZero(currentBufferCapacity, newBuf.capacity() - currentBufferCapacity); offsetBuffer.release(1); offsetBuffer = newBuf; offsetAllocationSizeInBytes = (int) newAllocationSize; }
private void reallocValidityBuffer() { final int currentBufferCapacity = validityBuffer.capacity(); long baseSize = validityAllocationSizeInBytes; if (baseSize < (long) currentBufferCapacity) { baseSize = (long) currentBufferCapacity; } long newAllocationSize = baseSize * 2L; newAllocationSize = BaseAllocator.nextPowerOfTwo(newAllocationSize); assert newAllocationSize >= 1; if (newAllocationSize > MAX_ALLOCATION_SIZE) { throw new OversizedAllocationException("Unable to expand the buffer"); } final ArrowBuf newBuf = allocator.buffer((int) newAllocationSize); newBuf.setBytes(0, validityBuffer, 0, currentBufferCapacity); newBuf.setZero(currentBufferCapacity, newBuf.capacity() - currentBufferCapacity); validityBuffer.release(1); validityBuffer = newBuf; validityAllocationSizeInBytes = (int) newAllocationSize; }
public void reAlloc() { long baseSize = (long)allocationSizeInBytes; int currentBufferCapacity = dataBuffer.capacity(); if(baseSize < (long)currentBufferCapacity) { baseSize = (long)currentBufferCapacity; } long newAllocationSize = baseSize * 2L; newAllocationSize = BaseAllocator.nextPowerOfTwo(newAllocationSize); if(newAllocationSize > (long)MAX_ALLOCATION_SIZE) { throw new OversizedAllocationException("Unable to expand the buffer. Max allowed buffer size is reached."); } else { ArrowBuf newBuf = this.allocator.buffer((int)newAllocationSize); newBuf.setZero(0, newBuf.capacity()); newBuf.setBytes(0, dataBuffer, 0, currentBufferCapacity); newBuf.writerIndex(dataBuffer.writerIndex()); dataBuffer.release(1); dataBuffer = newBuf; allocationSizeInBytes = (int)newAllocationSize; } }