parquet_string_column_shrink_to_fit Subroutine

public subroutine parquet_string_column_shrink_to_fit(self)

Reallocates the buffers down to exactly the current size (frees unused capacity). Invalidates every outstanding handle into this column.

Arguments

Type IntentOptional Attributes Name
type(parquet_string_column), intent(inout) :: self

the column.


Source Code

    subroutine parquet_string_column_shrink_to_fit(self)
        type(parquet_string_column), intent(inout) :: self !! the column.
        integer(int64), allocatable :: to(:)
        character(len=1), allocatable :: td(:)
        integer(int8), allocatable :: tv(:)
        integer(int64) :: need_bytes
        if (allocated(self%offsets)) then
            if (size(self%offsets, kind=int64) > self%nrows+1) then
                allocate(to(self%nrows+1))
                to(:) = self%offsets(1:self%nrows+1)
                call move_alloc(to, self%offsets)
            end if
        end if
        if (allocated(self%data)) then
            if (self%nchars == 0) then
                deallocate(self%data)
            else if (size(self%data, kind=int64) > self%nchars) then
                allocate(td(self%nchars))
                td(:) = self%data(1:self%nchars)
                call move_alloc(td, self%data)
            end if
        end if
        if (self%has_nulls .and. allocated(self%validity)) then
            need_bytes = (self%nrows + 7_int64)/8_int64
            if (size(self%validity, kind=int64) > need_bytes .and. need_bytes >= 1) then
                allocate(tv(need_bytes))
                tv(:) = self%validity(1:need_bytes)
                call move_alloc(tv, self%validity)
            end if
        end if
    end subroutine parquet_string_column_shrink_to_fit