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

Function repeat_to_buffer

datafusion/functions/src/string/repeat.rs:273–286  ·  view source on GitHub ↗
(buffer: &mut Vec<u8>, string: &str, count: usize)

Source from the content-addressed store, hash-verified

271 // count must be > 0
272 #[inline]
273 fn repeat_to_buffer(buffer: &mut Vec<u8>, string: &str, count: usize) {
274 buffer.clear();
275 if !string.is_empty() {
276 let src = string.as_bytes();
277 // Initial copy
278 buffer.extend_from_slice(src);
279 // Doubling strategy: copy what we have so far until we reach the target
280 while buffer.len() < src.len() * count {
281 let copy_len = buffer.len().min(src.len() * count - buffer.len());
282 // SAFETY: we're copying valid UTF-8 bytes that we already verified
283 buffer.extend_from_within(..copy_len);
284 }
285 }
286 }
287
288 // Output is null IFF either input is null
289 let nulls = NullBuffer::union(string_array.nulls(), number_array.nulls());

Callers 1

repeat_implFunction · 0.85

Calls 4

clearMethod · 0.45
is_emptyMethod · 0.45
lenMethod · 0.45
minMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…