-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add docs and actually create scalar columns
- Loading branch information
1 parent
c0bb959
commit 4bda43a
Showing
9 changed files
with
230 additions
and
137 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
crates/polars-core/src/chunked_array/builder/binary_offset.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
use super::*; | ||
|
||
pub struct BinaryOffsetChunkedBuilder { | ||
pub(crate) chunk_builder: MutableBinaryArray<i64>, | ||
pub(crate) field: FieldRef, | ||
} | ||
|
||
impl Clone for BinaryOffsetChunkedBuilder { | ||
fn clone(&self) -> Self { | ||
Self { | ||
chunk_builder: self.chunk_builder.clone(), | ||
field: self.field.clone(), | ||
} | ||
} | ||
} | ||
|
||
impl BinaryOffsetChunkedBuilder { | ||
/// Create a new [`BinaryOffsetChunkedBuilder`] | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `capacity` - Number of string elements in the final array. | ||
pub fn new(name: PlSmallStr, capacity: usize) -> Self { | ||
Self { | ||
chunk_builder: MutableBinaryArray::with_capacity(capacity), | ||
field: Arc::new(Field::new(name, DataType::BinaryOffset)), | ||
} | ||
} | ||
|
||
/// Appends a value of type `T` into the builder | ||
#[inline] | ||
pub fn append_value(&mut self, v: &[u8]) { | ||
self.chunk_builder.push(Some(v)); | ||
} | ||
|
||
/// Appends a null slot into the builder | ||
#[inline] | ||
pub fn append_null(&mut self) { | ||
self.chunk_builder.push_null() | ||
} | ||
|
||
#[inline] | ||
pub fn append_option(&mut self, opt: Option<&[u8]>) { | ||
self.chunk_builder.push(opt); | ||
} | ||
|
||
pub fn finish(mut self) -> BinaryOffsetChunked { | ||
let arr = self.chunk_builder.as_box(); | ||
ChunkedArray::new_with_compute_len(self.field, vec![arr]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.