public CompactList(int elementMaxLength, int capacity, BufferAllocator bufferAllocator) { this( bufferAllocator.allocate(requiredBufferCapacity(framedLength(elementMaxLength), capacity)), elementMaxLength, capacity); }
public CompactList(int elementMaxLength, int capacity, BufferAllocator bufferAllocator) { this( bufferAllocator.allocate(requiredBufferCapacity(framedLength(elementMaxLength), capacity)), elementMaxLength, capacity); }
public CompactList(AllocatedBuffer allocatedBuffer, int elementMaxLength, int capacity) { this.allocatedBuffer = allocatedBuffer; framedElementLength = framedLength(elementMaxLength); final int requiredBufferCapacity = requiredBufferCapacity(framedElementLength, capacity); final int bufferCapacity = allocatedBuffer.capacity(); if (bufferCapacity < requiredBufferCapacity) { final String errorMessage = String.format( "Not enough capacity in provided buffer. Has %d, required %d", bufferCapacity, requiredBufferCapacity); throw new IllegalArgumentException(errorMessage); } listBuffer = new UnsafeBuffer(0, 0); listBuffer.wrap(allocatedBuffer.getRawBuffer(), 0, requiredBufferCapacity); // write header listBuffer.putInt(sizeOffset(), 0); listBuffer.putInt(elementMaxLengthOffset(), elementMaxLength); listBuffer.putInt(capacityOffset(), capacity); iterator = new CompactListIterator(this); }
public CompactList(AllocatedBuffer allocatedBuffer, int elementMaxLength, int capacity) { this.allocatedBuffer = allocatedBuffer; framedElementLength = framedLength(elementMaxLength); final int requiredBufferCapacity = requiredBufferCapacity(framedElementLength, capacity); final int bufferCapacity = allocatedBuffer.capacity(); if (bufferCapacity < requiredBufferCapacity) { final String errorMessage = String.format( "Not enough capacity in provided buffer. Has %d, required %d", bufferCapacity, requiredBufferCapacity); throw new IllegalArgumentException(errorMessage); } listBuffer = new UnsafeBuffer(0, 0); listBuffer.wrap(allocatedBuffer.getRawBuffer(), 0, requiredBufferCapacity); // write header listBuffer.putInt(sizeOffset(), 0); listBuffer.putInt(elementMaxLengthOffset(), elementMaxLength); listBuffer.putInt(capacityOffset(), capacity); iterator = new CompactListIterator(this); }