mz_arrow_util/
lib.rs

1// Copyright Materialize, Inc. and contributors. All rights reserved.
2//
3// Use of this software is governed by the Business Source License
4// included in the LICENSE file.
5//
6// As of the Change Date specified in that file, in accordance with
7// the Business Source License, use of this software will be governed
8// by the Apache License, Version 2.0.
9
10use std::sync::Arc;
11
12use arrow::array::{ArrayRef, make_array};
13use arrow::buffer::NullBuffer;
14
15pub mod builder;
16pub mod reader;
17
18/// Merge the provided null buffer with the existing array's null buffer, if any.
19pub fn mask_nulls(column: &ArrayRef, null_mask: Option<&NullBuffer>) -> ArrayRef {
20    if null_mask.is_none() {
21        Arc::clone(column)
22    } else {
23        let nulls = NullBuffer::union(null_mask, column.nulls());
24        let data = column
25            .to_data()
26            .into_builder()
27            .nulls(nulls)
28            .build()
29            .expect("changed only null mask");
30        make_array(data)
31    }
32}