MCPcopy Create free account
hub / github.com/apache/datafusion / finish

Method finish

datafusion/functions/src/strings.rs:136–161  ·  view source on GitHub ↗

Finalize the builder into a concrete [`StringArray`]. # Errors Returns an error when: - the provided `null_buffer` is not the same length as the `offsets_buffer`.

(self, null_buffer: Option<NullBuffer>)

Source from the content-addressed store, hash-verified

134 ///
135 /// - the provided `null_buffer` is not the same length as the `offsets_buffer`.
136 pub fn finish(self, null_buffer: Option<NullBuffer>) -> Result<StringArray> {
137 let row_count = self.offsets_buffer.len() / size_of::<i32>() - 1;
138 if let Some(ref null_buffer) = null_buffer
139 && null_buffer.len() != row_count
140 {
141 return internal_err!(
142 "Null buffer and offsets buffer must be the same length"
143 );
144 }
145 let array_builder = ArrayDataBuilder::new(DataType::Utf8)
146 .len(row_count)
147 .add_buffer(self.offsets_buffer.into())
148 .add_buffer(self.value_buffer.into())
149 .nulls(null_buffer);
150 if self.tainted {
151 // Raw binary arrays with possible invalid utf-8 were used,
152 // so let ArrayDataBuilder perform validation
153 let array_data = array_builder.build()?;
154 Ok(StringArray::from(array_data))
155 } else {
156 // SAFETY: all data that was appended was valid UTF8 and the values
157 // and offsets were created correctly
158 let array_data = unsafe { array_builder.build_unchecked() };
159 Ok(StringArray::from(array_data))
160 }
161 }
162}
163
164/// Builder used by `concat`/`concat_ws` to assemble a [`StringViewArray`] one

Callers 15

hashFunction · 0.45
hashFunction · 0.45
hashFunction · 0.45
hashFunction · 0.45
hashFunction · 0.45
fmtMethod · 0.45
hash_valueMethod · 0.45
hashFunction · 0.45
fmtMethod · 0.45
hashFunction · 0.45
fmtMethod · 0.45
hashFunction · 0.45

Calls 9

newFunction · 0.85
null_countMethod · 0.80
lenMethod · 0.45
nullsMethod · 0.45
intoMethod · 0.45
buildMethod · 0.45
is_emptyMethod · 0.45
as_refMethod · 0.45
flush_in_progressMethod · 0.45