Skip to content

Commit

Permalink
implement specific array builder for NullBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
rluvaton committed Dec 10, 2024
1 parent a8cb7d0 commit 878ec3e
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion arrow-array/src/builder/null_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

use crate::builder::ArrayBuilder;
use crate::builder::{SpecificArrayBuilder, ArrayBuilder};
use crate::{ArrayRef, NullArray};
use arrow_data::ArrayData;
use arrow_schema::DataType;
Expand Down Expand Up @@ -146,6 +146,43 @@ impl ArrayBuilder for NullBuilder {
}
}

impl SpecificArrayBuilder for NullBuilder {
type Output = NullArray;
type Item<'a> = ();

fn finish(&mut self) -> Arc<Self::Output> {
Arc::new(self.finish())
}

fn finish_cloned(&self) -> Arc<Self::Output> {
Arc::new(self.finish_cloned())
}

fn append_value<'a>(&'a mut self, value: Self::Item<'a>) {
self.append_null();
}

fn append_value_ref<'a>(&'a mut self, value: &'a Self::Item<'a>) {
self.append_null();
}

fn append_null(&mut self) {
self.append_null();
}

fn append_output<'a>(&'a mut self, output: &'a Self::Output) {
self.len += output.len();
}

fn append_nulls(&mut self, n: usize) {
self.append_nulls(n)
}

fn append_option<'a>(&'a mut self, v: Option<Self::Item<'a>>) {
self.append_null()
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down

0 comments on commit 878ec3e

Please sign in to comment.