vector/src/main/java/org/apache/arrow/vector/complex/LargeListViewVector.java [749:944]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    return vals;
  }

  /**
   * Check if an element at given index is null.
   *
   * @param index position of an element
   * @return true if an element at given index is null, false otherwise
   */
  @Override
  public boolean isNull(int index) {
    return (isSet(index) == 0);
  }

  /**
   * Check if an element at given index is an empty list.
   *
   * @param index position of an element
   * @return true if an element at given index is an empty list or NULL, false otherwise
   */
  @Override
  public boolean isEmpty(int index) {
    if (isNull(index)) {
      return true;
    } else {
      return sizeBuffer.getInt(index * SIZE_WIDTH) == 0;
    }
  }

  /**
   * Same as {@link #isNull(int)}.
   *
   * @param index position of the element
   * @return 1 if element at given index is not null, 0 otherwise
   */
  public int isSet(int index) {
    final int byteIndex = index >> 3;
    final byte b = validityBuffer.getByte(byteIndex);
    final int bitIndex = index & 7;
    return (b >> bitIndex) & 0x01;
  }

  /**
   * Get the number of elements that are null in the vector.
   *
   * @return the number of null elements.
   */
  @Override
  public int getNullCount() {
    return BitVectorHelper.getNullCount(validityBuffer, valueCount);
  }

  /**
   * Get the value capacity by considering validity and offset capacity. Note that the size buffer
   * capacity is not considered here since it has the same capacity as the offset buffer.
   *
   * @return the value capacity
   */
  @Override
  public int getValueCapacity() {
    return getValidityAndOffsetValueCapacity();
  }

  private int getValidityAndSizeValueCapacity() {
    final int offsetValueCapacity = Math.max(getOffsetBufferValueCapacity(), 0);
    final int sizeValueCapacity = Math.max(getSizeBufferValueCapacity(), 0);
    return Math.min(offsetValueCapacity, sizeValueCapacity);
  }

  private int getValidityAndOffsetValueCapacity() {
    final int offsetValueCapacity = Math.max(getOffsetBufferValueCapacity(), 0);
    return Math.min(offsetValueCapacity, getValidityBufferValueCapacity());
  }

  private int getValidityBufferValueCapacity() {
    return capAtMaxInt(validityBuffer.capacity() * 8);
  }

  /**
   * Set the element at the given index to null.
   *
   * @param index the value to change
   */
  @Override
  public void setNull(int index) {
    while (index >= getValidityAndSizeValueCapacity()) {
      reallocValidityAndSizeAndOffsetBuffers();
    }

    offsetBuffer.setInt(index * OFFSET_WIDTH, 0);
    sizeBuffer.setInt(index * SIZE_WIDTH, 0);
    BitVectorHelper.unsetBit(validityBuffer, index);
  }

  /**
   * Start new value in the ListView vector.
   *
   * @param index index of the value to start
   * @return offset of the new value
   */
  @Override
  public int startNewValue(int index) {
    while (index >= getValidityAndSizeValueCapacity()) {
      reallocValidityAndSizeAndOffsetBuffers();
    }

    if (index > 0) {
      final int prevOffset = getMaxViewEndChildVectorByIndex(index);
      offsetBuffer.setInt(index * OFFSET_WIDTH, prevOffset);
    }

    BitVectorHelper.setBit(validityBuffer, index);
    return offsetBuffer.getInt(index * OFFSET_WIDTH);
  }

  /**
   * Validate the invariants of the offset and size buffers. 0 <= offsets[i] <= length of the child
   * array 0 <= offsets[i] + size[i] <= length of the child array
   *
   * @param offset the offset at a given index
   * @param size the size at a given index
   */
  private void validateInvariants(int offset, int size) {
    if (offset < 0) {
      throw new IllegalArgumentException("Offset cannot be negative");
    }

    if (size < 0) {
      throw new IllegalArgumentException("Size cannot be negative");
    }

    // 0 <= offsets[i] <= length of the child array
    if (offset > this.vector.getValueCount()) {
      throw new IllegalArgumentException("Offset is out of bounds.");
    }

    // 0 <= offsets[i] + size[i] <= length of the child array
    if (offset + size > this.vector.getValueCount()) {
      throw new IllegalArgumentException("Offset + size <= length of the child array.");
    }
  }

  /**
   * Set the offset at the given index. Make sure to use this function after updating `field` vector
   * and using `setValidity`
   *
   * @param index index of the value to set
   * @param value value to set
   */
  public void setOffset(int index, int value) {
    validateInvariants(value, sizeBuffer.getInt(index * SIZE_WIDTH));

    offsetBuffer.setInt(index * OFFSET_WIDTH, value);
  }

  /**
   * Set the size at the given index. Make sure to use this function after using `setOffset`.
   *
   * @param index index of the value to set
   * @param value value to set
   */
  public void setSize(int index, int value) {
    validateInvariants(offsetBuffer.getInt(index * SIZE_WIDTH), value);

    sizeBuffer.setInt(index * SIZE_WIDTH, value);
  }

  /**
   * Set the validity at the given index.
   *
   * @param index index of the value to set
   * @param value value to set (0 for unset and 1 for a set)
   */
  public void setValidity(int index, int value) {
    if (value == 0) {
      BitVectorHelper.unsetBit(validityBuffer, index);
    } else {
      BitVectorHelper.setBit(validityBuffer, index);
    }
  }

  /**
   * Sets the value count for the vector.
   *
   * <p>Important note: The underlying vector does not support 64-bit allocations yet. This may
   * throw if attempting to hold larger than what a 32-bit vector can store.
   *
   * @param valueCount value count
   */
  @Override
  public void setValueCount(int valueCount) {
    this.valueCount = valueCount;
    if (valueCount > 0) {
      while (valueCount > getValidityAndSizeValueCapacity()) {
        /* check if validity and offset buffers need to be re-allocated */
        reallocValidityAndSizeAndOffsetBuffers();
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



vector/src/main/java/org/apache/arrow/vector/complex/ListViewVector.java [754:941]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    return vals;
  }

  /**
   * Check if an element at given index is null.
   *
   * @param index position of an element
   * @return true if an element at given index is null, false otherwise
   */
  @Override
  public boolean isNull(int index) {
    return (isSet(index) == 0);
  }

  /**
   * Check if an element at given index is an empty list.
   *
   * @param index position of an element
   * @return true if an element at given index is an empty list or NULL, false otherwise
   */
  @Override
  public boolean isEmpty(int index) {
    if (isNull(index)) {
      return true;
    } else {
      return sizeBuffer.getInt(index * SIZE_WIDTH) == 0;
    }
  }

  /**
   * Same as {@link #isNull(int)}.
   *
   * @param index position of the element
   * @return 1 if element at given index is not null, 0 otherwise
   */
  public int isSet(int index) {
    final int byteIndex = index >> 3;
    final byte b = validityBuffer.getByte(byteIndex);
    final int bitIndex = index & 7;
    return (b >> bitIndex) & 0x01;
  }

  /**
   * Get the number of elements that are null in the vector.
   *
   * @return the number of null elements.
   */
  @Override
  public int getNullCount() {
    return BitVectorHelper.getNullCount(validityBuffer, valueCount);
  }

  /**
   * Get the value capacity by considering validity and offset capacity. Note that the size buffer
   * capacity is not considered here since it has the same capacity as the offset buffer.
   *
   * @return the value capacity
   */
  @Override
  public int getValueCapacity() {
    return getValidityAndOffsetValueCapacity();
  }

  private int getValidityAndSizeValueCapacity() {
    final int offsetValueCapacity = Math.max(getOffsetBufferValueCapacity(), 0);
    final int sizeValueCapacity = Math.max(getSizeBufferValueCapacity(), 0);
    return Math.min(offsetValueCapacity, sizeValueCapacity);
  }

  private int getValidityAndOffsetValueCapacity() {
    final int offsetValueCapacity = Math.max(getOffsetBufferValueCapacity(), 0);
    return Math.min(offsetValueCapacity, getValidityBufferValueCapacity());
  }

  private int getValidityBufferValueCapacity() {
    return capAtMaxInt(validityBuffer.capacity() * 8);
  }

  /**
   * Set the element at the given index to null.
   *
   * @param index the value to change
   */
  @Override
  public void setNull(int index) {
    while (index >= getValidityAndSizeValueCapacity()) {
      reallocValidityAndSizeAndOffsetBuffers();
    }

    offsetBuffer.setInt(index * OFFSET_WIDTH, 0);
    sizeBuffer.setInt(index * SIZE_WIDTH, 0);
    BitVectorHelper.unsetBit(validityBuffer, index);
  }

  /**
   * Start new value in the ListView vector.
   *
   * @param index index of the value to start
   * @return offset of the new value
   */
  @Override
  public int startNewValue(int index) {
    while (index >= getValidityAndSizeValueCapacity()) {
      reallocValidityAndSizeAndOffsetBuffers();
    }

    if (index > 0) {
      final int prevOffset = getMaxViewEndChildVectorByIndex(index);
      offsetBuffer.setInt(index * OFFSET_WIDTH, prevOffset);
    }

    BitVectorHelper.setBit(validityBuffer, index);
    return offsetBuffer.getInt(index * OFFSET_WIDTH);
  }

  /**
   * Validate the invariants of the offset and size buffers. 0 <= offsets[i] <= length of the child
   * array 0 <= offsets[i] + size[i] <= length of the child array
   *
   * @param offset the offset at a given index
   * @param size the size at a given index
   */
  private void validateInvariants(int offset, int size) {
    if (offset < 0) {
      throw new IllegalArgumentException("Offset cannot be negative");
    }

    if (size < 0) {
      throw new IllegalArgumentException("Size cannot be negative");
    }

    // 0 <= offsets[i] <= length of the child array
    if (offset > this.vector.getValueCount()) {
      throw new IllegalArgumentException("Offset is out of bounds.");
    }

    // 0 <= offsets[i] + size[i] <= length of the child array
    if (offset + size > this.vector.getValueCount()) {
      throw new IllegalArgumentException("Offset + size <= length of the child array.");
    }
  }

  /**
   * Set the offset at the given index. Make sure to use this function after updating `field` vector
   * and using `setValidity`
   *
   * @param index index of the value to set
   * @param value value to set
   */
  public void setOffset(int index, int value) {
    validateInvariants(value, sizeBuffer.getInt(index * SIZE_WIDTH));

    offsetBuffer.setInt(index * OFFSET_WIDTH, value);
  }

  /**
   * Set the size at the given index. Make sure to use this function after using `setOffset`.
   *
   * @param index index of the value to set
   * @param value value to set
   */
  public void setSize(int index, int value) {
    validateInvariants(offsetBuffer.getInt(index * SIZE_WIDTH), value);

    sizeBuffer.setInt(index * SIZE_WIDTH, value);
  }

  /**
   * Set the validity at the given index.
   *
   * @param index index of the value to set
   * @param value value to set (0 for unset and 1 for a set)
   */
  public void setValidity(int index, int value) {
    if (value == 0) {
      BitVectorHelper.unsetBit(validityBuffer, index);
    } else {
      BitVectorHelper.setBit(validityBuffer, index);
    }
  }

  @Override
  public void setValueCount(int valueCount) {
    this.valueCount = valueCount;
    if (valueCount > 0) {
      while (valueCount > getValidityAndSizeValueCapacity()) {
        /* check if validity and offset buffers need to be re-allocated */
        reallocValidityAndSizeAndOffsetBuffers();
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



