/** * Get the potential buffer size for a particular number of records. * * @param count desired number of elements in the vector * @return estimated size of underlying buffers if the vector holds * a given number of elements */ @Override public int getBufferSizeFor(final int count) { if (count == 0) { return 0; } return 2 * getValidityBufferSizeFromCount(count); }
/** * 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; }
public void load(SerializedField metadata, ArrowBuf buffer) { Preconditions.checkArgument(vector.name.equals(metadata.getNamePart().getName()), "The field %s doesn't match the provided metadata %s.", vector.name, metadata); final int valueCount = metadata.getValueCount(); final int expectedLength = vector.getValidityBufferSizeFromCount(valueCount); final int actualLength = metadata.getBufferLength(); assert expectedLength == actualLength: "expected and actual buffer sizes do not match"; vector.clear(); vector.valueBuffer = buffer.slice(0, actualLength); vector.valueBuffer.writerIndex(actualLength); vector.valueBuffer.retain(); vector.valueCount = valueCount; }
int firstByteSource = BitVectorHelper.byteIndex(startIndex); int lastByteSource = BitVectorHelper.byteIndex(valueCount - 1); int byteSizeTarget = getValidityBufferSizeFromCount(length); int offset = startIndex % 8;