/** * Get the current value capacity for the vector. * @return number of elements that vector can hold. */ @Override public int getValueCapacity() { return getValidityAndOffsetValueCapacity(); }
public void setNotNull(int index) { while (index >= getValidityAndOffsetValueCapacity()) { reallocValidityAndOffsetBuffers(); } BitVectorHelper.setValidityBitToOne(validityBuffer, index); lastSet = index + 1; }
/** * Start a new value in the list vector. * * @param index index of the value to start */ @Override public int startNewValue(int index) { while (index >= getValidityAndOffsetValueCapacity()) { reallocValidityAndOffsetBuffers(); } for (int i = lastSet; i <= index; i++) { final int currentOffset = offsetBuffer.getInt(i * OFFSET_WIDTH); offsetBuffer.setInt((i + 1) * OFFSET_WIDTH, currentOffset); } BitVectorHelper.setValidityBitToOne(validityBuffer, index); lastSet = index + 1; return offsetBuffer.getInt(lastSet * OFFSET_WIDTH); }
/** * Sets the value count for the vector. * * @param valueCount value count */ @Override public void setValueCount(int valueCount) { this.valueCount = valueCount; if (valueCount > 0) { while (valueCount > getValidityAndOffsetValueCapacity()) { /* check if validity and offset buffers need to be re-allocated */ reallocValidityAndOffsetBuffers(); } for (int i = lastSet; i < valueCount; i++) { /* fill the holes with offsets */ final int currentOffset = offsetBuffer.getInt(i * OFFSET_WIDTH); offsetBuffer.setInt((i + 1) * OFFSET_WIDTH, currentOffset); } } /* valueCount for the data vector is the current end offset */ final int childValueCount = (valueCount == 0) ? 0 : offsetBuffer.getInt(valueCount * OFFSET_WIDTH); /* set the value count of data vector and this will take care of * checking whether data buffer needs to be reallocated. */ vector.setValueCount(childValueCount); }