Skip to main content

check_string_capacity

Function check_string_capacity 

Source
fn check_string_capacity(
    current_len: i32,
    space_needed: Option<i32>,
    limit: i32,
) -> Result<bool>
Expand description

Checks whether a string field builder that currently holds current_len bytes can additionally accommodate space_needed bytes of string data, given that the offset of a single Arrow string array is limited to limit (i32::MAX in production).

Returns:

  • Ok(true) if current_len + space_needed <= limit;
  • Ok(false) if space_needed <= limit but current_len + space_needed > limit, i.e. the current builder is too full but an empty builder could accommodate the batch (the caller may freeze the current builder and replay the batch onto an empty one);
  • Err(InvalidBatchSnafu) if the batch’s string data alone (space_needed, or the fact that its total bytes cannot even be represented as i32) exceeds limit, i.e. the batch can never be accommodated by any builder.