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

Function compute_repeat

datafusion/functions/src/string/repeat.rs:165–178  ·  view source on GitHub ↗
(s: &str, count: i64, max_size: usize)

Source from the content-addressed store, hash-verified

163/// Computes repeat for a single string value with max size check
164#[inline]
165fn compute_repeat(s: &str, count: i64, max_size: usize) -> Result<String> {
166 if count <= 0 {
167 return Ok(String::new());
168 }
169 let result_len = s.len().saturating_mul(count as usize);
170 if result_len > max_size {
171 return exec_err!(
172 "string size overflow on repeat, max size is {}, but got {}",
173 max_size,
174 result_len
175 );
176 }
177 Ok(s.repeat(count as usize))
178}
179
180/// Repeats string the specified number of times.
181/// repeat('Pg', 4) = 'PgPgPgPg'

Callers 1

invoke_with_argsMethod · 0.85

Calls 2

newFunction · 0.85
lenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…